Skip to content

Commit

Permalink
Auto merge of #2332 - rust-lang:slash_slash_at, r=oli-obk
Browse files Browse the repository at this point in the history
More robust comment parsing

fixes #2170

I haven't ported the entire test suite yet. Once we've done that, I will remove the old parsing system (or in fact, turn them into errors so that accidental usage of old-style comments will be detected)
  • Loading branch information
bors committed Jul 8, 2022
2 parents cde87d1 + 6e10661 commit 7a6a812
Show file tree
Hide file tree
Showing 273 changed files with 1,062 additions and 482 deletions.
194 changes: 194 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use colored::*;
use regex::Regex;
use std::env;
use std::path::PathBuf;
use ui_test::{Config, Mode, OutputConflictHandling};
use ui_test::{color_eyre::Result, Config, Mode, OutputConflictHandling};

fn miri_path() -> PathBuf {
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
}

fn run_tests(mode: Mode, path: &str, target: Option<String>) {
fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();

// Add some flags we always want.
Expand Down Expand Up @@ -108,7 +108,7 @@ regexes! {
"sys/[a-z]+/" => "sys/PLATFORM/",
}

fn ui(mode: Mode, path: &str) {
fn ui(mode: Mode, path: &str) -> Result<()> {
let target = get_target();

let msg = format!(
Expand All @@ -117,20 +117,24 @@ fn ui(mode: Mode, path: &str) {
);
eprintln!("{}", msg.green().bold());

run_tests(mode, path, target);
run_tests(mode, path, target)
}

fn get_target() -> Option<String> {
env::var("MIRI_TEST_TARGET").ok()
}

fn main() {
fn main() -> Result<()> {
ui_test::color_eyre::install()?;

// Add a test env var to do environment communication tests.
env::set_var("MIRI_ENV_VAR_TEST", "0");
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
env::set_var("MIRI_TEMP", env::temp_dir());

ui(Mode::Pass, "tests/pass");
ui(Mode::Panic, "tests/panic");
ui(Mode::Fail, "tests/fail");
ui(Mode::Pass, "tests/pass")?;
ui(Mode::Panic, "tests/panic")?;
ui(Mode::Fail, "tests/fail")?;

Ok(())
}
2 changes: 1 addition & 1 deletion tests/fail/alloc/deallocate-bad-alignment.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::alloc::{alloc, dealloc, Layout};

// error-pattern: has size 1 and alignment 1, but gave size 1 and alignment 2
//@error-pattern: has size 1 and alignment 1, but gave size 1 and alignment 2

fn main() {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/alloc/deallocate-bad-size.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::alloc::{alloc, dealloc, Layout};

// error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1
//@error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1

fn main() {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/alloc/deallocate-twice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::alloc::{alloc, dealloc, Layout};

// error-pattern: dereferenced after this allocation got freed
//@error-pattern: dereferenced after this allocation got freed

fn main() {
unsafe {
Expand Down
8 changes: 4 additions & 4 deletions tests/fail/alloc/global_system_mixup.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Make sure we detect when the `Global` and `System` allocators are mixed
// (even when the default `Global` uses `System`).
// error-pattern: which is Rust heap memory, using
//@error-pattern: which is Rust heap memory, using

// normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
// normalize-stderr-test: "\| +\^+" -> "| ^"
// normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();"
//@normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
//@normalize-stderr-test: "\| +\^+" -> "| ^"
//@normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();"

#![feature(allocator_api, slice_ptr_get)]

Expand Down
Loading

0 comments on commit 7a6a812

Please sign in to comment.