Skip to content

Commit

Permalink
Use path instead of Path in some run-make tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Aug 28, 2024
1 parent 4ca4779 commit bb4c81a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 55 deletions.
6 changes: 2 additions & 4 deletions tests/run-make/dos-device-input/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
//@ only-windows
// Reason: dos devices are a Windows thing

use std::path::Path;

use run_make_support::{rustc, static_lib_name};
use run_make_support::{path, rustc, static_lib_name};

fn main() {
rustc().input(r"\\.\NUL").crate_type("staticlib").run();
rustc().input(r"\\?\NUL").crate_type("staticlib").run();

assert!(Path::new(&static_lib_name("rust_out")).exists());
assert!(path(&static_lib_name("rust_out")).exists());
}
42 changes: 20 additions & 22 deletions tests/run-make/emit-shared-files/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
// `all-shared` should only emit files that can be shared between crates.
// See https://github.com/rust-lang/rust/pull/83478

use std::path::Path;

use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files};
use run_make_support::{has_extension, has_prefix, path, rustdoc, shallow_find_files};

fn main() {
rustdoc()
Expand All @@ -19,17 +17,17 @@ fn main() {
.args(&["--extend-css", "z.css"])
.input("x.rs")
.run();
assert!(Path::new("invocation-only/search-index-xxx.js").exists());
assert!(Path::new("invocation-only/settings.html").exists());
assert!(Path::new("invocation-only/x/all.html").exists());
assert!(Path::new("invocation-only/x/index.html").exists());
assert!(Path::new("invocation-only/theme-xxx.css").exists()); // generated from z.css
assert!(!Path::new("invocation-only/storage-xxx.js").exists());
assert!(!Path::new("invocation-only/SourceSerif4-It.ttf.woff2").exists());
assert!(path("invocation-only/search-index-xxx.js").exists());
assert!(path("invocation-only/settings.html").exists());
assert!(path("invocation-only/x/all.html").exists());
assert!(path("invocation-only/x/index.html").exists());
assert!(path("invocation-only/theme-xxx.css").exists()); // generated from z.css
assert!(!path("invocation-only/storage-xxx.js").exists());
assert!(!path("invocation-only/SourceSerif4-It.ttf.woff2").exists());
// FIXME: this probably shouldn't have a suffix
assert!(Path::new("invocation-only/y-xxx.css").exists());
assert!(path("invocation-only/y-xxx.css").exists());
// FIXME: this is technically incorrect (see `write_shared`)
assert!(!Path::new("invocation-only/main-xxx.js").exists());
assert!(!path("invocation-only/main-xxx.js").exists());

rustdoc()
.arg("-Zunstable-options")
Expand Down Expand Up @@ -60,10 +58,10 @@ fn main() {
.len(),
1
);
assert!(!Path::new("toolchain-only/search-index-xxx.js").exists());
assert!(!Path::new("toolchain-only/x/index.html").exists());
assert!(!Path::new("toolchain-only/theme.css").exists());
assert!(!Path::new("toolchain-only/y-xxx.css").exists());
assert!(!path("toolchain-only/search-index-xxx.js").exists());
assert!(!path("toolchain-only/x/index.html").exists());
assert!(!path("toolchain-only/theme.css").exists());
assert!(!path("toolchain-only/y-xxx.css").exists());

rustdoc()
.arg("-Zunstable-options")
Expand All @@ -87,17 +85,17 @@ fn main() {
.len(),
1
);
assert!(!Path::new("all-shared/search-index-xxx.js").exists());
assert!(!Path::new("all-shared/settings.html").exists());
assert!(!Path::new("all-shared/x").exists());
assert!(!Path::new("all-shared/src").exists());
assert!(!Path::new("all-shared/theme.css").exists());
assert!(!path("all-shared/search-index-xxx.js").exists());
assert!(!path("all-shared/settings.html").exists());
assert!(!path("all-shared/x").exists());
assert!(!path("all-shared/src").exists());
assert!(!path("all-shared/theme.css").exists());
assert_eq!(
shallow_find_files("all-shared/static.files", |path| {
has_prefix(path, "main-") && has_extension(path, "js")
})
.len(),
1
);
assert!(!Path::new("all-shared/y-xxx.css").exists());
assert!(!path("all-shared/y-xxx.css").exists());
}
6 changes: 2 additions & 4 deletions tests/run-make/manual-crate-name/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::path::Path;

use run_make_support::rustc;
use run_make_support::{path, rustc};

fn main() {
rustc().input("bar.rs").crate_name("foo").run();
assert!(Path::new("libfoo.rlib").is_file());
assert!(path("libfoo.rlib").is_file());
}
6 changes: 2 additions & 4 deletions tests/run-make/pretty-print-with-dep-file/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
// does not get an unexpected dep-info file.
// See https://github.com/rust-lang/rust/issues/112898

use std::path::Path;

use run_make_support::{invalid_utf8_contains, rfs, rustc};
use run_make_support::{invalid_utf8_contains, path, rfs, rustc};

fn main() {
rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run();
invalid_utf8_contains("with-dep.d", "with-dep.rs");
rfs::remove_file("with-dep.d");
rustc().emit("dep-info").arg("-Zunpretty=normal").input("with-dep.rs").run();
assert!(!Path::new("with-dep.d").exists());
assert!(!path("with-dep.d").exists());
}
10 changes: 4 additions & 6 deletions tests/run-make/profile/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
//@ ignore-cross-compile
//@ needs-profiler-support

use std::path::Path;

use run_make_support::{run, rustc};
use run_make_support::{path, run, rustc};

fn main() {
rustc().arg("-g").arg("-Zprofile").input("test.rs").run();
run("test");
assert!(Path::new("test.gcno").exists(), "no .gcno file");
assert!(Path::new("test.gcda").exists(), "no .gcda file");
assert!(path("test.gcno").exists(), "no .gcno file");
assert!(path("test.gcda").exists(), "no .gcda file");
rustc().arg("-g").arg("-Zprofile").arg("-Zprofile-emit=abc/abc.gcda").input("test.rs").run();
run("test");
assert!(Path::new("abc/abc.gcda").exists(), "gcda file not emitted to defined path");
assert!(path("abc/abc.gcda").exists(), "gcda file not emitted to defined path");
}
10 changes: 4 additions & 6 deletions tests/run-make/reset-codegen-1/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

//@ ignore-cross-compile

use std::path::Path;

use run_make_support::{bin_name, rustc};
use run_make_support::{bin_name, path, rustc};

fn compile(output_file: &str, emit: Option<&str>) {
let mut rustc = rustc();
Expand All @@ -34,10 +32,10 @@ fn main() {
// In the None case, bin_name is required for successful Windows compilation.
let output_file = &bin_name(output_file);
compile(output_file, emit);
assert!(Path::new(output_file).is_file());
assert!(path(output_file).is_file());
}

compile("multi-output", Some("asm,obj"));
assert!(Path::new("multi-output.s").is_file());
assert!(Path::new("multi-output.o").is_file());
assert!(path("multi-output.s").is_file());
assert!(path("multi-output.o").is_file());
}
8 changes: 3 additions & 5 deletions tests/run-make/rustdoc-determinism/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Assert that the search index is generated deterministically, regardless of the
// order that crates are documented in.

use std::path::Path;

use run_make_support::{diff, rustdoc};
use run_make_support::{diff, path, rustdoc};

fn main() {
let foo_first = Path::new("foo_first");
let foo_first = path("foo_first");
rustdoc().input("foo.rs").out_dir(&foo_first).run();
rustdoc().input("bar.rs").out_dir(&foo_first).run();

let bar_first = Path::new("bar_first");
let bar_first = path("bar_first");
rustdoc().input("bar.rs").out_dir(&bar_first).run();
rustdoc().input("foo.rs").out_dir(&bar_first).run();

Expand Down
5 changes: 1 addition & 4 deletions tests/run-make/rustdoc-output-path/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Checks that if the output folder doesn't exist, rustdoc will create it.

use std::path::Path;

use run_make_support::rustdoc;

fn main() {
let out_dir = Path::new("foo/bar/doc");
rustdoc().input("foo.rs").out_dir(&out_dir).run();
rustdoc().input("foo.rs").out_dir("foo/bar/doc").run();
assert!(out_dir.exists());
}

0 comments on commit bb4c81a

Please sign in to comment.