Rollup merge of #59432 - phansch:compiletest_docs, r=alexcrichton

Improve some compiletest documentation

This adds some missing documentation for rustfix related things and adds
a test for the `is_test` function.
This commit is contained in:
Guillaume Gomez 2019-03-26 22:26:46 +01:00 committed by GitHub
commit cbb13f496c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View file

@ -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.
@ -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>,
}

View file

@ -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>,
}

View file

@ -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,

View file

@ -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();
@ -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")));
}