]> git.lizzy.rs Git - rust.git/blob - src/compiletest/common.rs
Rollup merge of #31295 - steveklabnik:gh31266, 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     CodegenUnits
29 }
30
31 impl FromStr for Mode {
32     type Err = ();
33     fn from_str(s: &str) -> Result<Mode, ()> {
34         match s {
35           "compile-fail" => Ok(CompileFail),
36           "parse-fail" => Ok(ParseFail),
37           "run-fail" => Ok(RunFail),
38           "run-pass" => Ok(RunPass),
39           "run-pass-valgrind" => Ok(RunPassValgrind),
40           "pretty" => Ok(Pretty),
41           "debuginfo-lldb" => Ok(DebugInfoLldb),
42           "debuginfo-gdb" => Ok(DebugInfoGdb),
43           "codegen" => Ok(Codegen),
44           "rustdoc" => Ok(Rustdoc),
45           "codegen-units" => Ok(CodegenUnits),
46           _ => Err(()),
47         }
48     }
49 }
50
51 impl fmt::Display for Mode {
52     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
53         fmt::Display::fmt(match *self {
54             CompileFail => "compile-fail",
55             ParseFail => "parse-fail",
56             RunFail => "run-fail",
57             RunPass => "run-pass",
58             RunPassValgrind => "run-pass-valgrind",
59             Pretty => "pretty",
60             DebugInfoGdb => "debuginfo-gdb",
61             DebugInfoLldb => "debuginfo-lldb",
62             Codegen => "codegen",
63             Rustdoc => "rustdoc",
64             CodegenUnits => "codegen-units",
65         }, f)
66     }
67 }
68
69 #[derive(Clone)]
70 pub struct Config {
71     // The library paths required for running the compiler
72     pub compile_lib_path: String,
73
74     // The library paths required for running compiled programs
75     pub run_lib_path: String,
76
77     // The rustc executable
78     pub rustc_path: PathBuf,
79
80     // The rustdoc executable
81     pub rustdoc_path: PathBuf,
82
83     // The python executable
84     pub python: String,
85
86     // The llvm binaries path
87     pub llvm_bin_path: Option<PathBuf>,
88
89     // The valgrind path
90     pub valgrind_path: Option<String>,
91
92     // Whether to fail if we can't run run-pass-valgrind tests under valgrind
93     // (or, alternatively, to silently run them like regular run-pass tests).
94     pub force_valgrind: bool,
95
96     // The directory containing the tests to run
97     pub src_base: PathBuf,
98
99     // The directory where programs should be built
100     pub build_base: PathBuf,
101
102     // Directory for auxiliary libraries
103     pub aux_base: PathBuf,
104
105     // The name of the stage being built (stage1, etc)
106     pub stage_id: String,
107
108     // The test mode, compile-fail, run-fail, run-pass
109     pub mode: Mode,
110
111     // Run ignored tests
112     pub run_ignored: bool,
113
114     // Only run tests that match this filter
115     pub filter: Option<String>,
116
117     // Write out a parseable log of tests that were run
118     pub logfile: Option<PathBuf>,
119
120     // A command line to prefix program execution with,
121     // for running under valgrind
122     pub runtool: Option<String>,
123
124     // Flags to pass to the compiler when building for the host
125     pub host_rustcflags: Option<String>,
126
127     // Flags to pass to the compiler when building for the target
128     pub target_rustcflags: Option<String>,
129
130     // Target system to be tested
131     pub target: String,
132
133     // Host triple for the compiler being invoked
134     pub host: String,
135
136     // Version of GDB
137     pub gdb_version: Option<String>,
138
139     // Version of LLDB
140     pub lldb_version: Option<String>,
141
142     // Path to the android tools
143     pub android_cross_path: PathBuf,
144
145     // Extra parameter to run adb on arm-linux-androideabi
146     pub adb_path: String,
147
148     // Extra parameter to run test suite on arm-linux-androideabi
149     pub adb_test_dir: String,
150
151     // status whether android device available or not
152     pub adb_device_status: bool,
153
154     // the path containing LLDB's Python module
155     pub lldb_python_dir: Option<String>,
156
157     // Explain what's going on
158     pub verbose: bool
159 }