forked from mirrors/nixpkgs
add opt out flag for type checking
This commit is contained in:
parent
814027378b
commit
fd4ebd8990
|
@ -332,6 +332,19 @@ repository):
|
||||||
'';
|
'';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Similarly, the type checking of test scripts can be disabled in the following
|
||||||
|
way:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
import ./make-test-python.nix {
|
||||||
|
skipTypeCheck = true;
|
||||||
|
nodes.machine =
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{ configuration…
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Failing tests early {#ssec-failing-tests-early}
|
## Failing tests early {#ssec-failing-tests-early}
|
||||||
|
|
||||||
To fail tests early when certain invariables are no longer met (instead of waiting for the build to time out), the decorator `polling_condition` is provided. For example, if we are testing a program `foo` that should not quit after being started, we might write the following:
|
To fail tests early when certain invariables are no longer met (instead of waiting for the build to time out), the decorator `polling_condition` is provided. For example, if we are testing a program `foo` that should not quit after being started, we might write the following:
|
||||||
|
|
|
@ -589,6 +589,19 @@ import ./make-test-python.nix {
|
||||||
Python code…
|
Python code…
|
||||||
# fmt: on
|
# fmt: on
|
||||||
'';
|
'';
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Similarly, the type checking of test scripts can be disabled in
|
||||||
|
the following way:
|
||||||
|
</para>
|
||||||
|
<programlisting language="bash">
|
||||||
|
import ./make-test-python.nix {
|
||||||
|
skipTypeCheck = true;
|
||||||
|
nodes.machine =
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{ configuration…
|
||||||
|
};
|
||||||
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</section>
|
</section>
|
||||||
<section xml:id="ssec-failing-tests-early">
|
<section xml:id="ssec-failing-tests-early">
|
||||||
|
|
|
@ -50,6 +50,7 @@ rec {
|
||||||
, qemu_pkg ? pkgs.qemu_test
|
, qemu_pkg ? pkgs.qemu_test
|
||||||
, enableOCR ? false
|
, enableOCR ? false
|
||||||
, skipLint ? false
|
, skipLint ? false
|
||||||
|
, skipTypeCheck ? false
|
||||||
, passthru ? {}
|
, passthru ? {}
|
||||||
, interactive ? false
|
, interactive ? false
|
||||||
}:
|
}:
|
||||||
|
@ -129,19 +130,21 @@ rec {
|
||||||
|
|
||||||
vmStartScripts=($(for i in ${toString vms}; do echo $i/bin/run-*-vm; done))
|
vmStartScripts=($(for i in ${toString vms}; do echo $i/bin/run-*-vm; done))
|
||||||
|
|
||||||
# prepend type hints so the test script can be type checked with mypy
|
${lib.optionalString (!skipTypeCheck) ''
|
||||||
cat "${./test-script-prepend.py}" >> testScriptWithTypes
|
# prepend type hints so the test script can be type checked with mypy
|
||||||
echo "${builtins.toString machineNames}" >> testScriptWithTypes
|
cat "${./test-script-prepend.py}" >> testScriptWithTypes
|
||||||
echo "${builtins.toString vlanNames}" >> testScriptWithTypes
|
echo "${builtins.toString machineNames}" >> testScriptWithTypes
|
||||||
echo -n "$testScript" >> testScriptWithTypes
|
echo "${builtins.toString vlanNames}" >> testScriptWithTypes
|
||||||
|
echo -n "$testScript" >> testScriptWithTypes
|
||||||
|
|
||||||
# set pythonpath so mypy knows where to find the imports. this requires the py.typed file.
|
# set pythonpath so mypy knows where to find the imports. this requires the py.typed file.
|
||||||
export PYTHONPATH='${./test-driver}'
|
export PYTHONPATH='${./test-driver}'
|
||||||
mypy --no-implicit-optional \
|
mypy --no-implicit-optional \
|
||||||
--pretty \
|
--pretty \
|
||||||
--no-color-output \
|
--no-color-output \
|
||||||
testScriptWithTypes
|
testScriptWithTypes
|
||||||
unset PYTHONPATH
|
unset PYTHONPATH
|
||||||
|
''}
|
||||||
|
|
||||||
echo -n "$testScript" >> $out/test-script
|
echo -n "$testScript" >> $out/test-script
|
||||||
|
|
||||||
|
@ -171,6 +174,7 @@ rec {
|
||||||
, testScript
|
, testScript
|
||||||
, enableOCR ? false
|
, enableOCR ? false
|
||||||
, name ? "unnamed"
|
, name ? "unnamed"
|
||||||
|
, skipTypeCheck ? false
|
||||||
# Skip linting (mainly intended for faster dev cycles)
|
# Skip linting (mainly intended for faster dev cycles)
|
||||||
, skipLint ? false
|
, skipLint ? false
|
||||||
, passthru ? {}
|
, passthru ? {}
|
||||||
|
@ -232,13 +236,13 @@ rec {
|
||||||
);
|
);
|
||||||
|
|
||||||
driver = setupDriverForTest {
|
driver = setupDriverForTest {
|
||||||
inherit testScript enableOCR skipLint passthru;
|
inherit testScript enableOCR skipTypeCheck skipLint passthru;
|
||||||
testName = name;
|
testName = name;
|
||||||
qemu_pkg = pkgs.qemu_test;
|
qemu_pkg = pkgs.qemu_test;
|
||||||
nodes = mkNodes pkgs.qemu_test;
|
nodes = mkNodes pkgs.qemu_test;
|
||||||
};
|
};
|
||||||
driverInteractive = setupDriverForTest {
|
driverInteractive = setupDriverForTest {
|
||||||
inherit testScript enableOCR skipLint passthru;
|
inherit testScript enableOCR skipTypeCheck skipLint passthru;
|
||||||
testName = name;
|
testName = name;
|
||||||
qemu_pkg = pkgs.qemu;
|
qemu_pkg = pkgs.qemu;
|
||||||
nodes = mkNodes pkgs.qemu;
|
nodes = mkNodes pkgs.qemu;
|
||||||
|
|
Loading…
Reference in a new issue