Skip to content

Improve some compiletest documentation #59432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl CompareMode {
}
}

/// Configuration for compiletest
#[derive(Clone)]
pub struct Config {
/// `true` to to overwrite stderr/stdout files instead of complaining about changes in output.
Expand Down Expand Up @@ -254,6 +255,8 @@ pub struct Config {
pub linker: Option<String>,
pub llvm_components: String,
pub llvm_cxxflags: String,

/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests
pub nodejs: Option<String>,
}

Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ pub struct TestProps {
pub normalize_stdout: Vec<(String, String)>,
pub normalize_stderr: Vec<(String, String)>,
pub failure_status: i32,
// Whether or not `rustfix` should apply the `CodeSuggestion`s of this test and compile the
// resulting Rust code.
pub run_rustfix: bool,
// If true, `rustfix` will only apply `MachineApplicable` suggestions.
pub rustfix_only_machine_applicable: bool,
pub assembly_output: Option<String>,
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/json.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! These structs are a subset of the ones found in `syntax::json`.
//! They are only used for deserialization of JSON output provided by libtest.

use crate::errors::{Error, ErrorKind};
use crate::runtest::ProcRes;
use serde_json;
use std::path::Path;
use std::str::FromStr;

// These structs are a subset of the ones found in
// `syntax::json`.

#[derive(Deserialize)]
struct Diagnostic {
message: String,
Expand Down
11 changes: 11 additions & 0 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ fn collect_tests_from_dir(
Ok(())
}


/// Returns true if `file_name` looks like a proper test file name.
pub fn is_test(file_name: &OsString) -> bool {
let file_name = file_name.to_str().unwrap();

Expand Down Expand Up @@ -1048,3 +1050,12 @@ fn test_extract_gdb_version() {
7012050: "GNU gdb (GDB) 7.12.50.20161027-git",
}
}

#[test]
fn is_test_test() {
assert_eq!(true, is_test(&OsString::from("a_test.rs")));
assert_eq!(false, is_test(&OsString::from(".a_test.rs")));
assert_eq!(false, is_test(&OsString::from("a_cat.gif")));
assert_eq!(false, is_test(&OsString::from("#a_dog_gif")));
assert_eq!(false, is_test(&OsString::from("~a_temp_file")));
}