diff options
author | Travis A. Everett <travis.a.everett@gmail.com> | 2021-09-23 19:55:14 -0500 |
---|---|---|
committer | Cole Helbling <cole.e.helbling@outlook.com> | 2022-02-07 19:43:37 -0800 |
commit | 14d355b7c0262cbaddfc3090b9a6ef5eea2ee7c5 (patch) | |
tree | 397554226de2cba8a735e023175262844ae47f73 /pkgs/tools/misc/shunit2 | |
parent | 5469552b2f8eb31eb7cfd5b6db4a0805d3fea293 (diff) |
shunit2: use resholvePackage
Diffstat (limited to 'pkgs/tools/misc/shunit2')
-rw-r--r-- | pkgs/tools/misc/shunit2/default.nix | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/pkgs/tools/misc/shunit2/default.nix b/pkgs/tools/misc/shunit2/default.nix index 1895acacac270..07265fb89cd05 100644 --- a/pkgs/tools/misc/shunit2/default.nix +++ b/pkgs/tools/misc/shunit2/default.nix @@ -1,6 +1,15 @@ -{ lib, stdenv, fetchFromGitHub }: +{ lib +, resholvePackage +, fetchFromGitHub +, bash +, coreutils +, gnused +, gnugrep +, findutils +, ncurses +}: -stdenv.mkDerivation { +resholvePackage { pname = "shunit2"; version = "2019-08-10"; @@ -22,6 +31,55 @@ stdenv.mkDerivation { $out/bin/shunit2 ''; + solutions = { + shunit = { + # Caution: see __SHUNIT_CMD_ECHO_ESC before changing + interpreter = "${bash}/bin/sh"; + scripts = [ "bin/shunit2" ]; + inputs = [ coreutils gnused gnugrep findutils ncurses ]; + # resholve's Nix API is analogous to the CLI flags + # documented in 'man resholve' + fake = { + # "missing" functions shunit2 expects the user to declare + function = [ + "oneTimeSetUp" + "oneTimeTearDown" + "setUp" + "tearDown" + "suite" + "noexec" + ]; + # shunit2 is both bash and zsh compatible, and in + # some zsh-specific code it uses this non-bash builtin + builtin = [ "setopt" ]; + }; + fix = { + # stray absolute path; make it resolve from coreutils + "/usr/bin/od" = true; + /* + Caution: this one is contextually debatable. shunit2 + sets this variable after testing whether `echo -e test` + yields `test` or `-e test`. Since we're setting the + interpreter, we can pre-test this. But if we go fiddle + the interpreter later, I guess we _could_ break it. + */ + "$__SHUNIT_CMD_ECHO_ESC" = [ "'echo -e'" ]; + "$SHUNIT_CMD_TPUT" = [ "tput" ]; # from ncurses + }; + keep = { + # dynamically defined in shunit2:_shunit_mktempFunc + eval = [ "shunit_condition_" "_shunit_test_" "_shunit_prepForSourcing" ]; + + # dynamic based on CLI flag + "$_SHUNIT_LINENO_" = true; + }; + execer = [ + # drop after https://github.com/abathur/binlore/issues/2 + "cannot:${ncurses}/bin/tput" + ]; + }; + }; + meta = with lib; { homepage = "https://github.com/kward/shunit2"; description = "A xUnit based unit test framework for Bourne based shell scripts"; |