]> git.lizzy.rs Git - rust.git/blob - src/compiletest/common.rs
c29f74d74181087ab05ef8f6f6e79af20fdc6670
[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 regex::Regex;
15
16 #[derive(Clone, PartialEq)]
17 pub enum Mode {
18     CompileFail,
19     RunFail,
20     RunPass,
21     RunPassValgrind,
22     Pretty,
23     DebugInfoGdb,
24     DebugInfoLldb,
25     Codegen
26 }
27
28 impl Copy for Mode {}
29
30 impl FromStr for Mode {
31     fn from_str(s: &str) -> Option<Mode> {
32         match s {
33           "compile-fail" => Some(CompileFail),
34           "run-fail" => Some(RunFail),
35           "run-pass" => Some(RunPass),
36           "run-pass-valgrind" => Some(RunPassValgrind),
37           "pretty" => Some(Pretty),
38           "debuginfo-lldb" => Some(DebugInfoLldb),
39           "debuginfo-gdb" => Some(DebugInfoGdb),
40           "codegen" => Some(Codegen),
41           _ => None,
42         }
43     }
44 }
45
46 impl fmt::String for Mode {
47     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
48         fmt::String::fmt(match *self {
49             CompileFail => "compile-fail",
50             RunFail => "run-fail",
51             RunPass => "run-pass",
52             RunPassValgrind => "run-pass-valgrind",
53             Pretty => "pretty",
54             DebugInfoGdb => "debuginfo-gdb",
55             DebugInfoLldb => "debuginfo-lldb",
56             Codegen => "codegen",
57         }, f)
58     }
59 }
60
61 impl fmt::Show for Mode {
62     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
63         fmt::String::fmt(self, f)
64     }
65 }
66
67 #[derive(Clone)]
68 pub struct Config {
69     // The library paths required for running the compiler
70     pub compile_lib_path: String,
71
72     // The library paths required for running compiled programs
73     pub run_lib_path: String,
74
75     // The rustc executable
76     pub rustc_path: Path,
77
78     // The clang executable
79     pub clang_path: Option<Path>,
80
81     // The llvm binaries path
82     pub llvm_bin_path: Option<Path>,
83
84     // The valgrind path
85     pub valgrind_path: Option<String>,
86
87     // Whether to fail if we can't run run-pass-valgrind tests under valgrind
88     // (or, alternatively, to silently run them like regular run-pass tests).
89     pub force_valgrind: bool,
90
91     // The directory containing the tests to run
92     pub src_base: Path,
93
94     // The directory where programs should be built
95     pub build_base: Path,
96
97     // Directory for auxiliary libraries
98     pub aux_base: Path,
99
100     // The name of the stage being built (stage1, etc)
101     pub stage_id: String,
102
103     // The test mode, compile-fail, run-fail, run-pass
104     pub mode: Mode,
105
106     // Run ignored tests
107     pub run_ignored: bool,
108
109     // Only run tests that match this filter
110     pub filter: Option<Regex>,
111
112     // Precompiled regex for finding expected errors in cfail
113     pub cfail_regex: Regex,
114
115     // Write out a parseable log of tests that were run
116     pub logfile: Option<Path>,
117
118     // Write out a json file containing any metrics of the run
119     pub save_metrics: Option<Path>,
120
121     // Write and ratchet a metrics file
122     pub ratchet_metrics: Option<Path>,
123
124     // Percent change in metrics to consider noise
125     pub ratchet_noise_percent: Option<f64>,
126
127     // "Shard" of the testsuite to pub run: this has the form of
128     // two numbers (a,b), and causes only those tests with
129     // positional order equal to a mod b to run.
130     pub test_shard: Option<(uint,uint)>,
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     // Run tests using the JIT
143     pub jit: bool,
144
145     // Target system to be tested
146     pub target: String,
147
148     // Host triple for the compiler being invoked
149     pub host: String,
150
151     // Version of GDB
152     pub gdb_version: Option<String>,
153
154     // Version of LLDB
155     pub lldb_version: Option<String>,
156
157     // Path to the android tools
158     pub android_cross_path: Path,
159
160     // Extra parameter to run adb on arm-linux-androideabi
161     pub adb_path: String,
162
163     // Extra parameter to run test suite on arm-linux-androideabi
164     pub adb_test_dir: String,
165
166     // status whether android device available or not
167     pub adb_device_status: bool,
168
169     // the path containing LLDB's Python module
170     pub lldb_python_dir: Option<String>,
171
172     // Explain what's going on
173     pub verbose: bool
174 }