20 , doInstallCheck ? true
23 resholve.mkDerivation rec {
27 src = fetchFromGitHub {
31 sha256 = "sha256-gy4dyoKRlf2WFmH1/mSNwhVR3df92BgpT4TjTpV4FyQ=";
49 interpreter = "${bash}/bin/bash";
67 "pkill" # procps doesn't supply this on darwin
71 "$BATS_ROOT" = [ "${placeholder "out"}" ];
72 "$BATS_LIBEXEC" = [ "${placeholder "out"}/libexec/bats-core" ];
75 "${placeholder "out"}/libexec/bats-core/bats" = true;
77 "${placeholder "out"}/lib/bats-core/validator.bash"
78 "${placeholder "out"}/lib/bats-core/preprocessing.bash"
80 "${placeholder "out"}/lib/bats-core/tracing.bash"
81 "${placeholder "out"}/lib/bats-core/test_functions.bash"
83 "${placeholder "out"}/lib/bats-core/common.bash"
84 "${placeholder "out"}/lib/bats-core/semaphore.bash"
85 "${placeholder "out"}/lib/bats-core/formatter.bash"
86 "${placeholder "out"}/lib/bats-core/warnings.bash"
87 "$setup_suite_file" # via cli arg
89 "$interpolated_report_formatter" = true;
90 "$interpolated_formatter" = true;
91 "$pre_command" = true;
92 "$BATS_TEST_NAME" = true;
93 "${placeholder "out"}/libexec/bats-core/bats-exec-test" = true;
94 "$BATS_LINE_REFERENCE_FORMAT" = "comma_line";
95 "$BATS_LOCKING_IMPLEMENTATION" = "${flock}/bin/flock";
96 "$parallel_binary_name" = "${parallel}/bin/parallel";
100 both blatant lies for expedience; these can certainly exec args
101 they may be safe here, because they may always run things that
102 are ultimately in libexec?
103 TODO: handle parallel and flock in binlore/resholve
105 "cannot:${parallel}/bin/parallel"
106 "cannot:${flock}/bin/flock"
108 "cannot:libexec/bats-core/bats-preprocess"
110 # these do exec, but other internal files
111 "cannot:libexec/bats-core/bats-exec-file"
112 "cannot:libexec/bats-core/bats-exec-suite"
117 passthru.libraries = callPackages ./libraries.nix {};
119 passthru.withLibraries = selector:
121 name = "bats-with-libraries-${bats.version}";
125 ] ++ selector bats.libraries;
127 nativeBuildInputs = [
132 wrapProgram "$out/bin/bats" \
133 --suffix BATS_LIB_PATH : "$out/share/bats"
137 passthru.tests.libraries = runCommand "${bats.name}-with-libraries-test" {
140 bats_load_library bats-support
141 bats_load_library bats-assert
142 bats_load_library bats-file
144 bats_require_minimum_version 1.5.0
146 TEST_TEMP_DIR="$(temp_make --prefix 'nixpkgs-bats-test')"
150 temp_del "$TEST_TEMP_DIR"
160 assert_line --index 0 "cp: missing file operand"
161 assert_line --index 1 "Try 'cp --help' for more information."
165 echo "hi" > "$TEST_TEMP_DIR/hello.txt"
166 assert_file_exist "$TEST_TEMP_DIR/hello.txt"
167 run cat "$TEST_TEMP_DIR/hello.txt"
171 passAsFile = [ "testScript" ];
173 ${bats.withLibraries (p: [ p.bats-support p.bats-assert p.bats-file ])}/bin/bats "$testScriptPath"
177 passthru.tests.upstream = bats.unresholved.overrideAttrs (old: {
178 name = "${bats.name}-tests";
179 dontInstall = true; # just need the build directory
180 nativeInstallCheckInputs = [
182 parallel # skips some tests if it can't detect
183 flock # skips some tests if it can't detect
185 ] ++ lib.optionals stdenv.isDarwin [ lsof ];
186 inherit doInstallCheck;
187 installCheckPhase = ''
188 # TODO: cut if https://github.com/bats-core/bats-core/issues/418 allows
189 sed -i '/test works even if PATH is reset/a skip "disabled for nix build"' test/bats.bats
191 # skip tests that assume bats `install.sh` will be in BATS_ROOT
194 '' + (lib.optionalString stdenv.hostPlatform.isDarwin ''
195 # skip new timeout tests which are failing on macOS for unclear reasons
196 # This might relate to procps not having a pkill?
200 # test generates file with absolute shebang dynamically
201 substituteInPlace test/install.bats --replace \
202 "/usr/bin/env bash" "${bash}/bin/bash"
204 ${bats}/bin/bats test
210 homepage = "https://github.com/bats-core/bats-core";
211 description = "Bash Automated Testing System";
212 maintainers = with maintainers; [ abathur ];
213 license = licenses.mit;
214 platforms = platforms.unix;