From 0648f03133a899269a86cdd204d45582871bbb61 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 6 Jun 2022 18:34:41 -0400 Subject: [PATCH 1/4] ensure all worker threads stay around --- ui_test/src/lib.rs | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index 7f9eb48e05f..8b7b4783fab 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -1,3 +1,4 @@ +use std::collections::VecDeque; use std::fmt::Write; use std::path::{Path, PathBuf}; use std::process::{Command, ExitStatus}; @@ -6,7 +7,6 @@ use colored::*; use comments::ErrorMatch; -use crossbeam::queue::SegQueue; use regex::Regex; use rustc_stderr::{Level, Message}; @@ -55,9 +55,8 @@ pub fn run_tests(config: Config) { // Get the triple with which to run the tests let target = config.target.clone().unwrap_or_else(|| config.get_host()); - // A queue for files or folders to process - let todo = SegQueue::new(); - todo.push(config.root_dir.clone()); + // A channel for files to process + let (submit, receive) = crossbeam::channel::unbounded(); // Some statistics and failure reports. let failures = Mutex::new(vec![]); @@ -66,20 +65,31 @@ pub fn run_tests(config: Config) { let filtered = AtomicUsize::default(); crossbeam::scope(|s| { + // Create a thread that is in charge of walking the directory and submitting jobs. + // It closes the channel when it is done. + s.spawn(|_| { + let mut todo = VecDeque::new(); + todo.push_back(config.root_dir.clone()); + while let Some(path) = todo.pop_front() { + if path.is_dir() { + // Enqueue everything inside this directory. + for entry in std::fs::read_dir(path).unwrap() { + todo.push_back(entry.unwrap().path()); + } + } else if path.extension().map(|ext| ext == "rs").unwrap_or(false) { + // Forward .rs files to the test workers. + submit.send(path).unwrap(); + } + } + // There will be no more jobs. This signals the workers to quit. + // (This also ensures `submit` is moved into this closure.) + drop(submit); + }); + + // Create N worker threads that receive files to test. for _ in 0..std::thread::available_parallelism().unwrap().get() { s.spawn(|_| { - while let Some(path) = todo.pop() { - // Collect everything inside directories - if path.is_dir() { - for entry in std::fs::read_dir(path).unwrap() { - todo.push(entry.unwrap().path()); - } - continue; - } - // Only look at .rs files - if !path.extension().map(|ext| ext == "rs").unwrap_or(false) { - continue; - } + for path in &receive { if !config.path_filter.is_empty() { let path_display = path.display().to_string(); if !config.path_filter.iter().any(|filter| path_display.contains(filter)) { From a2cc014231537d913cc51984a6ec11090d62e787 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 6 Jun 2022 18:53:19 -0400 Subject: [PATCH 2/4] test files in a deterministic order --- ui_test/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index 8b7b4783fab..d6938b19bfe 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -73,8 +73,12 @@ pub fn run_tests(config: Config) { while let Some(path) = todo.pop_front() { if path.is_dir() { // Enqueue everything inside this directory. - for entry in std::fs::read_dir(path).unwrap() { - todo.push_back(entry.unwrap().path()); + // We want it sorted, to have some control over scheduling of slow tests. + let mut entries = + std::fs::read_dir(path).unwrap().collect::, _>>().unwrap(); + entries.sort_by_key(|e| e.file_name()); + for entry in entries { + todo.push_back(entry.path()); } } else if path.extension().map(|ext| ext == "rs").unwrap_or(false) { // Forward .rs files to the test workers. From 8ebdad06158f33accee028c2937f95a8a0fca29a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 6 Jun 2022 18:53:33 -0400 Subject: [PATCH 3/4] organize more files into folders, and run the weak-mem consistency test as the very first since it is so slow --- .../{weak_memory/consistency.rs => 0weak_memory_consistency.rs} | 2 +- tests/pass/{ => backtrace}/backtrace-api-v0.rs | 0 tests/pass/{ => backtrace}/backtrace-api-v0.stderr | 0 tests/pass/{ => backtrace}/backtrace-api-v0.stdout | 0 tests/pass/{ => backtrace}/backtrace-api-v1.rs | 0 tests/pass/{ => backtrace}/backtrace-api-v1.stderr | 0 tests/pass/{ => backtrace}/backtrace-api-v1.stdout | 0 tests/pass/{ => backtrace}/backtrace-global-alloc.rs | 0 tests/pass/{ => backtrace}/backtrace-global-alloc.stderr | 0 tests/pass/{ => backtrace}/backtrace-std.rs | 0 tests/pass/{ => backtrace}/backtrace-std.stderr | 0 tests/pass/{ => issues}/issue-15063.rs | 0 tests/pass/{ => issues}/issue-15080.rs | 0 tests/pass/{ => issues}/issue-15523-big.rs | 0 tests/pass/{ => issues}/issue-17877.rs | 0 tests/pass/{ => issues}/issue-20575.rs | 0 tests/pass/{ => issues}/issue-23261.rs | 0 tests/pass/{ => issues}/issue-26709.rs | 0 tests/pass/{ => issues}/issue-27901.rs | 0 tests/pass/{ => issues}/issue-29746.rs | 0 tests/pass/{ => issues}/issue-30530.rs | 0 tests/pass/{ => issues}/issue-31267-additional.rs | 0 tests/pass/{ => issues}/issue-33387.rs | 0 tests/pass/{ => issues}/issue-34571.rs | 0 tests/pass/{ => issues}/issue-35815.rs | 0 tests/pass/{ => issues}/issue-36278-prefix-nesting.rs | 0 tests/pass/{ => issues}/issue-3794.rs | 0 tests/pass/{ => issues}/issue-3794.stdout | 0 tests/pass/{ => issues}/issue-53728.rs | 0 tests/pass/{ => issues}/issue-5917.rs | 0 tests/pass/{ => issues}/issue-73223.rs | 0 tests/pass/{ => issues}/issue-91636.rs | 0 tests/pass/{ => issues}/issue-94371.rs | 0 tests/pass/{ => issues}/issue-miri-1075.rs | 0 tests/pass/{ => issues}/issue-miri-133.rs | 0 tests/pass/{ => issues}/issue-miri-184.rs | 0 tests/pass/{ => issues}/issue-miri-1925.rs | 0 tests/pass/{ => issues}/issue-miri-2068-2.rs | 0 tests/pass/{ => issues}/issue-miri-2068.rs | 0 39 files changed, 1 insertion(+), 1 deletion(-) rename tests/pass/{weak_memory/consistency.rs => 0weak_memory_consistency.rs} (99%) rename tests/pass/{ => backtrace}/backtrace-api-v0.rs (100%) rename tests/pass/{ => backtrace}/backtrace-api-v0.stderr (100%) rename tests/pass/{ => backtrace}/backtrace-api-v0.stdout (100%) rename tests/pass/{ => backtrace}/backtrace-api-v1.rs (100%) rename tests/pass/{ => backtrace}/backtrace-api-v1.stderr (100%) rename tests/pass/{ => backtrace}/backtrace-api-v1.stdout (100%) rename tests/pass/{ => backtrace}/backtrace-global-alloc.rs (100%) rename tests/pass/{ => backtrace}/backtrace-global-alloc.stderr (100%) rename tests/pass/{ => backtrace}/backtrace-std.rs (100%) rename tests/pass/{ => backtrace}/backtrace-std.stderr (100%) rename tests/pass/{ => issues}/issue-15063.rs (100%) rename tests/pass/{ => issues}/issue-15080.rs (100%) rename tests/pass/{ => issues}/issue-15523-big.rs (100%) rename tests/pass/{ => issues}/issue-17877.rs (100%) rename tests/pass/{ => issues}/issue-20575.rs (100%) rename tests/pass/{ => issues}/issue-23261.rs (100%) rename tests/pass/{ => issues}/issue-26709.rs (100%) rename tests/pass/{ => issues}/issue-27901.rs (100%) rename tests/pass/{ => issues}/issue-29746.rs (100%) rename tests/pass/{ => issues}/issue-30530.rs (100%) rename tests/pass/{ => issues}/issue-31267-additional.rs (100%) rename tests/pass/{ => issues}/issue-33387.rs (100%) rename tests/pass/{ => issues}/issue-34571.rs (100%) rename tests/pass/{ => issues}/issue-35815.rs (100%) rename tests/pass/{ => issues}/issue-36278-prefix-nesting.rs (100%) rename tests/pass/{ => issues}/issue-3794.rs (100%) rename tests/pass/{ => issues}/issue-3794.stdout (100%) rename tests/pass/{ => issues}/issue-53728.rs (100%) rename tests/pass/{ => issues}/issue-5917.rs (100%) rename tests/pass/{ => issues}/issue-73223.rs (100%) rename tests/pass/{ => issues}/issue-91636.rs (100%) rename tests/pass/{ => issues}/issue-94371.rs (100%) rename tests/pass/{ => issues}/issue-miri-1075.rs (100%) rename tests/pass/{ => issues}/issue-miri-133.rs (100%) rename tests/pass/{ => issues}/issue-miri-184.rs (100%) rename tests/pass/{ => issues}/issue-miri-1925.rs (100%) rename tests/pass/{ => issues}/issue-miri-2068-2.rs (100%) rename tests/pass/{ => issues}/issue-miri-2068.rs (100%) diff --git a/tests/pass/weak_memory/consistency.rs b/tests/pass/0weak_memory_consistency.rs similarity index 99% rename from tests/pass/weak_memory/consistency.rs rename to tests/pass/0weak_memory_consistency.rs index 8a7c1340cc5..fc9dce0c986 100644 --- a/tests/pass/weak_memory/consistency.rs +++ b/tests/pass/0weak_memory_consistency.rs @@ -214,7 +214,7 @@ fn test_single_thread() { } pub fn main() { - for _ in 0..100 { + for _ in 0..50 { test_single_thread(); test_mixed_access(); test_load_buffering_acq_rel(); diff --git a/tests/pass/backtrace-api-v0.rs b/tests/pass/backtrace/backtrace-api-v0.rs similarity index 100% rename from tests/pass/backtrace-api-v0.rs rename to tests/pass/backtrace/backtrace-api-v0.rs diff --git a/tests/pass/backtrace-api-v0.stderr b/tests/pass/backtrace/backtrace-api-v0.stderr similarity index 100% rename from tests/pass/backtrace-api-v0.stderr rename to tests/pass/backtrace/backtrace-api-v0.stderr diff --git a/tests/pass/backtrace-api-v0.stdout b/tests/pass/backtrace/backtrace-api-v0.stdout similarity index 100% rename from tests/pass/backtrace-api-v0.stdout rename to tests/pass/backtrace/backtrace-api-v0.stdout diff --git a/tests/pass/backtrace-api-v1.rs b/tests/pass/backtrace/backtrace-api-v1.rs similarity index 100% rename from tests/pass/backtrace-api-v1.rs rename to tests/pass/backtrace/backtrace-api-v1.rs diff --git a/tests/pass/backtrace-api-v1.stderr b/tests/pass/backtrace/backtrace-api-v1.stderr similarity index 100% rename from tests/pass/backtrace-api-v1.stderr rename to tests/pass/backtrace/backtrace-api-v1.stderr diff --git a/tests/pass/backtrace-api-v1.stdout b/tests/pass/backtrace/backtrace-api-v1.stdout similarity index 100% rename from tests/pass/backtrace-api-v1.stdout rename to tests/pass/backtrace/backtrace-api-v1.stdout diff --git a/tests/pass/backtrace-global-alloc.rs b/tests/pass/backtrace/backtrace-global-alloc.rs similarity index 100% rename from tests/pass/backtrace-global-alloc.rs rename to tests/pass/backtrace/backtrace-global-alloc.rs diff --git a/tests/pass/backtrace-global-alloc.stderr b/tests/pass/backtrace/backtrace-global-alloc.stderr similarity index 100% rename from tests/pass/backtrace-global-alloc.stderr rename to tests/pass/backtrace/backtrace-global-alloc.stderr diff --git a/tests/pass/backtrace-std.rs b/tests/pass/backtrace/backtrace-std.rs similarity index 100% rename from tests/pass/backtrace-std.rs rename to tests/pass/backtrace/backtrace-std.rs diff --git a/tests/pass/backtrace-std.stderr b/tests/pass/backtrace/backtrace-std.stderr similarity index 100% rename from tests/pass/backtrace-std.stderr rename to tests/pass/backtrace/backtrace-std.stderr diff --git a/tests/pass/issue-15063.rs b/tests/pass/issues/issue-15063.rs similarity index 100% rename from tests/pass/issue-15063.rs rename to tests/pass/issues/issue-15063.rs diff --git a/tests/pass/issue-15080.rs b/tests/pass/issues/issue-15080.rs similarity index 100% rename from tests/pass/issue-15080.rs rename to tests/pass/issues/issue-15080.rs diff --git a/tests/pass/issue-15523-big.rs b/tests/pass/issues/issue-15523-big.rs similarity index 100% rename from tests/pass/issue-15523-big.rs rename to tests/pass/issues/issue-15523-big.rs diff --git a/tests/pass/issue-17877.rs b/tests/pass/issues/issue-17877.rs similarity index 100% rename from tests/pass/issue-17877.rs rename to tests/pass/issues/issue-17877.rs diff --git a/tests/pass/issue-20575.rs b/tests/pass/issues/issue-20575.rs similarity index 100% rename from tests/pass/issue-20575.rs rename to tests/pass/issues/issue-20575.rs diff --git a/tests/pass/issue-23261.rs b/tests/pass/issues/issue-23261.rs similarity index 100% rename from tests/pass/issue-23261.rs rename to tests/pass/issues/issue-23261.rs diff --git a/tests/pass/issue-26709.rs b/tests/pass/issues/issue-26709.rs similarity index 100% rename from tests/pass/issue-26709.rs rename to tests/pass/issues/issue-26709.rs diff --git a/tests/pass/issue-27901.rs b/tests/pass/issues/issue-27901.rs similarity index 100% rename from tests/pass/issue-27901.rs rename to tests/pass/issues/issue-27901.rs diff --git a/tests/pass/issue-29746.rs b/tests/pass/issues/issue-29746.rs similarity index 100% rename from tests/pass/issue-29746.rs rename to tests/pass/issues/issue-29746.rs diff --git a/tests/pass/issue-30530.rs b/tests/pass/issues/issue-30530.rs similarity index 100% rename from tests/pass/issue-30530.rs rename to tests/pass/issues/issue-30530.rs diff --git a/tests/pass/issue-31267-additional.rs b/tests/pass/issues/issue-31267-additional.rs similarity index 100% rename from tests/pass/issue-31267-additional.rs rename to tests/pass/issues/issue-31267-additional.rs diff --git a/tests/pass/issue-33387.rs b/tests/pass/issues/issue-33387.rs similarity index 100% rename from tests/pass/issue-33387.rs rename to tests/pass/issues/issue-33387.rs diff --git a/tests/pass/issue-34571.rs b/tests/pass/issues/issue-34571.rs similarity index 100% rename from tests/pass/issue-34571.rs rename to tests/pass/issues/issue-34571.rs diff --git a/tests/pass/issue-35815.rs b/tests/pass/issues/issue-35815.rs similarity index 100% rename from tests/pass/issue-35815.rs rename to tests/pass/issues/issue-35815.rs diff --git a/tests/pass/issue-36278-prefix-nesting.rs b/tests/pass/issues/issue-36278-prefix-nesting.rs similarity index 100% rename from tests/pass/issue-36278-prefix-nesting.rs rename to tests/pass/issues/issue-36278-prefix-nesting.rs diff --git a/tests/pass/issue-3794.rs b/tests/pass/issues/issue-3794.rs similarity index 100% rename from tests/pass/issue-3794.rs rename to tests/pass/issues/issue-3794.rs diff --git a/tests/pass/issue-3794.stdout b/tests/pass/issues/issue-3794.stdout similarity index 100% rename from tests/pass/issue-3794.stdout rename to tests/pass/issues/issue-3794.stdout diff --git a/tests/pass/issue-53728.rs b/tests/pass/issues/issue-53728.rs similarity index 100% rename from tests/pass/issue-53728.rs rename to tests/pass/issues/issue-53728.rs diff --git a/tests/pass/issue-5917.rs b/tests/pass/issues/issue-5917.rs similarity index 100% rename from tests/pass/issue-5917.rs rename to tests/pass/issues/issue-5917.rs diff --git a/tests/pass/issue-73223.rs b/tests/pass/issues/issue-73223.rs similarity index 100% rename from tests/pass/issue-73223.rs rename to tests/pass/issues/issue-73223.rs diff --git a/tests/pass/issue-91636.rs b/tests/pass/issues/issue-91636.rs similarity index 100% rename from tests/pass/issue-91636.rs rename to tests/pass/issues/issue-91636.rs diff --git a/tests/pass/issue-94371.rs b/tests/pass/issues/issue-94371.rs similarity index 100% rename from tests/pass/issue-94371.rs rename to tests/pass/issues/issue-94371.rs diff --git a/tests/pass/issue-miri-1075.rs b/tests/pass/issues/issue-miri-1075.rs similarity index 100% rename from tests/pass/issue-miri-1075.rs rename to tests/pass/issues/issue-miri-1075.rs diff --git a/tests/pass/issue-miri-133.rs b/tests/pass/issues/issue-miri-133.rs similarity index 100% rename from tests/pass/issue-miri-133.rs rename to tests/pass/issues/issue-miri-133.rs diff --git a/tests/pass/issue-miri-184.rs b/tests/pass/issues/issue-miri-184.rs similarity index 100% rename from tests/pass/issue-miri-184.rs rename to tests/pass/issues/issue-miri-184.rs diff --git a/tests/pass/issue-miri-1925.rs b/tests/pass/issues/issue-miri-1925.rs similarity index 100% rename from tests/pass/issue-miri-1925.rs rename to tests/pass/issues/issue-miri-1925.rs diff --git a/tests/pass/issue-miri-2068-2.rs b/tests/pass/issues/issue-miri-2068-2.rs similarity index 100% rename from tests/pass/issue-miri-2068-2.rs rename to tests/pass/issues/issue-miri-2068-2.rs diff --git a/tests/pass/issue-miri-2068.rs b/tests/pass/issues/issue-miri-2068.rs similarity index 100% rename from tests/pass/issue-miri-2068.rs rename to tests/pass/issues/issue-miri-2068.rs From c16c45362ccb854ab9438a5db5ad6152dc7fd519 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 13 Jun 2022 15:20:01 +0200 Subject: [PATCH 4/4] Document file sorting --- ui_test/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui_test/README.md b/ui_test/README.md index b3c9a3378cf..07a0a67b914 100644 --- a/ui_test/README.md +++ b/ui_test/README.md @@ -1,5 +1,10 @@ A smaller version of compiletest-rs +## Magic behavior + +* Tests are run in order of their filenames (files first, then recursing into folders). + So if you have any slow tests, prepend them with a small integral number to make them get run first, taking advantage of parallelism as much as possible (instead of waiting for the slow tests at the end). + ## Supported magic comment annotations Note that the space after `//`, when it is present, is *not* optional -- it must be exactly one.