Skip to content

Commit

Permalink
Update regex and implement necessary AArch64 vendor intrinsics
Browse files Browse the repository at this point in the history
Upstream has removed the shootout-regex-dna example.
  • Loading branch information
bjorn3 committed Sep 21, 2023
1 parent 2b30bcc commit c3fc9a4
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 265 deletions.
48 changes: 10 additions & 38 deletions build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::path::{Dirs, RelPath};
use crate::prepare::{apply_patches, GitRepo};
use crate::rustc_info::get_default_sysroot;
use crate::shared_utils::rustflags_from_env;
use crate::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler, LogGroup};
use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup};
use crate::{CodegenBackend, SysrootKind};

static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
Expand Down Expand Up @@ -114,8 +114,8 @@ pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir()
pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"rust-lang",
"regex",
"32fed9429eafba0ae92a64b01796a0c5a75b88c8",
"fcc4df7c5b902633",
"061ee815ef2c44101dba7b0b124600fcb03c1912",
"dc26aefbeeac03ca",
"regex",
);

Expand Down Expand Up @@ -178,40 +178,6 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
spawn_and_wait(build_cmd);
}
}),
TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
REGEX_REPO.patch(&runner.dirs);

REGEX.clean(&runner.dirs);

let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
build_cmd.arg("--example").arg("shootout-regex-dna");
spawn_and_wait(build_cmd);

if runner.is_native {
let mut run_cmd = REGEX.run(&runner.target_compiler, &runner.dirs);
run_cmd.arg("--example").arg("shootout-regex-dna");

let input = fs::read_to_string(
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-input.txt"),
)
.unwrap();
let expected = fs::read_to_string(
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-output.txt"),
)
.unwrap();

let output = spawn_and_wait_with_input(run_cmd, input);

let output_matches = expected.lines().eq(output.lines());
if !output_matches {
println!("Output files don't match!");
println!("Expected Output:\n{}", expected);
println!("Actual Output:\n{}", output);

std::process::exit(1);
}
}
}),
TestCase::custom("test.regex", &|runner| {
REGEX_REPO.patch(&runner.dirs);

Expand All @@ -221,7 +187,13 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
// regex-capi and regex-debug don't have any tests. Nor do they contain any code
// that is useful to test with cg_clif. Skip building them to reduce test time.
run_cmd.args(["-p", "regex", "-p", "regex-syntax", "--", "-q"]);
run_cmd.args(["-p", "regex", "-p", "regex-syntax", "--release", "--all-targets", "--", "-q"]);
spawn_and_wait(run_cmd);

let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
// don't run integration tests for regex-autonata. they take like 2min each without
// much extra coverage of simd usage.
run_cmd.args(["-p", "regex-automata", "--release", "--lib", "--", "-q"]);
spawn_and_wait(run_cmd);
} else {
eprintln!("Cross-Compiling: Not running tests");
Expand Down
26 changes: 2 additions & 24 deletions build_system/utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::env;
use std::fs;
use std::io::{self, Write};
use std::io;
use std::path::{Path, PathBuf};
use std::process::{self, Command, Stdio};
use std::process::{self, Command};
use std::sync::atomic::{AtomicBool, Ordering};

use crate::path::{Dirs, RelPath};
Expand Down Expand Up @@ -220,28 +220,6 @@ pub(crate) fn retry_spawn_and_wait(tries: u64, mut cmd: Command) {
process::exit(1);
}

#[track_caller]
pub(crate) fn spawn_and_wait_with_input(mut cmd: Command, input: String) -> String {
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.expect("Failed to spawn child process");

let mut stdin = child.stdin.take().expect("Failed to open stdin");
std::thread::spawn(move || {
stdin.write_all(input.as_bytes()).expect("Failed to write to stdin");
});

let output = child.wait_with_output().expect("Failed to read stdout");
if !output.status.success() {
eprintln!("{cmd:?} exited with status {:?}", output.status);
process::exit(1);
}

String::from_utf8(output.stdout).unwrap()
}

pub(crate) fn remove_dir_if_exists(path: &Path) {
match fs::remove_dir_all(&path) {
Ok(()) => {}
Expand Down
1 change: 0 additions & 1 deletion config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ aot.issue-59326
testsuite.extended_sysroot
test.rust-random/rand
test.libcore
test.regex-shootout-regex-dna
test.regex
test.portable-simd
Loading

0 comments on commit c3fc9a4

Please sign in to comment.