diff options
| author | bors <bors@rust-lang.org> | 2024-04-30 18:45:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-30 18:45:56 +0000 |
| commit | 4f8187962001c167238eadb9e568b331ef4c636a (patch) | |
| tree | 3f8bc54394bc67a636e0b17dc67a8975a0305ff2 /src | |
| parent | 20aa2d81e36036073a9acf418c7d413cb4b22fa6 (diff) | |
| parent | 7350a7fa4fd797f6f08bbfedad124341b5535749 (diff) | |
| download | rust-4f8187962001c167238eadb9e568b331ef4c636a.tar.gz rust-4f8187962001c167238eadb9e568b331ef4c636a.zip | |
Auto merge of #124564 - jieyouxu:rollup-kuf5wlq, r=jieyouxu
Rollup of 4 pull requests
Successful merges:
- #124280 (Port repr128-dwarf run-make test to rmake)
- #124299 (Add test for issue 106269)
- #124553 (Write `git-commit-{sha,info}` for Cargo in source tarballs)
- #124561 (Add `normalize()` in run-make `Diff` type)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/dist.rs | 17 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/diff/mod.rs | 28 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/diff/tests.rs | 22 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 |
7 files changed, 62 insertions, 9 deletions
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 770a5cdb232..5bc9d7615e2 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -25,7 +25,7 @@ use crate::core::build_steps::llvm; use crate::core::build_steps::tool::{self, Tool}; use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; -use crate::utils::channel; +use crate::utils::channel::{self, Info}; use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit}; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; @@ -991,10 +991,17 @@ impl Step for PlainSourceTarball { // Create the version file builder.create(&plain_dst_src.join("version"), &builder.rust_version()); - if let Some(info) = builder.rust_info().info() { - channel::write_commit_hash_file(plain_dst_src, &info.sha); - channel::write_commit_info_file(plain_dst_src, info); - } + + // Create the files containing git info, to ensure --version outputs the same. + let write_git_info = |info: Option<&Info>, path: &Path| { + if let Some(info) = info { + t!(std::fs::create_dir_all(path)); + channel::write_commit_hash_file(path, &info.sha); + channel::write_commit_info_file(path, info); + } + }; + write_git_info(builder.rust_info().info(), plain_dst_src); + write_git_info(builder.cargo_info.info(), &plain_dst_src.join("./src/tools/cargo")); // If we're building from git or tarball sources, we need to vendor // a complete distribution. diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index da51b33a9d6..0a861d62c37 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3825,6 +3825,7 @@ impl<'test> TestCx<'test> { .arg(format!("-Ldependency={}", &support_lib_deps_deps.to_string_lossy())) .arg("--extern") .arg(format!("run_make_support={}", &support_lib_path.to_string_lossy())) + .arg("--edition=2021") .arg(&self.testpaths.file.join("rmake.rs")) .env("TARGET", &self.config.target) .env("PYTHON", &self.config.python) diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 61a24c97e77..cf4ae4b16cd 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -8,3 +8,4 @@ object = "0.34.0" similar = "2.5.0" wasmparser = "0.118.2" regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace +gimli = "0.28.1" diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs index 54532c6e35b..332126939c0 100644 --- a/src/tools/run-make-support/src/diff/mod.rs +++ b/src/tools/run-make-support/src/diff/mod.rs @@ -1,3 +1,4 @@ +use regex::Regex; use similar::TextDiff; use std::path::Path; @@ -14,12 +15,19 @@ pub struct Diff { expected_name: Option<String>, actual: Option<String>, actual_name: Option<String>, + normalizers: Vec<(String, String)>, } impl Diff { /// Construct a bare `diff` invocation. pub fn new() -> Self { - Self { expected: None, expected_name: None, actual: None, actual_name: None } + Self { + expected: None, + expected_name: None, + actual: None, + actual_name: None, + normalizers: Vec::new(), + } } /// Specify the expected output for the diff from a file. @@ -58,15 +66,29 @@ impl Diff { self } + /// Specify a regex that should replace text in the "actual" text that will be compared. + pub fn normalize<R: Into<String>, I: Into<String>>( + &mut self, + regex: R, + replacement: I, + ) -> &mut Self { + self.normalizers.push((regex.into(), replacement.into())); + self + } + /// Executes the diff process, prints any differences to the standard error. #[track_caller] pub fn run(&self) { let expected = self.expected.as_ref().expect("expected text not set"); - let actual = self.actual.as_ref().expect("actual text not set"); + let mut actual = self.actual.as_ref().expect("actual text not set").to_string(); let expected_name = self.expected_name.as_ref().unwrap(); let actual_name = self.actual_name.as_ref().unwrap(); + for (regex, replacement) in &self.normalizers { + let re = Regex::new(regex).expect("bad regex in custom normalization rule"); + actual = re.replace_all(&actual, replacement).into_owned(); + } - let output = TextDiff::from_lines(expected, actual) + let output = TextDiff::from_lines(expected, &actual) .unified_diff() .header(expected_name, actual_name) .to_string(); diff --git a/src/tools/run-make-support/src/diff/tests.rs b/src/tools/run-make-support/src/diff/tests.rs index e6d72544b7e..286548bef61 100644 --- a/src/tools/run-make-support/src/diff/tests.rs +++ b/src/tools/run-make-support/src/diff/tests.rs @@ -36,4 +36,26 @@ test failed: `EXPECTED_TEXT` is different from `ACTUAL_TEXT` assert_eq!(output.downcast_ref::<String>().unwrap(), expected_output); } + + #[test] + fn test_normalize() { + let expected = " +running 2 tests +.. + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +"; + let actual = " +running 2 tests +.. + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s +"; + + diff() + .expected_text("EXPECTED_TEXT", expected) + .actual_text("ACTUAL_TEXT", actual) + .normalize(r#"finished in \d+\.\d+s"#, "finished in $$TIME") + .run(); + } } diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 76e8838d27c..a874c1313b5 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -15,6 +15,7 @@ use std::env; use std::path::{Path, PathBuf}; use std::process::{Command, Output}; +pub use gimli; pub use object; pub use regex; pub use wasmparser; diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index a2179b895b3..69c6dda4b19 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -235,7 +235,6 @@ run-make/relocation-model/Makefile run-make/relro-levels/Makefile run-make/remap-path-prefix-dwarf/Makefile run-make/remap-path-prefix/Makefile -run-make/repr128-dwarf/Makefile run-make/reproducible-build-2/Makefile run-make/reproducible-build/Makefile run-make/resolve-rename/Makefile |
