Skip to content
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

Run test suite on NixOS #7778

Closed
wants to merge 4 commits into from
Closed

Conversation

roberth
Copy link
Member

@roberth roberth commented Feb 7, 2023

Motivation

This one was a rabbit hole.

TODO

Context

Testing is how we make sure that we

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or bug fix: updated release notes

Comment on lines +296 to +302
src = lib.cleanSourceWith {
src = ./.;
filter = path: type:
toString path != toString ./tests/nixos
&& toString path != toString ./flake.nix
;
};
Copy link
Member Author

Choose a reason for hiding this comment

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

This change will be removed.
An improved change can be made after

Ideally the filter is additive - not subtractive - as subtractive filter don't scale well to projects with multiple derivation, which is increasingly the case for NixOS/nix.

Comment on lines +1451 to +1458
if (evalSettings.pureEval) {
// TODO feature flag?
// state.debugThrowLastTrace(EvalError({
// .msg = hintfmt("'%s' is not allowed in pure evaluation mode", "builtins.storePath"),
// .errPos = state.positions[pos]
// }));'
state.allowPath(uncheckedPath);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll look for a workaround, as I know this is controversial. builtins.storePath is referentially transparent, and only undesirable for some. If I can find an alternative for this change, I'll use that instead.

@@ -1,5 +1,8 @@
source common.sh

enableFeatures nix-command
Copy link
Member Author

Choose a reason for hiding this comment

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

I've had to add a lot of these enableFeatures, as I could not find the supposed central place where they should be enabled. Doing it on a case by case basis made more sense to me, but if the in-build tests don't enforce these calls that's going to be annoying. The in-build tests should cover almost everything, so that the VM tests are almost guarnateed to succeed after that.

@@ -1,5 +1,8 @@
source common.sh

enableFeatures nix-command
unknownFailsOnNixOS # fails because of path may have been built and not gc-ed; generate unique derivation?
Copy link
Member Author

Choose a reason for hiding this comment

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

We'll want to resolve some of these later, so that we don't have to block this PR for too long.

isTestOnSystemNix() {
[[ "${TEST_SYSTEM_NIX:-}" = 1 ]]
}

Copy link
Member Author

Choose a reason for hiding this comment

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

These functions should be made a bit more accurate, and "integrate" better with the existing helper functions, which should also be made a bit more accurate or precise.

Comment on lines +54 to +65
# Tests we don't need
echo >tests/plugins/local.mk
sed -i tests/local.mk \
-e 's^plugins\.sh^^' \
-e "s^test-deps += tests/plugins/libplugintest.\$(SO_EXT)^^" \
;

export TEST_SYSTEM_NIX=1
export version=${config.nix.package.version}
export NIX_REMOTE_=daemon
export NIX_REMOTE=daemon
make -j1 tests/eval-store.sh.test installcheck --keep-going
Copy link
Member Author

Choose a reason for hiding this comment

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

These adaptation should be in an entrypoint that can be run outside of the VM tests. Benefits

  • Quicker iteration on reproducers and improvements in test coverage that don't require main code changes
  • Easier troubleshooting of test suite issues

@roberth roberth changed the title Runs test suite on NixOS, work towards fixing issue #6736 Run test suite on NixOS, work towards fixing issue #6736 Feb 7, 2023
Comment on lines +18 to +26
nix.package = (builtins.getFlake "git+file:///home/user/h/nix?rev=a1c7cb8fb6c6511daf4884e140aba8ae1788cd84").packages.x86_64-linux.default;
nix.settings.substituters = lib.mkForce [];

nixpkgs.overlays = [
(final: prev: {
thisNix = prev.nix;
nix = config.nix.package;
})
];
Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose of the nix.package and overlay hacks here is to not rebuild the nix derivation every time the test suite is changed during local development. This hack should be moved to a convenience attribute and not run on CI. It should use HEAD instead of a specific hash.
Alternatively, we could have a mode that adds an impurely built (devshell) nix into the store somehow, or we could build Nix in such a way that it does not depend on its test suite.

@roberth roberth added bug with-tests Issues related to testing. PRs with tests have some priority labels Feb 20, 2023
@roberth roberth mentioned this pull request Mar 21, 2023
7 tasks
@roberth roberth mentioned this pull request Apr 10, 2023
8 tasks
@roberth
Copy link
Member Author

roberth commented Apr 10, 2023

Will re-do with fewer changes (and probably less coverage at first)

@roberth roberth closed this Apr 10, 2023
@roberth roberth reopened this Oct 13, 2023
@github-actions github-actions bot removed the with-tests Issues related to testing. PRs with tests have some priority label Oct 13, 2023
@fricklerhandwerk fricklerhandwerk changed the title Run test suite on NixOS, work towards fixing issue #6736 Run test suite on NixOS Jun 12, 2024
@roberth
Copy link
Member Author

roberth commented Jun 16, 2024

@roberth roberth closed this Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

structuredAttrs $NIX_ATTRS_JSON_FILE points to the wrong location in sandbox
3 participants