]> git.lizzy.rs Git - rust.git/blob - src/compiletest/common.rs
Auto merge of #25359 - thepowersgang:result-expect-2, r=alexcrichton
[rust.git] / src / compiletest / common.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10 pub use self::Mode::*;
11
12 use std::fmt;
13 use std::str::FromStr;
14 use std::path::PathBuf;
15
16 #[derive(Clone, Copy, PartialEq, Debug)]
17 pub enum Mode {
18     CompileFail,
19     ParseFail,
20     RunFail,
21     RunPass,
22     RunPassValgrind,
23     Pretty,
24     DebugInfoGdb,
25     DebugInfoLldb,
26     Codegen,
27     Rustdoc,
28 }
29
30 impl FromStr for Mode {
31     type Err = ();
32     fn from_str(s: &str) -> Result<Mode, ()> {
33         match s {
34           "compile-fail" => Ok(CompileFail),
35           "parse-fail" => Ok(ParseFail),
36           "run-fail" => Ok(RunFail),
37           "run-pass" => Ok(RunPass),
38           "run-pass-valgrind" => Ok(RunPassValgrind),
39           "pretty" => Ok(Pretty),
40           "debuginfo-lldb" => Ok(DebugInfoLldb),
41           "debuginfo-gdb" => Ok(DebugInfoGdb),
42           "codegen" => Ok(Codegen),
43           "rustdoc" => Ok(Rustdoc),
44           _ => Err(()),
45         }
46     }
47 }
48
49 impl fmt::Display for Mode {
50     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
51         fmt::Display::fmt(match *self {
52             CompileFail => "compile-fail",
53             ParseFail => "parse-fail",
54             RunFail => "run-fail",
55             RunPass => "run-pass",
56             RunPassValgrind => "run-pass-valgrind",
57             Pretty => "pretty",
58             DebugInfoGdb => "debuginfo-gdb",
59             DebugInfoLldb => "debuginfo-lldb",
60             Codegen => "codegen",
61             Rustdoc => "rustdoc",
62         }, f)
63     }
64 }
65
66 #[derive(Clone)]
67 pub struct Config {
68     // The library paths required for running the compiler
69     pub compile_lib_path: String,
70
71     // The library paths required for running compiled programs
72     pub run_lib_path: String,
73
74     // The rustc executable
75     pub rustc_path: PathBuf,
76
77     // The rustdoc executable
78     pub rustdoc_path: PathBuf,
79
80     // The python executable
81     pub python: String,
82
83     // The llvm binaries path
84     pub llvm_bin_path: Option<PathBuf>,
85
86     // The valgrind path
87     pub valgrind_path: Option<String>,
88
89     // Whether to fail if we can't run run-pass-valgrind tests under valgrind
90     // (or, alternatively, to silently run them like regular run-pass tests).
91     pub force_valgrind: bool,
92
93     // The directory containing the tests to run
94     pub src_base: PathBuf,
95
96     // The directory where programs should be built
97     pub build_base: PathBuf,
98
99     // Directory for auxiliary libraries
100     pub aux_base: PathBuf,
101
102     // The name of the stage being built (stage1, etc)
103     pub stage_id: String,
104
105     // The test mode, compile-fail, run-fail, run-pass
106     pub mode: Mode,
107
108     // Run ignored tests
109     pub run_ignored: bool,
110
111     // Only run tests that match this filter
112     pub filter: Option<String>,
113
114     // Write out a parseable log of tests that were run
115     pub logfile: Option<PathBuf>,
116
117     // A command line to prefix program execution with,
118     // for running under valgrind
119     pub runtool: Option<String>,
120
121     // Flags to pass to the compiler when building for the host
122     pub host_rustcflags: Option<String>,
123
124     // Flags to pass to the compiler when building for the target
125     pub target_rustcflags: Option<String>,
126
127     // Target system to be tested
128     pub target: String,
129
130     // Host triple for the compiler being invoked
131     pub host: String,
132
133     // Version of GDB
134     pub gdb_version: Option<String>,
135
136     // Version of LLDB
137     pub lldb_version: Option<String>,
138
139     // Path to the android tools
140     pub android_cross_path: PathBuf,
141
142     // Extra parameter to run adb on arm-linux-androideabi
143     pub adb_path: String,
144
145     // Extra parameter to run test suite on arm-linux-androideabi
146     pub adb_test_dir: String,
147
148     // status whether android device available or not
149     pub adb_device_status: bool,
150
151     // the path containing LLDB's Python module
152     pub lldb_python_dir: Option<String>,
153
154     // Explain what's going on
155     pub verbose: bool
156 }