Skip to content

Commit

Permalink
Reformat and fix tidy error
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu committed Mar 7, 2024
1 parent 32e713f commit a7ee012
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-mode-incremental",
"ignore-mode-js-doc-test",
"ignore-mode-mir-opt",
"ignore-mode-pretty",
"ignore-mode-run-make",
"ignore-mode-run-pass-valgrind",
"ignore-mode-rustdoc",
"ignore-mode-rustdoc-json",
"ignore-mode-pretty",
"ignore-mode-ui",
"ignore-mode-ui-fulldeps",
"ignore-msp430",
Expand Down Expand Up @@ -993,7 +993,8 @@ fn iter_header(
if testfile.extension().map(|e| e == "rs").unwrap_or(false) {
let directive_ln = non_revisioned_directive_line.trim();

let CheckDirectiveResult { is_known_directive, directive_name } = check_directive(directive_ln);
let CheckDirectiveResult { is_known_directive, directive_name } =
check_directive(directive_ln);

if !is_known_directive {
*poisoned = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ check-pass

//~ HELP
fn main() { } //~ERROR
fn main() {} //~ERROR
//~^ ERROR
//~| ERROR
30 changes: 25 additions & 5 deletions src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,34 +623,54 @@ fn run_path(poisoned: &mut bool, path: &Path, buf: &[u8]) {
#[test]
fn test_unknown_directive_check() {
let mut poisoned = false;
run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/unknown_directive.rs"));
run_path(
&mut poisoned,
Path::new("a.rs"),
include_bytes!("./directive_checks/unknown_directive.rs"),
);
assert!(poisoned);
}

#[test]
fn test_known_legacy_directive_check() {
let mut poisoned = false;
run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/known_legacy_directive.rs"));
run_path(
&mut poisoned,
Path::new("a.rs"),
include_bytes!("./directive_checks/known_legacy_directive.rs"),
);
assert!(poisoned);
}

#[test]
fn test_known_directive_check_no_error() {
let mut poisoned = false;
run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/known_directive.rs"));
run_path(
&mut poisoned,
Path::new("a.rs"),
include_bytes!("./directive_checks/known_directive.rs"),
);
assert!(!poisoned);
}

#[test]
fn test_error_annotation_no_error() {
let mut poisoned = false;
run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/error_annotation.rs"));
run_path(
&mut poisoned,
Path::new("a.rs"),
include_bytes!("./directive_checks/error_annotation.rs"),
);
assert!(!poisoned);
}

#[test]
fn test_non_rs_unknown_directive_not_checked() {
let mut poisoned = false;
run_path(&mut poisoned, Path::new("a.Makefile"), include_bytes!("./directive_checks/not_rs.Makefile"));
run_path(
&mut poisoned,
Path::new("a.Makefile"),
include_bytes!("./directive_checks/not_rs.Makefile"),
);
assert!(!poisoned);
}
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::process::Command;

use tracing::*;

pub(crate) mod edit_distance;
#[cfg(test)]
mod tests;
pub(crate) mod edit_distance;

pub fn make_new_path(path: &str) -> String {
assert!(cfg!(windows));
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/util/edit_distance.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Edit distance taken from rustc's `rustc_span::edit_distance`.

use std::mem;
use std::cmp;
use std::mem;

/// Finds the [edit distance] between two strings.
///
Expand Down

0 comments on commit a7ee012

Please sign in to comment.