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