-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Migrate inaccessible-temp-dir
, output-with-hyphens
and issue-10971-temps-dir
run-make
tests to rmake
#126279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bors
merged 4 commits into
rust-lang:master
from
Oneirical:you-can-run-make-but-cannot-hide
Jun 18, 2024
Merged
Migrate inaccessible-temp-dir
, output-with-hyphens
and issue-10971-temps-dir
run-make
tests to rmake
#126279
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d226890
rewrite and rename issue-10971-temps-dir to rmake format
Oneirical 03982da
rewrite inaccessible-temp-dir to rmake format
Oneirical 7c2b3b5
rewrite output-with-hyphens to rmake format
Oneirical 03f19d6
Add new test_while_readonly helper function to run-make-support
Oneirical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Issue #66530: We would ICE if someone compiled with `-o /dev/null`, | ||
// because we would try to generate auxiliary files in `/dev/` (which | ||
// at least the OS X file system rejects). | ||
// | ||
// An attempt to `-Ztemps-dir` into a directory we cannot write into should | ||
// indeed be an error; but not an ICE. | ||
// | ||
// However, some folks run tests as root, which can write `/dev/` and end | ||
// up clobbering `/dev/null`. Instead we'll use an inaccessible path, which | ||
// also used to ICE, but even root can't magically write there. | ||
// | ||
// Note that `-Ztemps-dir` uses `create_dir_all` so it is not sufficient to | ||
// use a directory with non-existing parent like `/does-not-exist/output`. | ||
// See https://github.com/rust-lang/rust/issues/66530 | ||
|
||
//@ ignore-arm | ||
// Reason: linker error on `armhf-gnu` | ||
//@ ignore-windows | ||
// Reason: `set_readonly` has no effect on directories | ||
// and does not prevent modification. | ||
|
||
use run_make_support::{fs_wrapper, rustc, test_while_readonly}; | ||
|
||
fn main() { | ||
// Create an inaccessible directory. | ||
fs_wrapper::create_dir("inaccessible"); | ||
test_while_readonly("inaccessible", || { | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one, | ||
// so that it can't create `tmp`. | ||
rustc() | ||
.input("program.rs") | ||
.arg("-Ztemps-dir=inaccessible/tmp") | ||
.run_fail() | ||
.assert_stderr_contains( | ||
"failed to find or create the directory specified by `--temps-dir`", | ||
); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Rust files with hyphens in their filename should | ||
// not result in compiled libraries keeping that hyphen - | ||
// it should become an underscore. Only bin executables | ||
// should keep the hyphen. This test ensures that this rule | ||
// remains enforced. | ||
// See https://github.com/rust-lang/rust/pull/23786 | ||
|
||
//@ ignore-cross-compile | ||
|
||
use run_make_support::{bin_name, path, rust_lib_name, rustc}; | ||
|
||
fn main() { | ||
rustc().input("foo-bar.rs").crate_type("bin").run(); | ||
assert!(path(bin_name("foo-bar")).exists()); | ||
rustc().input("foo-bar.rs").crate_type("lib").run(); | ||
assert!(path(rust_lib_name("foo_bar")).exists()); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// When two instances of rustc are invoked in parallel, they | ||
// can conflict on their temporary files and overwrite each others', | ||
// leading to unsuccessful compilation. The -Z temps-dir flag adds | ||
// separate designated directories for each rustc invocation, preventing | ||
// conflicts. This test uses this flag and checks for successful compilation. | ||
// See https://github.com/rust-lang/rust/pull/83846 | ||
|
||
use run_make_support::{fs_wrapper, rustc}; | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use std::sync::{Arc, Barrier}; | ||
use std::thread; | ||
|
||
fn main() { | ||
fs_wrapper::create_file("lib.rs"); | ||
let barrier = Arc::new(Barrier::new(2)); | ||
let handle = { | ||
let barrier = Arc::clone(&barrier); | ||
thread::spawn(move || { | ||
barrier.wait(); | ||
rustc().crate_type("lib").arg("-Ztemps-dir=temp1").input("lib.rs").run(); | ||
}) | ||
}; | ||
barrier.wait(); | ||
rustc().crate_type("staticlib").arg("-Ztemps-dir=temp2").input("lib.rs").run(); | ||
handle.join().expect("lib thread panicked"); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.