]> git.lizzy.rs Git - rust.git/blob - src/tools/compiletest/src/common.rs
Auto merge of #42394 - ollie27:rustdoc_deref_box, r=QuietMisdreavus
[rust.git] / src / tools / compiletest / src / 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 use test::ColorConfig;
17
18 #[derive(Clone, Copy, PartialEq, Debug)]
19 pub enum Mode {
20     CompileFail,
21     ParseFail,
22     RunFail,
23     RunPass,
24     RunPassValgrind,
25     Pretty,
26     DebugInfoGdb,
27     DebugInfoLldb,
28     Codegen,
29     Rustdoc,
30     CodegenUnits,
31     Incremental,
32     RunMake,
33     Ui,
34     MirOpt,
35 }
36
37 impl FromStr for Mode {
38     type Err = ();
39     fn from_str(s: &str) -> Result<Mode, ()> {
40         match s {
41             "compile-fail" => Ok(CompileFail),
42             "parse-fail" => Ok(ParseFail),
43             "run-fail" => Ok(RunFail),
44             "run-pass" => Ok(RunPass),
45             "run-pass-valgrind" => Ok(RunPassValgrind),
46             "pretty" => Ok(Pretty),
47             "debuginfo-lldb" => Ok(DebugInfoLldb),
48             "debuginfo-gdb" => Ok(DebugInfoGdb),
49             "codegen" => Ok(Codegen),
50             "rustdoc" => Ok(Rustdoc),
51             "codegen-units" => Ok(CodegenUnits),
52             "incremental" => Ok(Incremental),
53             "run-make" => Ok(RunMake),
54             "ui" => Ok(Ui),
55             "mir-opt" => Ok(MirOpt),
56             _ => Err(()),
57         }
58     }
59 }
60
61 impl fmt::Display for Mode {
62     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
63         fmt::Display::fmt(match *self {
64                               CompileFail => "compile-fail",
65                               ParseFail => "parse-fail",
66                               RunFail => "run-fail",
67                               RunPass => "run-pass",
68                               RunPassValgrind => "run-pass-valgrind",
69                               Pretty => "pretty",
70                               DebugInfoGdb => "debuginfo-gdb",
71                               DebugInfoLldb => "debuginfo-lldb",
72                               Codegen => "codegen",
73                               Rustdoc => "rustdoc",
74                               CodegenUnits => "codegen-units",
75                               Incremental => "incremental",
76                               RunMake => "run-make",
77                               Ui => "ui",
78                               MirOpt => "mir-opt",
79                           },
80                           f)
81     }
82 }
83
84 #[derive(Clone)]
85 pub struct Config {
86     // The library paths required for running the compiler
87     pub compile_lib_path: PathBuf,
88
89     // The library paths required for running compiled programs
90     pub run_lib_path: PathBuf,
91
92     // The rustc executable
93     pub rustc_path: PathBuf,
94
95     // The rustdoc executable
96     pub rustdoc_path: PathBuf,
97
98     // The python executable to use for LLDB
99     pub lldb_python: String,
100
101     // The python executable to use for htmldocck
102     pub docck_python: String,
103
104     // The llvm FileCheck binary path
105     pub llvm_filecheck: Option<PathBuf>,
106
107     // The valgrind path
108     pub valgrind_path: Option<String>,
109
110     // Whether to fail if we can't run run-pass-valgrind tests under valgrind
111     // (or, alternatively, to silently run them like regular run-pass tests).
112     pub force_valgrind: bool,
113
114     // The directory containing the tests to run
115     pub src_base: PathBuf,
116
117     // The directory where programs should be built
118     pub build_base: PathBuf,
119
120     // The name of the stage being built (stage1, etc)
121     pub stage_id: String,
122
123     // The test mode, compile-fail, run-fail, run-pass
124     pub mode: Mode,
125
126     // Run ignored tests
127     pub run_ignored: bool,
128
129     // Only run tests that match this filter
130     pub filter: Option<String>,
131
132     // Exactly match the filter, rather than a substring
133     pub filter_exact: bool,
134
135     // Write out a parseable log of tests that were run
136     pub logfile: Option<PathBuf>,
137
138     // A command line to prefix program execution with,
139     // for running under valgrind
140     pub runtool: Option<String>,
141
142     // Flags to pass to the compiler when building for the host
143     pub host_rustcflags: Option<String>,
144
145     // Flags to pass to the compiler when building for the target
146     pub target_rustcflags: Option<String>,
147
148     // Target system to be tested
149     pub target: String,
150
151     // Host triple for the compiler being invoked
152     pub host: String,
153
154     // Path to / name of the GDB executable
155     pub gdb: Option<String>,
156
157     // Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
158     pub gdb_version: Option<u32>,
159
160     // Whether GDB has native rust support
161     pub gdb_native_rust: bool,
162
163     // Version of LLDB
164     pub lldb_version: Option<String>,
165
166     // Version of LLVM
167     pub llvm_version: Option<String>,
168
169     // Path to the android tools
170     pub android_cross_path: PathBuf,
171
172     // Extra parameter to run adb on arm-linux-androideabi
173     pub adb_path: String,
174
175     // Extra parameter to run test suite on arm-linux-androideabi
176     pub adb_test_dir: String,
177
178     // status whether android device available or not
179     pub adb_device_status: bool,
180
181     // the path containing LLDB's Python module
182     pub lldb_python_dir: Option<String>,
183
184     // Explain what's going on
185     pub verbose: bool,
186
187     // Print one character per test instead of one line
188     pub quiet: bool,
189
190     // Whether to use colors in test.
191     pub color: ColorConfig,
192
193     // where to find the remote test client process, if we're using it
194     pub remote_test_client: Option<PathBuf>,
195
196     // Configuration for various run-make tests frobbing things like C compilers
197     // or querying about various LLVM component information.
198     pub cc: String,
199     pub cxx: String,
200     pub cflags: String,
201     pub llvm_components: String,
202     pub llvm_cxxflags: String,
203     pub nodejs: Option<String>,
204 }