chore: verify dream-lock examples

This commit is contained in:
DavHau 2022-11-14 18:07:18 +01:00
parent fbba21b525
commit 4427f736aa
7 changed files with 88 additions and 6 deletions

View File

@ -65,7 +65,7 @@ utils.writePureShellScriptBin
${pkgs.python3.pkgs.jsonschema}/bin/jsonschema \
--instance $dreamLockPath \
--output pretty \
--base-uri file:${../../specifications} \
--base-uri file:${../../specifications}/ \
${../../specifications}/dream-lock-schema.json
echo -e "\nFinished:: $name (translator: $translator) (lock path: $dreamLockPath)"

View File

@ -11,6 +11,7 @@
"_subsystem": {
"pythonAttr": "python38",
"application": false,
"sourceFormats": {
"requests": "sdist",
"certifi": "wheel"
@ -32,7 +33,6 @@
"1.2.3": {
"url": "https://download.pypi.org/requests/2.28.0",
"hash": "000000000000000000000000000000000000000",
"version": "1.2.3",
"type": "http"
}
},
@ -40,7 +40,6 @@
"2.3.4": {
"url": "https://download.pypi.org/certifi/2.0",
"hash": "000000000000000000000000000000000000000",
"version": "2.3.4",
"type": "http"
}
}

View File

@ -1,6 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "dream-lock-schema.json",
"title": "manifest",
"type": "object",
"properties": {

View File

@ -229,7 +229,7 @@ in
${python3.pkgs.jsonschema}/bin/jsonschema \
--instance $dreamLockPath \
--output pretty \
--base-uri file:${../specifications} \
--base-uri file:${../specifications}/ \
${../specifications}/dream-lock-schema.json
# add dream-lock.json to git

View File

@ -55,7 +55,7 @@ in
shift
${testScript} $arg1 "$@"
fi
echo "done running integration tests"
echo "done running flake integration tests"
echo -e "\nExecution times:"
cat $STATS_FILE | sort --numeric-sort
rm $STATS_FILE

View File

@ -0,0 +1,58 @@
{
self,
lib,
async,
bash,
coreutils,
git,
parallel,
nix,
pkgs,
utils,
dream2nixWithExternals,
callPackageDream,
...
}: let
l = lib // builtins;
testDirs = l.attrNames (l.readDir ./tests);
testScripts =
map
(dir: callPackageDream (./tests + "/${dir}") {inherit self;})
testDirs;
testScriptsFile = pkgs.writeText "scripts-list" (l.concatStringsSep "\n" testScripts);
execTest =
utils.writePureShellScript
[
bash
coreutils
]
''
cd $TMPDIR
test=$1
shift
echo -e "\nrunning test $test"
start_time=$(date +%s)
bash "$test"
end_time=$(date +%s)
elapsed=$(( end_time - start_time ))
echo -e "testing example for $test took $elapsed seconds"
echo "$elapsed sec: $test" >> $STATS_FILE
'';
in
utils.writePureShellScript
[
bash
coreutils
parallel
]
''
export STATS_FILE=$(mktemp)
JOBS=''${JOBS:-$(nproc)}
parallel --halt now,fail=1 -j$JOBS -a ${testScriptsFile} ${execTest}
echo "done running integration tests"
echo -e "\nExecution times:"
cat $STATS_FILE | sort --numeric-sort
rm $STATS_FILE
''

View File

@ -0,0 +1,26 @@
{
lib,
pkgs,
utils,
self,
...
}: let
l = lib // builtins;
specificationsDir = ../../../../src/specifications;
in
utils.writePureShellScript
(with pkgs; [
coreutils
nix
])
''
cd $TMPDIR
cp -r ${specificationsDir}/* .
chmod -R +w .
specsDir=$(realpath .)
${pkgs.python3.pkgs.jsonschema}/bin/jsonschema \
--instance $specsDir/dream-lock-example.json \
--output pretty \
--base-uri file:$specsDir/ \
$specsDir/dream-lock-schema.json
''