Skip to content

Commit 49d4c6b

Browse files
committed
tests/run-make: update for symlink helper changes
1 parent 264072b commit 49d4c6b

File tree

4 files changed

+93
-26
lines changed

4 files changed

+93
-26
lines changed

tests/run-make/invalid-symlink-search-path/rmake.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// In this test, the symlink created is invalid (valid relative to the root, but not
2-
// relatively to where it is located), and used to cause an internal
3-
// compiler error (ICE) when passed as a library search path. This was fixed in #26044,
4-
// and this test checks that the invalid symlink is instead simply ignored.
1+
// In this test, the symlink created is invalid (valid relative to the root, but not relatively to
2+
// where it is located), and used to cause an internal compiler error (ICE) when passed as a library
3+
// search path. This was fixed in #26044, and this test checks that the invalid symlink is instead
4+
// simply ignored.
5+
//
56
// See https://github.com/rust-lang/rust/issues/26006
67

78
//@ needs-symlink
@@ -22,7 +23,22 @@ fn main() {
2223
.run();
2324
rfs::create_dir("out/bar");
2425
rfs::create_dir("out/bar/deps");
25-
rfs::create_symlink("out/foo/libfoo.rlib", "out/bar/deps/libfoo.rlib");
26+
#[cfg(unix)]
27+
{
28+
rfs::unix::symlink("out/foo/libfoo.rlib", "out/bar/deps/libfoo.rlib");
29+
}
30+
#[cfg(windows)]
31+
{
32+
rfs::windows::symlink_file("out/foo/libfoo.rlib", "out/bar/deps/libfoo.rlib");
33+
}
34+
#[cfg(not(any(unix, windows)))]
35+
{
36+
// FIXME(jieyouxu): this is not supported, but we really should implement a only-* directive
37+
// that accepts multiple targets, like e.g. `//@ only-target-families: unix, windows`. That
38+
// way, it properly shows up as an ignored test instead of silently passing.
39+
return;
40+
}
41+
2642
// Check that the invalid symlink does not cause an ICE
2743
rustc()
2844
.input("in/bar/lib.rs")
+29-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// Crates that are resolved normally have their path canonicalized and all
2-
// symlinks resolved. This did not happen for paths specified
3-
// using the --extern option to rustc, which could lead to rustc thinking
4-
// that it encountered two different versions of a crate, when it's
5-
// actually the same version found through different paths.
6-
// See https://github.com/rust-lang/rust/pull/16505
7-
8-
// This test checks that --extern and symlinks together
9-
// can result in successful compilation.
1+
// Crates that are resolved normally have their path canonicalized and all symlinks resolved. This
2+
// did not happen for paths specified using the `--extern` option to rustc, which could lead to
3+
// rustc thinking that it encountered two different versions of a crate, when it's actually the same
4+
// version found through different paths.
5+
//
6+
// This test checks that `--extern` and symlinks together can result in successful compilation.
7+
//
8+
// See <https://github.com/rust-lang/rust/pull/16505>.
109

1110
//@ ignore-cross-compile
1211
//@ needs-symlink
@@ -16,7 +15,26 @@ use run_make_support::{cwd, rfs, rustc};
1615
fn main() {
1716
rustc().input("foo.rs").run();
1817
rfs::create_dir_all("other");
19-
rfs::create_symlink("libfoo.rlib", "other");
18+
#[cfg(unix)]
19+
{
20+
rfs::unix::symlink(cwd().join("libfoo.rlib"), cwd().join("other").join("libfoo.rlib"));
21+
}
22+
#[cfg(windows)]
23+
{
24+
rfs::windows::symlink_file(
25+
cwd().join("libfoo.rlib"),
26+
cwd().join("other").join("libfoo.rlib"),
27+
);
28+
}
29+
#[cfg(not(any(unix, windows)))]
30+
{
31+
// FIXME(jieyouxu): this is not supported, but we really should implement a only-* directive
32+
// that accepts multiple targets, like e.g. `//@ only-target-families: unix, windows`. That
33+
// way, it properly shows up as an ignored test instead of silently passing.
34+
return;
35+
}
36+
2037
rustc().input("bar.rs").library_search_path(cwd()).run();
21-
rustc().input("baz.rs").extern_("foo", "other").library_search_path(cwd()).run();
38+
39+
rustc().input("baz.rs").extern_("foo", "other/libfoo.rlib").library_search_path(cwd()).run();
2240
}
+28-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1-
// When a directory and a symlink simultaneously exist with the same name,
2-
// setting that name as the library search path should not cause rustc
3-
// to avoid looking in the symlink and cause an error. This test creates
4-
// a directory and a symlink named "other", and places the library in the symlink.
5-
// If it succeeds, the library was successfully found.
6-
// See https://github.com/rust-lang/rust/issues/12459
1+
// Avoid erroring on symlinks pointing to the same file that are present in the library search path.
2+
//
3+
// See <https://github.com/rust-lang/rust/issues/12459>.
74

85
//@ ignore-cross-compile
96
//@ needs-symlink
107

11-
use run_make_support::{dynamic_lib_name, rfs, rustc};
8+
use run_make_support::{cwd, dynamic_lib_name, rfs, rustc};
129

1310
fn main() {
1411
rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
1512
rfs::create_dir_all("other");
16-
rfs::create_symlink(dynamic_lib_name("foo"), "other");
17-
rustc().input("bar.rs").library_search_path("other").run();
13+
14+
#[cfg(unix)]
15+
{
16+
rfs::unix::symlink(
17+
cwd().join(dynamic_lib_name("foo")),
18+
cwd().join("other").join(dynamic_lib_name("foo")),
19+
);
20+
}
21+
#[cfg(windows)]
22+
{
23+
rfs::windows::symlink_file(
24+
cwd().join(dynamic_lib_name("foo")),
25+
cwd().join("other").join(dynamic_lib_name("foo")),
26+
);
27+
}
28+
#[cfg(not(any(unix, windows)))]
29+
{
30+
// FIXME(jieyouxu): this is not supported, but we really should implement a only-* directive
31+
// that accepts multiple targets, like e.g. `//@ only-target-families: unix, windows`. That
32+
// way, it properly shows up as an ignored test instead of silently passing.
33+
return;
34+
}
35+
36+
rustc().input("bar.rs").library_search_path(cwd()).library_search_path("other").run();
1837
}

tests/run-make/symlinked-rlib/rmake.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ use run_make_support::{cwd, rfs, rustc};
1212

1313
fn main() {
1414
rustc().input("foo.rs").crate_type("rlib").output("foo.xxx").run();
15-
rfs::create_symlink("foo.xxx", "libfoo.rlib");
15+
#[cfg(unix)]
16+
{
17+
rfs::unix::symlink("foo.xxx", "libfoo.rlib");
18+
}
19+
#[cfg(windows)]
20+
{
21+
rfs::windows::symlink_file("foo.xxx", "libfoo.rlib");
22+
}
23+
#[cfg(not(any(unix, windows)))]
24+
{
25+
// FIXME(jieyouxu): this is not supported, but we really should implement a only-* directive
26+
// that accepts multiple targets, like e.g. `//@ only-target-families: unix, windows`. That
27+
// way, it properly shows up as an ignored test instead of silently passing.
28+
return;
29+
}
1630
rustc().input("bar.rs").library_search_path(cwd()).run();
1731
}

0 commit comments

Comments
 (0)