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