Skip to content

Commit 272c44f

Browse files
wizemanFuuzetsu
authored andcommitted
rustcMaster: Fix test_override_env and enable tests
We also need to disable parallel building due to rust-lang/rust#16305. Closes NixOS#4339
1 parent 516be15 commit 272c44f

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

pkgs/development/compilers/rustc/head.nix

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper}:
1+
{ stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper
2+
, tzdata, git
3+
}:
24

35
assert stdenv.gcc.gcc != null;
46

@@ -63,14 +65,19 @@ in stdenv.mkDerivation {
6365
configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ];
6466

6567
# The compiler requires cc, so we patch the source to tell it where to find it
66-
patches = [ ./hardcode_paths.HEAD.patch ./local_stage0.HEAD.patch ];
68+
patches = [ ./hardcode_paths.HEAD.patch ./local_stage0.HEAD.patch ./override_env.HEAD.patch ];
6769
postPatch = ''
6870
substituteInPlace src/librustc/back/link.rs \
6971
--subst-var-by "ccPath" "${stdenv.gcc}/bin/cc"
7072
substituteInPlace src/librustc_back/archive.rs \
7173
--subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar"
7274
'';
7375

74-
buildInputs = [ which file perl curl python27 makeWrapper ];
75-
enableParallelBuilding = true;
76+
buildInputs = [ which file perl curl python27 makeWrapper git ];
77+
78+
enableParallelBuilding = false; # disabled due to rust-lang/rust#16305
79+
80+
preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
81+
82+
doCheck = true;
7683
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
commit 02f4c61bd6a2aedbf56169aff5b3a65c83c89557
2+
Author: Ricardo M. Correia <[email protected]>
3+
Date: Tue Sep 30 15:57:06 2014 +0200
4+
5+
libstd: Pass-through PATH in test_override_env test
6+
7+
In some operating systems (such as NixOS), `env` can only be found in
8+
the explicitly-provided PATH, not in default places such as /bin or
9+
/usr/bin. So we need to pass-through PATH when spawning the `env`
10+
sub-process.
11+
12+
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
13+
index 83890d2..8fbf254 100644
14+
--- a/src/libstd/io/process.rs
15+
+++ b/src/libstd/io/process.rs
16+
@@ -956,7 +956,22 @@ mod tests {
17+
})
18+
19+
iotest!(fn test_override_env() {
20+
- let new_env = vec![("RUN_TEST_NEW_ENV", "123")];
21+
+ use os;
22+
+ let mut new_env = vec![("RUN_TEST_NEW_ENV", "123")];
23+
+
24+
+ // In some operating systems (such as NixOS), `env` can only be found in
25+
+ // the explicitly-provided PATH env variable, not in default places
26+
+ // such as /bin or /usr/bin. So we need to pass through PATH to our
27+
+ // sub-process.
28+
+ let path_val: String;
29+
+ match os::getenv("PATH") {
30+
+ None => {}
31+
+ Some(val) => {
32+
+ path_val = val;
33+
+ new_env.push(("PATH", path_val.as_slice()))
34+
+ }
35+
+ }
36+
+
37+
let prog = env_cmd().env_set_all(new_env.as_slice()).spawn().unwrap();
38+
let result = prog.wait_with_output().unwrap();
39+
let output = String::from_utf8_lossy(result.output.as_slice()).into_string();

0 commit comments

Comments
 (0)