tests: adapt to new linter
The Python test driver now uses 'pyflakes'. Remove hacks that were needed for the 'black' linter.
This commit is contained in:
parent
c1c663d0a9
commit
1be924529d
@ -10,36 +10,16 @@ args:
|
|||||||
let
|
let
|
||||||
test = pythonTesting.makeTest args;
|
test = pythonTesting.makeTest args;
|
||||||
|
|
||||||
fixedDriver = test.driver.overrideAttrs (old: let
|
# 1. Save test logging output
|
||||||
# Allow the test script to have longer lines by fixing the call to the 'black'
|
# 2. Add link to driver so that a gcroot to a test prevents the driver from
|
||||||
# code formatter.
|
|
||||||
# The default width of 88 chars is too restrictive for our script.
|
|
||||||
parts = builtins.split ''/nix/store/[^ ]+/black '' old.buildCommand;
|
|
||||||
preMatch = builtins.elemAt parts 0;
|
|
||||||
postMatch = builtins.elemAt parts 2;
|
|
||||||
in {
|
|
||||||
# See `mkDriver` in nixpkgs/nixos/lib/testing-python.nix for the original definition of `buildCommand`
|
|
||||||
buildCommand = ''
|
|
||||||
${preMatch}${pkgs.python3Packages.black}/bin/black --line-length 100 ${postMatch}
|
|
||||||
'';
|
|
||||||
# Keep reference to the `testDriver` derivation, required by `buildCommand`
|
|
||||||
testDriverReference = old.buildCommand;
|
|
||||||
});
|
|
||||||
|
|
||||||
# 1. Use fixed driver
|
|
||||||
# 2. Save test logging output
|
|
||||||
# 3. Add link to driver so that a gcroot to a test prevents the driver from
|
|
||||||
# being garbage-collected
|
# being garbage-collected
|
||||||
fixedTest = test.overrideAttrs (_: {
|
fixedTest = test.overrideAttrs (_: {
|
||||||
# See `runTests` in nixpkgs/nixos/lib/testing-python.nix for the original definition of `buildCommand`
|
# See `runTests` in nixpkgs/nixos/lib/testing-python.nix for the original definition of `buildCommand`
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
LOGFILE=$out/output.xml tests='exec(os.environ["testScript"])' ${fixedDriver}/bin/nixos-test-driver
|
LOGFILE=$out/output.xml tests='exec(os.environ["testScript"])' ${test.driver}/bin/nixos-test-driver
|
||||||
ln -s ${fixedDriver} $out/driver
|
ln -s ${test.driver} $out/driver
|
||||||
'';
|
'';
|
||||||
}) // {
|
});
|
||||||
driver = fixedDriver;
|
|
||||||
inherit (test) nodes;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
fixedTest
|
fixedTest
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
logger = machine.logger
|
||||||
|
|
||||||
def succeed(*cmds):
|
def succeed(*cmds):
|
||||||
"""Returns the concatenated output of all cmds"""
|
"""Returns the concatenated output of all cmds"""
|
||||||
@ -39,7 +40,7 @@ def wait_for_open_port(address, port):
|
|||||||
status, _ = machine.execute(f"nc -z {address} {port}")
|
status, _ = machine.execute(f"nc -z {address} {port}")
|
||||||
return status == 0
|
return status == 0
|
||||||
|
|
||||||
with log.nested(f"Waiting for TCP port {address}:{port}"):
|
with logger.nested(f"Waiting for TCP port {address}:{port}"):
|
||||||
retry(is_port_open)
|
retry(is_port_open)
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ def run_tests():
|
|||||||
raise RuntimeError(f"The following tests are enabled but not defined: {enabled}")
|
raise RuntimeError(f"The following tests are enabled but not defined: {enabled}")
|
||||||
machine.connect() # Visually separate boot output from the test output
|
machine.connect() # Visually separate boot output from the test output
|
||||||
for test in to_run:
|
for test in to_run:
|
||||||
with log.nested(f"test: {test}"):
|
with logger.nested(f"test: {test}"):
|
||||||
tests[test]()
|
tests[test]()
|
||||||
|
|
||||||
|
|
||||||
@ -150,9 +151,9 @@ def _():
|
|||||||
f"Output of 'lightning-cli plugin list':\n{plugin_list}"
|
f"Output of 'lightning-cli plugin list':\n{plugin_list}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
log.log("Active clightning plugins:")
|
logger.log("Active clightning plugins:")
|
||||||
for p in test_data["clightning-plugins"]:
|
for p in test_data["clightning-plugins"]:
|
||||||
log.log(os.path.basename(p))
|
logger.log(os.path.basename(p))
|
||||||
|
|
||||||
|
|
||||||
@test("lnd")
|
@test("lnd")
|
||||||
|
Loading…
Reference in New Issue
Block a user