Skip to content

expect-failure.sh: fix variabl existence check#355953

Closed
teto wants to merge 1 commit intoNixOS:masterfrom
teto:teto/fix-expect-failure
Closed

expect-failure.sh: fix variabl existence check#355953
teto wants to merge 1 commit intoNixOS:masterfrom
teto:teto/fix-expect-failure

Conversation

@teto
Copy link
Member

@teto teto commented Nov 14, 2024

Trying to use pkgs.testers.testBuildFailure on the neovim wrapper I got:

testBuildFailure: Original builder produced exit code: 1
/nix/store/ms79njxnpys354nc5n9v27qh4i5g1gjj-expect-failure.sh: line 37: __structuredAttrs: unbound variable

-v seems a safer choice ?

this will be ready when I can uncomment #352727

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Trying to use pkgs.testers.testBuildFailure on the neovim wrapper I got:

> testBuildFailure: Original builder produced exit code: 1
> /nix/store/ms79njxnpys354nc5n9v27qh4i5g1gjj-expect-failure.sh: line 37: __structuredAttrs: unbound variable

-v seems a safer choice ?
@github-actions github-actions bot added the 6.topic: testing Tooling for automated testing of packages and modules label Nov 14, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Nov 15, 2024
Comment on lines 38 to 43
# # from stdenv setup.sh
getAllOutputNames() {
if [ -n "$__structuredAttrs" ]; then
if [ -v "__structuredAttrs" ]; then
echo "${!outputs[*]}"
else
echo "$outputs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, as the comment says this is copied as-is from pkgs/stdenv/generic/setup.sh. Why is it a problem here, but not there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or put differently: Will this ever work? I.e. will $__structuredAttrs be set here at all, even in the case when it's enabled?

Copy link
Contributor

@MattSturgeon MattSturgeon Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd that defining __structuredAttrs is what causes it to be unbound in the buildscript... Implying it is bound when not defined.

I agree it doesn't look like this PR fixes the underlying issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #371337

@MattSturgeon
Copy link
Contributor

I just ran into this issue myself, I'm surprised it hasn't come up sooner.

Here's a minimal reproducible example:

{
  nixpkgs ? <nixpkgs>,
  system ? builtins.currentSystem,
  pkgs ? import nixpkgs { inherit system; },
}:
pkgs.testers.testBuildFailure (
  pkgs.runCommandLocal "example" { __structuredAttrs = true; } ''
    exit 1
  ''
)
$ nix-build test.nix

these 2 derivations will be built:
  /nix/store/ws92j8crllvn2rqvcm5ivk4lf9hwgq7n-expect-failure.sh.drv
  /nix/store/z6kan4jnriiizyzcimr6x5xkg4f5s0l4-example.drv

building '/nix/store/ws92j8crllvn2rqvcm5ivk4lf9hwgq7n-expect-failure.sh.drv'...
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
Running phase: checkPhase
Running phase: installPhase
no Makefile or custom installPhase, doing nothing
Running phase: fixupPhase
shrinking RPATHs of ELF executables and libraries in /nix/store/h003mggvqn1hjc3lm8k2i7pn7awqkpsz-expect-failure.sh
checking for references to /build/ in /nix/store/h003mggvqn1hjc3lm8k2i7pn7awqkpsz-expect-failure.sh...
patching script interpreter paths in /nix/store/h003mggvqn1hjc3lm8k2i7pn7awqkpsz-expect-failure.sh
building '/nix/store/z6kan4jnriiizyzcimr6x5xkg4f5s0l4-example.drv'...
testBuildFailure: Expecting non-zero exit from builder and args: '/nix/store/5mh7kaj2fyv8mk4sfq1brwxgc02884wi-bash-5.2p37/bin/bash' '-e' '/nix/store/v6x3cs394jgqfbi0a42pam708flxaphh-default-builder.sh'
original builder: structuredAttrs is enabled
testBuildFailure: Original builder produced exit code: 1
/nix/store/h003mggvqn1hjc3lm8k2i7pn7awqkpsz-expect-failure.sh: line 37: __structuredAttrs: unbound variable

error: builder for '/nix/store/z6kan4jnriiizyzcimr6x5xkg4f5s0l4-example.drv' failed with exit code 1;
       last 4 log lines:
       > testBuildFailure: Expecting non-zero exit from builder and args: '/nix/store/5mh7kaj2fyv8mk4sfq1brwxgc02884wi-bash-5.2p37/bin/bash' '-e' '/nix/store/v6x3cs394jgqfbi0a42pam708flxaphh-default-builder.sh'
       > original builder: structuredAttrs is enabled
       > testBuildFailure: Original builder produced exit code: 1
       > /nix/store/h003mggvqn1hjc3lm8k2i7pn7awqkpsz-expect-failure.sh: line 37: __structuredAttrs: unbound variable
       For full logs, run 'nix log /nix/store/z6kan4jnriiizyzcimr6x5xkg4f5s0l4-example.drv'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: testing Tooling for automated testing of packages and modules 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants