-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
nixos/testing-python: Avoid infinite recursion in node definitions #144110
Draft
talyz
wants to merge
1
commit into
NixOS:master
Choose a base branch
from
talyz:testing-python-infinite-recursion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,6 @@ rec { | |
|
||
# Generate convenience wrappers for running the test driver | ||
# has vlans, vms and test script defaulted through env variables | ||
# also instantiates test script with nodes, if it's a function (contract) | ||
setupDriverForTest = { | ||
testScript | ||
, testName | ||
|
@@ -143,12 +142,6 @@ rec { | |
(node: builtins.match "^[A-z_]([A-z0-9_]+)?$" node == null) | ||
nodeHostNames; | ||
|
||
testScript' = | ||
# Call the test script with the computed nodes. | ||
if lib.isFunction testScript | ||
then testScript { inherit nodes; } | ||
else testScript; | ||
|
||
in | ||
if lib.length invalidNodeNames > 0 then | ||
throw '' | ||
|
@@ -161,9 +154,8 @@ rec { | |
'' | ||
else lib.warnIf skipLint "Linting is disabled" (runCommand testDriverName | ||
{ | ||
inherit testName; | ||
inherit testName testScript; | ||
nativeBuildInputs = [ makeWrapper ]; | ||
testScript = testScript'; | ||
preferLocalBuild = true; | ||
passthru = passthru // { | ||
inherit nodes; | ||
|
@@ -207,14 +199,16 @@ rec { | |
, ... | ||
} @ t: | ||
let | ||
nodes = qemu_pkg: | ||
let | ||
testScript' = | ||
# Call the test script with the computed nodes. | ||
if lib.isFunction testScript | ||
then testScript { nodes = nodes qemu_pkg; } | ||
else testScript; | ||
# Instantiates test script with nodes, if it's a function (contract) | ||
mkTestScript = qemu_pkg: | ||
# Call the test script with the computed nodes. | ||
if lib.isFunction testScript | ||
then testScript { nodes = nodes qemu_pkg false; } | ||
else testScript; | ||
|
||
nodes = qemu_pkg: addAdditionalPaths: | ||
let | ||
testScript' = mkTestScript qemu_pkg; | ||
build-vms = import ./build-vms.nix { | ||
inherit system lib pkgs minimal specialArgs; | ||
extraConfigurations = extraConfigurations ++ [( | ||
|
@@ -231,17 +225,9 @@ rec { | |
# copied to the image. | ||
virtualisation.additionalPaths = | ||
lib.optional | ||
# A testScript may evaluate nodes, which has caused | ||
# infinite recursions. The demand cycle involves: | ||
# testScript --> | ||
# nodes --> | ||
# toplevel --> | ||
# additionalPaths --> | ||
# hasContext testScript' --> | ||
# testScript (ad infinitum) | ||
# If we don't need to build an image, we can break this | ||
# cycle by short-circuiting when useNixStoreImage is false. | ||
(config.virtualisation.useNixStoreImage && builtins.hasContext testScript') | ||
(config.virtualisation.useNixStoreImage | ||
&& addAdditionalPaths | ||
&& builtins.hasContext testScript') | ||
(pkgs.writeStringReferencesToFile testScript'); | ||
|
||
# Ensure we do not use aliases. Ideally this is only set | ||
|
@@ -256,16 +242,18 @@ rec { | |
); | ||
|
||
driver = setupDriverForTest { | ||
inherit testScript enableOCR skipLint passthru; | ||
inherit enableOCR skipLint passthru; | ||
testScript = mkTestScript pkgs.qemu_test; | ||
testName = name; | ||
qemu_pkg = pkgs.qemu_test; | ||
nodes = nodes pkgs.qemu_test; | ||
nodes = nodes pkgs.qemu_test true; | ||
Comment on lines
+245
to
+249
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be best if the |
||
}; | ||
driverInteractive = setupDriverForTest { | ||
inherit testScript enableOCR skipLint passthru; | ||
inherit enableOCR skipLint passthru; | ||
testScript = mkTestScript pkgs.qemu; | ||
testName = name; | ||
qemu_pkg = pkgs.qemu; | ||
nodes = nodes pkgs.qemu; | ||
nodes = nodes pkgs.qemu true; | ||
}; | ||
|
||
test = | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.