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