From f46a1e353af8bd3f021f400f7275888c22dbaa29 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 8 Jun 2021 11:36:09 +0200 Subject: [PATCH] tests.writers: give all test derivations unique names This makes it easier to debug test failures since the derivation name will give an indication which writer it belongs to. --- pkgs/build-support/writers/test.nix | 52 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix index 689b45a126f..b0df153fee8 100644 --- a/pkgs/build-support/writers/test.nix +++ b/pkgs/build-support/writers/test.nix @@ -13,11 +13,11 @@ with writers; let bin = { - bash = writeBashBin "test_writers" '' + bash = writeBashBin "test_writers_bash_bin" '' if [[ "test" == "test" ]]; then echo "success"; fi ''; - c = writeCBin "test_writers" { libraries = [ ]; } '' + c = writeCBin "test_writers_c" { libraries = [ ]; } '' #include int main() { printf("success\n"); @@ -25,17 +25,17 @@ let } ''; - dash = writeDashBin "test_writers" '' + dash = writeDashBin "test_writers_dash_bin" '' test '~' = '~' && echo 'success' ''; - rust = writeRustBin "test_writers" {} '' + rust = writeRustBin "test_writers_rust_bin" {} '' fn main(){ println!("success") } ''; - haskell = writeHaskellBin "test_writers" { libraries = [ haskellPackages.acme-default ]; } '' + haskell = writeHaskellBin "test_writers_haskell_bin" { libraries = [ haskellPackages.acme-default ]; } '' import Data.Default int :: Int @@ -47,7 +47,7 @@ let _ -> print "fail" ''; - js = writeJSBin "test_writers" { libraries = [ nodePackages.semver ]; } '' + js = writeJSBin "test_writers_js_bin" { libraries = [ nodePackages.semver ]; } '' var semver = require('semver'); if (semver.valid('1.2.3')) { @@ -57,12 +57,12 @@ let } ''; - perl = writePerlBin "test_writers" { libraries = [ perlPackages.boolean ]; } '' + perl = writePerlBin "test_writers_perl_bin" { libraries = [ perlPackages.boolean ]; } '' use boolean; print "success\n" if true; ''; - python2 = writePython2Bin "test_writers" { libraries = [ python2Packages.enum ]; } '' + python2 = writePython2Bin "test_writers_python2_bin" { libraries = [ python2Packages.enum ]; } '' from enum import Enum @@ -73,7 +73,7 @@ let print Test.a ''; - python3 = writePython3Bin "test_writers" { libraries = [ python3Packages.pyyaml ]; } '' + python3 = writePython3Bin "test_writers_python3_bin" { libraries = [ python3Packages.pyyaml ]; } '' import yaml y = yaml.load(""" @@ -84,11 +84,11 @@ let }; simple = { - bash = writeBash "test_bash" '' + bash = writeBash "test_writers_bash" '' if [[ "test" == "test" ]]; then echo "success"; fi ''; - c = writeC "test_c" { libraries = [ glib.dev ]; } '' + c = writeC "test_writers_c" { libraries = [ glib.dev ]; } '' #include #include int main() { @@ -106,11 +106,11 @@ let } ''; - dash = writeDash "test_dash" '' + dash = writeDash "test_writers_dash" '' test '~' = '~' && echo 'success' ''; - haskell = writeHaskell "test_haskell" { libraries = [ haskellPackages.acme-default ]; } '' + haskell = writeHaskell "test_writers_haskell" { libraries = [ haskellPackages.acme-default ]; } '' import Data.Default int :: Int @@ -122,7 +122,7 @@ let _ -> print "fail" ''; - js = writeJS "test_js" { libraries = [ nodePackages.semver ]; } '' + js = writeJS "test_writers_js" { libraries = [ nodePackages.semver ]; } '' var semver = require('semver'); if (semver.valid('1.2.3')) { @@ -132,12 +132,12 @@ let } ''; - perl = writePerl "test_perl" { libraries = [ perlPackages.boolean ]; } '' + perl = writePerl "test_writers_perl" { libraries = [ perlPackages.boolean ]; } '' use boolean; print "success\n" if true; ''; - python2 = writePython2 "test_python2" { libraries = [ python2Packages.enum ]; } '' + python2 = writePython2 "test_writers_python2" { libraries = [ python2Packages.enum ]; } '' from enum import Enum @@ -148,7 +148,7 @@ let print Test.a ''; - python3 = writePython3 "test_python3" { libraries = [ python3Packages.pyyaml ]; } '' + python3 = writePython3 "test_writers_python3" { libraries = [ python3Packages.pyyaml ]; } '' import yaml y = yaml.load(""" @@ -157,21 +157,21 @@ let print(y[0]['test']) ''; - python2NoLibs = writePython2 "test_python2_no_libs" {} '' + python2NoLibs = writePython2 "test_writers_python2_no_libs" {} '' print("success") ''; - python3NoLibs = writePython3 "test_python3_no_libs" {} '' + python3NoLibs = writePython3 "test_writers_python3_no_libs" {} '' print("success") ''; }; path = { - bash = writeBash "test_bash" (writeText "test" '' + bash = writeBash "test_writers_bash_path" (writeText "test" '' if [[ "test" == "test" ]]; then echo "success"; fi ''); - haskell = writeHaskell "test_haskell" { libraries = [ haskellPackages.acme-default ]; } (writeText "test" '' + haskell = writeHaskell "test_writers_haskell_path" { libraries = [ haskellPackages.acme-default ]; } (writeText "test" '' import Data.Default int :: Int @@ -184,8 +184,8 @@ let ''); }; - writeTest = expectedValue: test: - writeDash "test-writers" '' + writeTest = expectedValue: name: test: + writeDash "run-${name}" '' if test "$(${test})" != "${expectedValue}"; then echo 'test ${test} failed' exit 1 @@ -196,9 +196,9 @@ in runCommand "test-writers" { passthru = { inherit writeTest bin simple; }; meta.platforms = lib.platforms.all; } '' - ${lib.concatMapStringsSep "\n" (test: writeTest "success" "${test}/bin/test_writers") (lib.attrValues bin)} - ${lib.concatMapStringsSep "\n" (test: writeTest "success" test) (lib.attrValues simple)} - ${lib.concatMapStringsSep "\n" (test: writeTest "success" test) (lib.attrValues path)} + ${lib.concatMapStringsSep "\n" (test: writeTest "success" test.name "${test}/bin/${test.name}") (lib.attrValues bin)} + ${lib.concatMapStringsSep "\n" (test: writeTest "success" test.name test) (lib.attrValues simple)} + ${lib.concatMapStringsSep "\n" (test: writeTest "success" test.name test) (lib.attrValues path)} echo 'nix-writers successfully tested' >&2 touch $out