mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2025-12-12 02:00:18 +01:00
fix: support passing string as dir for autodiscovery
This commit is contained in:
parent
d7e4902fed
commit
0272a8b0dc
2 changed files with 12 additions and 1 deletions
|
|
@ -39,7 +39,11 @@ in rec {
|
||||||
}: let
|
}: let
|
||||||
files = builtins.readDir dir;
|
files = builtins.readDir dir;
|
||||||
matchingFiles = builtins.filter (name: builtins.match pattern name != null) (builtins.attrNames files);
|
matchingFiles = builtins.filter (name: builtins.match pattern name != null) (builtins.attrNames files);
|
||||||
imports = map (file: /${dir}/${file}) matchingFiles;
|
imports = map (file:
|
||||||
|
if builtins.isString dir
|
||||||
|
then (builtins.unsafeDiscardStringContext dir) + "/${file}"
|
||||||
|
else /${dir}/${file})
|
||||||
|
matchingFiles;
|
||||||
in {
|
in {
|
||||||
inherit imports;
|
inherit imports;
|
||||||
# automatically set the base so test filepaths are easier to read
|
# automatically set the base so test filepaths are easier to read
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@
|
||||||
actual = ntlib.helpers.toPrettyFile (ntlib.autodiscover {
|
actual = ntlib.helpers.toPrettyFile (ntlib.autodiscover {
|
||||||
dir = ./fixtures;
|
dir = ./fixtures;
|
||||||
});
|
});
|
||||||
|
# tests if strings with store path context work
|
||||||
|
actualDirString = ntlib.helpers.toPrettyFile (ntlib.autodiscover {
|
||||||
|
dir = "${./fixtures}";
|
||||||
|
});
|
||||||
in
|
in
|
||||||
# sh
|
# sh
|
||||||
''
|
''
|
||||||
|
|
@ -20,6 +24,9 @@
|
||||||
${ntlib.helpers.scriptHelpers}
|
${ntlib.helpers.scriptHelpers}
|
||||||
assert_file_contains ${actual} "sample_test.nix" "should find sample_test.nix"
|
assert_file_contains ${actual} "sample_test.nix" "should find sample_test.nix"
|
||||||
assert_file_contains ${actual} "base = \"/nix/store/.*-source/tests/fixtures/\"" "should set base to fixtures dir"
|
assert_file_contains ${actual} "base = \"/nix/store/.*-source/tests/fixtures/\"" "should set base to fixtures dir"
|
||||||
|
|
||||||
|
assert_file_contains ${actualDirString} "sample_test.nix" "should find sample_test.nix"
|
||||||
|
assert_file_contains ${actualDirString} "base = \"/nix/store/.*-fixtures/\"" "should set base to fixtures dir"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue