Skip to content

Commit 3e27b56

Browse files
committed
Localize compile_test_and_save_assembly to assembly test module
1 parent 937fc66 commit 3e27b56

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

src/tools/compiletest/src/runtest.rs

-36
Original file line numberDiff line numberDiff line change
@@ -1846,42 +1846,6 @@ impl<'test> TestCx<'test> {
18461846
(proc_res, output_path)
18471847
}
18481848

1849-
fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) {
1850-
let output_file = self.get_output_file("s");
1851-
let input_file = &self.testpaths.file;
1852-
1853-
let mut emit = Emit::None;
1854-
match self.props.assembly_output.as_ref().map(AsRef::as_ref) {
1855-
Some("emit-asm") => {
1856-
emit = Emit::Asm;
1857-
}
1858-
1859-
Some("bpf-linker") => {
1860-
emit = Emit::LinkArgsAsm;
1861-
}
1862-
1863-
Some("ptx-linker") => {
1864-
// No extra flags needed.
1865-
}
1866-
1867-
Some(header) => self.fatal(&format!("unknown 'assembly-output' header: {header}")),
1868-
None => self.fatal("missing 'assembly-output' header"),
1869-
}
1870-
1871-
let rustc = self.make_compile_args(
1872-
input_file,
1873-
output_file,
1874-
emit,
1875-
AllowUnused::No,
1876-
LinkToAux::Yes,
1877-
Vec::new(),
1878-
);
1879-
1880-
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
1881-
let output_path = self.get_filecheck_file("s");
1882-
(proc_res, output_path)
1883-
}
1884-
18851849
fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
18861850
let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap());
18871851
filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file);

src/tools/compiletest/src/runtest/assembly.rs

+39-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use super::TestCx;
1+
use std::path::PathBuf;
2+
3+
use super::{AllowUnused, Emit, LinkToAux, ProcRes, TestCx};
24

35
impl TestCx<'_> {
46
pub(super) fn run_assembly_test(&self) {
@@ -16,4 +18,40 @@ impl TestCx<'_> {
1618
self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res);
1719
}
1820
}
21+
22+
fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) {
23+
let output_file = self.get_output_file("s");
24+
let input_file = &self.testpaths.file;
25+
26+
let mut emit = Emit::None;
27+
match self.props.assembly_output.as_ref().map(AsRef::as_ref) {
28+
Some("emit-asm") => {
29+
emit = Emit::Asm;
30+
}
31+
32+
Some("bpf-linker") => {
33+
emit = Emit::LinkArgsAsm;
34+
}
35+
36+
Some("ptx-linker") => {
37+
// No extra flags needed.
38+
}
39+
40+
Some(header) => self.fatal(&format!("unknown 'assembly-output' header: {header}")),
41+
None => self.fatal("missing 'assembly-output' header"),
42+
}
43+
44+
let rustc = self.make_compile_args(
45+
input_file,
46+
output_file,
47+
emit,
48+
AllowUnused::No,
49+
LinkToAux::Yes,
50+
Vec::new(),
51+
);
52+
53+
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
54+
let output_path = self.get_filecheck_file("s");
55+
(proc_res, output_path)
56+
}
1957
}

0 commit comments

Comments
 (0)