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