-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Migrate libs-through-symlinks
and translation
run-make tests to rmake
#129011
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// The rust compiler searches by default for libraries in its current directory, | ||
// but used to have difficulty following symlinks leading to required libraries | ||
// if the real ones were located elsewhere. After this was fixed in #13903, this test | ||
// checks that compilation succeeds through use of the symlink. | ||
// See https://github.com/rust-lang/rust/issues/13890 | ||
|
||
//@ needs-symlink | ||
|
||
use run_make_support::{cwd, path, rfs, rust_lib_name, rustc}; | ||
|
||
fn main() { | ||
rfs::create_dir("outdir"); | ||
rustc().input("foo.rs").output(path("outdir").join(rust_lib_name("foo"))).run(); | ||
rfs::create_symlink(path("outdir").join(rust_lib_name("foo")), rust_lib_name("foo")); | ||
// RUSTC_LOG is used for debugging and is not crucial to the test. | ||
rustc().env("RUSTC_LOG", "rustc_metadata::loader").input("bar.rs").run(); | ||
Oneirical marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file was deleted.
jieyouxu marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Various tests on Fluent bundles, useful to change the compiler's language | ||
// to the one requested by the user. Check each comment header to learn the purpose | ||
// of each test case. | ||
// See https://github.com/rust-lang/rust/pull/95512 | ||
|
||
//@ needs-symlink | ||
|
||
use run_make_support::{path, rfs, rustc}; | ||
|
||
fn main() { | ||
builtin_fallback_bundle(); | ||
custom_bundle(); | ||
interpolated_variable_missing(); | ||
desired_message_missing(); | ||
custom_locale_from_sysroot(); | ||
no_locale_in_sysroot(); | ||
locale_in_sysroot_is_invalid(); | ||
} | ||
|
||
fn builtin_fallback_bundle() { | ||
// Check that the test works normally, using the built-in fallback bundle. | ||
rustc().input("test.rs").run_fail().assert_stderr_contains("struct literal body without path"); | ||
jieyouxu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
fn custom_bundle() { | ||
// Check that a primary bundle can be loaded and will be preferentially used | ||
// where possible. | ||
rustc() | ||
.env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1") | ||
.arg("-Ztranslate-additional-ftl=working.ftl") | ||
.input("test.rs") | ||
.run_fail() | ||
.assert_stderr_contains("this is a test message"); | ||
} | ||
|
||
fn interpolated_variable_missing() { | ||
// Check that a primary bundle with a broken message (e.g. a interpolated | ||
// variable is missing) will use the fallback bundle. | ||
rustc() | ||
.env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1") | ||
.arg("-Ztranslate-additional-ftl=missing.ftl") | ||
.input("test.rs") | ||
.run_fail() | ||
.assert_stderr_contains("struct literal body without path"); | ||
} | ||
|
||
fn desired_message_missing() { | ||
// Check that a primary bundle without the desired message will use the fallback | ||
// bundle. | ||
rustc() | ||
.env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1") | ||
.arg("-Ztranslate-additional-ftl=broken.ftl") | ||
.input("test.rs") | ||
.run_fail() | ||
.assert_stderr_contains("struct literal body without path"); | ||
} | ||
|
||
fn custom_locale_from_sysroot() { | ||
// Check that a locale can be loaded from the sysroot given a language | ||
// identifier by making a local copy of the sysroot and adding the custom locale | ||
// to it. | ||
let sysroot = | ||
rustc().env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1").print("sysroot").run().stdout_utf8(); | ||
let sysroot = sysroot.trim(); | ||
rfs::create_dir("fakeroot"); | ||
symlink_all_entries(&sysroot, "fakeroot"); | ||
rfs::remove_file("fakeroot/lib"); | ||
rfs::create_dir("fakeroot/lib"); | ||
symlink_all_entries(path(&sysroot).join("lib"), "fakeroot/lib"); | ||
rfs::remove_file("fakeroot/lib/rustlib"); | ||
rfs::create_dir("fakeroot/lib/rustlib"); | ||
symlink_all_entries(path(&sysroot).join("lib/rustlib"), "fakeroot/lib/rustlib"); | ||
rfs::remove_file("fakeroot/lib/rustlib/src"); | ||
rfs::create_dir("fakeroot/lib/rustlib/src"); | ||
symlink_all_entries(path(&sysroot).join("lib/rustlib/src"), "fakeroot/lib/rustlib/src"); | ||
// When download-rustc is enabled, `sysroot` will have a share directory. Delete the link to it. | ||
if path("fakeroot/share").exists() { | ||
rfs::remove_file("fakeroot/share"); | ||
} | ||
rfs::create_dir_all("fakeroot/share/locale/zh-CN"); | ||
rfs::create_symlink("working.ftl", "fakeroot/share/locale/zh-CN/basic-translation.ftl"); | ||
rustc() | ||
.env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1") | ||
.arg("-Ztranslate-lang=zh-CN") | ||
.input("test.rs") | ||
.sysroot("fakeroot") | ||
.run_fail() | ||
.assert_stderr_contains("this is a test message"); | ||
} | ||
|
||
fn no_locale_in_sysroot() { | ||
// Check that the compiler errors out when the sysroot requested cannot be | ||
// found. This test might start failing if there actually exists a Klingon | ||
// translation of rustc's error messages. | ||
rustc() | ||
.env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1") | ||
.arg("-Ztranslate-lang=tlh") | ||
// .input("test.rs") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remark: commented out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Original test: sysroot-missing:
$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | $(CGREP) "missing locale directory" Note how the ususal |
||
.run_fail() | ||
.assert_stderr_contains("missing locale directory"); | ||
} | ||
|
||
fn locale_in_sysroot_is_invalid() { | ||
// Check that the compiler errors out when the directory for the locale in the | ||
// sysroot is actually a file. | ||
rfs::remove_dir_all("fakeroot/share/locale/zh-CN"); | ||
rfs::create_file("fakeroot/share/locale/zh-CN"); | ||
rustc() | ||
.env("RUSTC_TRANSLATION_NO_DEBUG_ASSERT", "1") | ||
.arg("-Ztranslate-lang=zh-CN") | ||
.input("test.rs") | ||
.sysroot("fakeroot") | ||
.run_fail() | ||
.assert_stderr_contains("`$sysroot/share/locales/$locale` is not a directory"); | ||
} | ||
|
||
fn symlink_all_entries<P: AsRef<std::path::Path>>(dir: P, fakepath: &str) { | ||
for found_path in rfs::shallow_find_dir_entries(dir) { | ||
rfs::create_symlink(&found_path, path(fakepath).join(found_path.file_name().unwrap())); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.