]> git.lizzy.rs Git - rust.git/blob - src/compiletest/common.rs
ca59f344e288f6e984e3a28394cf80cbf69d48b1
[rust.git] / src / compiletest / common.rs
1 // Copyright 2012-2013 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
11 use std::from_str::FromStr;
12 use std::fmt;
13
14 #[deriving(Clone, Eq)]
15 pub enum Mode {
16     CompileFail,
17     RunFail,
18     RunPass,
19     Pretty,
20     DebugInfoGdb,
21     DebugInfoLldb,
22     Codegen
23 }
24
25 impl FromStr for Mode {
26     fn from_str(s: &str) -> Option<Mode> {
27         match s {
28           "compile-fail" => Some(CompileFail),
29           "run-fail" => Some(RunFail),
30           "run-pass" => Some(RunPass),
31           "pretty" => Some(Pretty),
32           "debuginfo-lldb" => Some(DebugInfoLldb),
33           "debuginfo-gdb" => Some(DebugInfoGdb),
34           "codegen" => Some(Codegen),
35           _ => None,
36         }
37     }
38 }
39
40 impl fmt::Show for Mode {
41     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
42         let msg = match *self {
43           CompileFail => "compile-fail",
44           RunFail => "run-fail",
45           RunPass => "run-pass",
46           Pretty => "pretty",
47           DebugInfoGdb => "debuginfo-gdb",
48           DebugInfoLldb => "debuginfo-lldb",
49           Codegen => "codegen",
50         };
51         write!(f.buf, "{}", msg)
52     }
53 }
54
55 #[deriving(Clone)]
56 pub struct Config {
57     // The library paths required for running the compiler
58     pub compile_lib_path: ~str,
59
60     // The library paths required for running compiled programs
61     pub run_lib_path: ~str,
62
63     // The rustc executable
64     pub rustc_path: Path,
65
66     // The clang executable
67     pub clang_path: Option<Path>,
68
69     // The llvm binaries path
70     pub llvm_bin_path: Option<Path>,
71
72     // The directory containing the tests to run
73     pub src_base: Path,
74
75     // The directory where programs should be built
76     pub build_base: Path,
77
78     // Directory for auxiliary libraries
79     pub aux_base: Path,
80
81     // The name of the stage being built (stage1, etc)
82     pub stage_id: ~str,
83
84     // The test mode, compile-fail, run-fail, run-pass
85     pub mode: Mode,
86
87     // Run ignored tests
88     pub run_ignored: bool,
89
90     // Only run tests that match this filter
91     pub filter: Option<~str>,
92
93     // Write out a parseable log of tests that were run
94     pub logfile: Option<Path>,
95
96     // Write out a json file containing any metrics of the run
97     pub save_metrics: Option<Path>,
98
99     // Write and ratchet a metrics file
100     pub ratchet_metrics: Option<Path>,
101
102     // Percent change in metrics to consider noise
103     pub ratchet_noise_percent: Option<f64>,
104
105     // "Shard" of the testsuite to pub run: this has the form of
106     // two numbers (a,b), and causes only those tests with
107     // positional order equal to a mod b to run.
108     pub test_shard: Option<(uint,uint)>,
109
110     // A command line to prefix program execution with,
111     // for running under valgrind
112     pub runtool: Option<~str>,
113
114     // Flags to pass to the compiler when building for the host
115     pub host_rustcflags: Option<~str>,
116
117     // Flags to pass to the compiler when building for the target
118     pub target_rustcflags: Option<~str>,
119
120     // Run tests using the JIT
121     pub jit: bool,
122
123     // Target system to be tested
124     pub target: ~str,
125
126     // Host triple for the compiler being invoked
127     pub host: ~str,
128
129     // Extra parameter to run adb on arm-linux-androideabi
130     pub adb_path: ~str,
131
132     // Extra parameter to run test sute on arm-linux-androideabi
133     pub adb_test_dir: ~str,
134
135     // status whether android device available or not
136     pub adb_device_status: bool,
137
138     // the path containing LLDB's Python module
139     pub lldb_python_dir: Option<~str>,
140
141     // Explain what's going on
142     pub verbose: bool
143
144 }