Skip to content

More robust comment parsing #2332

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 17 commits into from
Jul 8, 2022
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
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