Skip to content

test_override_env failing during make check #17617

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

Closed
wizeman opened this issue Sep 29, 2014 · 2 comments · Fixed by #17667
Closed

test_override_env failing during make check #17617

wizeman opened this issue Sep 29, 2014 · 2 comments · Fixed by #17667
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@wizeman
Copy link
Contributor

wizeman commented Sep 29, 2014

Using commit 7fbbfe6 I am experiencing this failure during make check:

metrics saved to: tmp/check-stage2-T-x86_64-unknown-linux-gnu-H-x86_64-unknown-linux-gnu-std-metrics.json
failures:

---- io::process::tests::test_override_env::green stdout ----
    task 'io::process::tests::test_override_env::green' failed at 'called `Result::unwrap()` on an `Err` value: no such file or directory (no such file or directory)', /tmp/nix-build-rustc-0.12.0-pre-7fbbfe6bf.drv-0/git-export/src/libcore/result.rs:808


---- io::process::tests::test_override_env::native stdout ----
    task 'io::process::tests::test_override_env::native' failed at 'receiving on a closed channel', /tmp/nix-build-rustc-0.12.0-pre-7fbbfe6bf.drv-0/git-export/src/libsync/comm/mod.rs:837



failures:
    io::process::tests::test_override_env::green
    io::process::tests::test_override_env::native

test result: FAILED. 833 passed; 2 failed; 63 ignored; 0 measured

task '<main>' failed at 'Some tests failed', /tmp/nix-build-rustc-0.12.0-pre-7fbbfe6bf.drv-0/git-export/src/libtest/lib.rs:243
make: *** [tmp/check-stage2-T-x86_64-unknown-linux-gnu-H-x86_64-unknown-linux-gnu-std.ok] Error 101

Initially I thought it was because my OS (NixOS) did not install env in /usr/bin (in fact, /usr doesn't even exist, but env is in the PATH), but even then, that does not explain why other env tests succeed (such as test_add_to_env, which is almost exactly the same code as test_override_env).

However, if I copy/paste the code from the test into a new program and run it, it seems to work fine.

Furthermore, this exact make check failure seems to be repeatable, even after updating to a newer commit and compiling everything from scratch.

This seems quite mysterious to me... any ideas as to what the problem might be?

@wizeman
Copy link
Contributor Author

wizeman commented Sep 29, 2014

Ah, I just discovered what the problem is.

test_override_env, like the name alludes to, spawns an env subprocess, but before that (and unlike other tests) it completely deletes all environment variables (except that it adds a new one, just for testing). This means that $PATH will be empty.

The subprocess is executed using execvp(), and its man page says:

The (...) execvp() (... function ...) duplicates the actions of the shell in searching for an executable file if the specified filename does not contain a slash (/) character. The file is sought in the colon-separated list of directory pathnames specified in the PATH environment variable.

_If this variable isn't defined, the path list defaults to the current directory followed by the list of directories returned by confstr(CS_PATH). (This confstr(3) call typically returns the value "/bin:/usr/bin".)

Since env is not in /bin nor /usr/bin in my system, the test fails.

@kmcallister kmcallister added A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Sep 29, 2014
@wizeman
Copy link
Contributor Author

wizeman commented Sep 30, 2014

I have a fix for this, will submit soon.

wizeman added a commit to wizeman/rust that referenced this issue Sep 30, 2014
In some operating systems (such as NixOS), `env` can only be found in
the explicitly-provided PATH, not in default places such as /bin or
/usr/bin. So we need to pass-through PATH when spawning the `env`
sub-process.

Fixes rust-lang#17617
wizeman added a commit to wizeman/rust that referenced this issue Oct 1, 2014
In some build environments (such as Nix builds), `env` can only be found
in the explicitly-provided PATH, not in default places such as /bin or
/usr/bin. So we need to pass-through PATH when spawning the `env`
sub-process.

Fixes rust-lang#17617
wizeman added a commit to wizeman/rust that referenced this issue Oct 1, 2014
In some build environments (such as chrooted Nix builds), `env` can only
be found in the explicitly-provided PATH, not in default places such as
/bin or /usr/bin. So we need to pass-through PATH when spawning the
`env` sub-process.

Fixes rust-lang#17617
bors added a commit that referenced this issue Oct 1, 2014
In some build environments (such as chrooted Nix builds), `env` can only
be found in the explicitly-provided PATH, not in default places such as
/bin or /usr/bin. So we need to pass-through PATH when spawning the
`env` sub-process.

Fixes #17617
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 28, 2024
Derive kinds information from ungrammar file

This reduces the need to touch more files when adding a new grammar rule
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 1, 2024
Derive kinds information from ungrammar file

This reduces the need to touch more files when adding a new grammar rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants