Skip to content

Commit cbb13f4

Browse files
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.
2 parents 616ee87 + 8a9c620 commit cbb13f4

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl CompareMode {
117117
}
118118
}
119119

120+
/// Configuration for compiletest
120121
#[derive(Clone)]
121122
pub struct Config {
122123
/// `true` to to overwrite stderr/stdout files instead of complaining about changes in output.
@@ -254,6 +255,8 @@ pub struct Config {
254255
pub linker: Option<String>,
255256
pub llvm_components: String,
256257
pub llvm_cxxflags: String,
258+
259+
/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests
257260
pub nodejs: Option<String>,
258261
}
259262

src/tools/compiletest/src/header.rs

+3
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ pub struct TestProps {
333333
pub normalize_stdout: Vec<(String, String)>,
334334
pub normalize_stderr: Vec<(String, String)>,
335335
pub failure_status: i32,
336+
// Whether or not `rustfix` should apply the `CodeSuggestion`s of this test and compile the
337+
// resulting Rust code.
336338
pub run_rustfix: bool,
339+
// If true, `rustfix` will only apply `MachineApplicable` suggestions.
337340
pub rustfix_only_machine_applicable: bool,
338341
pub assembly_output: Option<String>,
339342
}

src/tools/compiletest/src/json.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
//! These structs are a subset of the ones found in `syntax::json`.
2+
//! They are only used for deserialization of JSON output provided by libtest.
3+
14
use crate::errors::{Error, ErrorKind};
25
use crate::runtest::ProcRes;
36
use serde_json;
47
use std::path::Path;
58
use std::str::FromStr;
69

7-
// These structs are a subset of the ones found in
8-
// `syntax::json`.
9-
1010
#[derive(Deserialize)]
1111
struct Diagnostic {
1212
message: String,

src/tools/compiletest/src/main.rs

+11
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ fn collect_tests_from_dir(
598598
Ok(())
599599
}
600600

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

@@ -1048,3 +1050,12 @@ fn test_extract_gdb_version() {
10481050
7012050: "GNU gdb (GDB) 7.12.50.20161027-git",
10491051
}
10501052
}
1053+
1054+
#[test]
1055+
fn is_test_test() {
1056+
assert_eq!(true, is_test(&OsString::from("a_test.rs")));
1057+
assert_eq!(false, is_test(&OsString::from(".a_test.rs")));
1058+
assert_eq!(false, is_test(&OsString::from("a_cat.gif")));
1059+
assert_eq!(false, is_test(&OsString::from("#a_dog_gif")));
1060+
assert_eq!(false, is_test(&OsString::from("~a_temp_file")));
1061+
}

0 commit comments

Comments
 (0)