nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 432 lines 15 kB view raw
1{ callPackage }: 2 3{ 4 test-bash = callPackage ( 5 { 6 lib, 7 runCommandLocal, 8 bash, 9 hello, 10 ksh, 11 patchRcPathBash, 12 shellcheck, 13 zsh, 14 }: 15 runCommandLocal "patch-rc-path-bash-test" 16 { 17 nativeBuildInputs = [ 18 bash 19 ksh 20 patchRcPathBash 21 shellcheck 22 zsh 23 ]; 24 meta = { 25 description = "Package test of patchActivateBash"; 26 inherit (patchRcPathBash.meta) maintainers; 27 }; 28 } 29 '' 30 set -eu -o pipefail 31 32 33 # Check the setup hook script 34 35 echo "Running shellcheck against ${./test-sourcing-bash}" 36 shellcheck -s bash --exclude SC1090 ${./test-sourcing-bash} 37 shellcheck -s ksh --exclude SC1090 ${./test-sourcing-bash} 38 39 40 # Test patching a blank file 41 42 echo > blank.bash 43 44 echo "Generating blank_patched.bash from blank.bash" 45 cp blank.bash blank_patched.bash 46 patchRcPathBash blank_patched.bash "$PWD/delta:$PWD/foxtrot" 47 48 echo "Running shellcheck against blank_patched.bash" 49 shellcheck -s bash blank_patched.bash 50 shellcheck -s ksh blank_patched.bash 51 52 echo "Testing in Bash if blank.bash and blank_patched.bash modifies PATH the same way" 53 bash ${./test-sourcing-bash} ./blank.bash ./blank_patched.bash 54 55 echo "Testing in Ksh if blank.bash and blank_patched.bash modifies PATH the same way" 56 ksh ${./test-sourcing-bash} "$PWD/blank.bash" "$PWD/blank_patched.bash" 57 58 echo "Testing in Zsh if blank.bash and blank_patched.bash modifies PATH the same way" 59 zsh ${./test-sourcing-bash} ./blank.bash ./blank_patched.bash 60 61 62 # Test patching silent_hello 63 64 echo "hello > /dev/null" > silent_hello.bash 65 66 echo "Generating silent_hello_patched.bash from silent_hello.bash" 67 cp silent_hello.bash silent_hello_patched.bash 68 patchRcPathBash silent_hello_patched.bash "${hello}/bin" 69 70 echo "Running shellcheck against silent_hello_patched.bash" 71 shellcheck -s bash silent_hello_patched.bash 72 73 echo "Testing in Bash if silent_hello_patched.bash get sourced without error" 74 bash -eu -o pipefail -c ". ./silent_hello_patched.bash" 75 76 echo "Testing in Ksh if silent_hello_patched.bash get sourced without error" 77 ksh -eu -o pipefail -c ". ./silent_hello_patched.bash" 78 79 echo "Testing in Zsh if silent_hello_patched.bash get sourced without error" 80 zsh -eu -o pipefail -c ". ./silent_hello_patched.bash" 81 82 83 # Check the sample source 84 85 echo "Running shellcheck against sample_source.bash" 86 shellcheck -s bash ${./sample_source.bash} 87 shellcheck -s ksh ${./sample_source.bash} 88 89 90 # Test patching the sample source 91 92 cp ${./sample_source.bash} sample_source_patched.bash 93 chmod u+w sample_source_patched.bash 94 95 echo "Generating sample_source_patched.bash from ./sample_source.bash" 96 patchRcPathBash sample_source_patched.bash "$PWD/delta:$PWD/foxtrot" 97 98 echo "Running shellcheck against sample_source_patched.bash" 99 shellcheck -s bash sample_source_patched.bash 100 101 echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 102 bash ${./test-sourcing-bash} ${./sample_source.bash} ./sample_source_patched.bash 103 104 echo "Testing in Ksh if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 105 ksh ${./test-sourcing-bash} ${./sample_source.bash} "$PWD/sample_source_patched.bash" 106 107 echo "Testing in Zsh if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 108 zsh ${./test-sourcing-bash} ${./sample_source.bash} ./sample_source_patched.bash 109 110 111 # Test double-patching the sample source 112 113 echo "Patching again sample_source_patched.bash" 114 patchRcPathBash sample_source_patched.bash "$PWD/foxtrot:$PWD/golf" 115 116 echo "Running shellcheck against sample_source_patched.bash" 117 shellcheck -s bash sample_source_patched.bash 118 shellcheck -s ksh sample_source_patched.bash 119 120 echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 121 bash ${./test-sourcing-bash} ${./sample_source.bash} ./sample_source_patched.bash 122 123 echo "Testing in Ksh if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 124 ksh ${./test-sourcing-bash} ${./sample_source.bash} "$PWD/sample_source_patched.bash" 125 126 echo "Testing in Zsh if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 127 zsh ${./test-sourcing-bash} ${./sample_source.bash} ./sample_source_patched.bash 128 129 130 # Create a dummy output 131 touch "$out" 132 '' 133 ) { }; 134 135 test-csh = callPackage ( 136 { 137 lib, 138 runCommandLocal, 139 gnused, 140 hello, 141 patchRcPathCsh, 142 tcsh, 143 }: 144 runCommandLocal "patch-rc-path-csh-test" 145 { 146 nativeBuildInputs = [ 147 patchRcPathCsh 148 tcsh 149 ]; 150 meta = { 151 description = "Package test of patchActivateCsh"; 152 inherit (patchRcPathCsh.meta) maintainers; 153 }; 154 } 155 '' 156 set -eu -o pipefail 157 158 159 # Test patching a blank file 160 161 echo > blank.csh 162 163 echo "Generating blank_patched.csh from blank.csh" 164 cp blank.csh blank_patched.csh 165 patchRcPathCsh blank_patched.csh "$PWD/delta:$PWD/foxtrot" 166 167 echo "Testing in Csh if blank.csh and blank_patched.csh modifies PATH the same way" 168 tcsh -e ${./test-sourcing-csh} blank.csh blank_patched.csh 169 170 171 # Test patching silent_hello file 172 173 echo "hello > /dev/null" > silent_hello.csh 174 175 echo "Generating silent_hello_patched.csh from silent_hello.csh" 176 cp silent_hello.csh silent_hello_patched.csh 177 patchRcPathCsh silent_hello_patched.csh "${hello}/bin" 178 179 echo "Testing in Csh if silent_hello_patched.csh get sourced without errer" 180 tcsh -e -c "source silent_hello_patched.csh" 181 182 183 # Generate the sample source 184 185 substitute ${./sample_source.csh.in} sample_source.csh --replace @sed@ ${gnused}/bin/sed 186 chmod u+rw sample_source.csh 187 188 189 # Test patching the sample source 190 191 echo "Generating sample_source_patched.csh from sample_source.csh" 192 cp sample_source.csh sample_source_patched.csh 193 chmod u+w sample_source_patched.csh 194 patchRcPathCsh sample_source_patched.csh "$PWD/delta:$PWD/foxtrot" 195 196 echo "Testing in Csh if sample_source.csh and sample_source_patched.csh modifies PATH the same way" 197 tcsh -e ${./test-sourcing-csh} sample_source.csh sample_source_patched.csh 198 199 200 # Test double-patching the sample source 201 202 echo "Patching again sample_source_patched.csh from sample_source.csh" 203 patchRcPathCsh sample_source_patched.csh "$PWD/foxtrot:$PWD/golf" 204 205 echo "Testing in Csh if sample_source.csh and sample_source_patched.csh modifies PATH the same way" 206 tcsh -e ${./test-sourcing-csh} sample_source.csh sample_source_patched.csh 207 208 209 # Create a dummy output 210 touch "$out" 211 '' 212 ) { }; 213 214 test-fish = callPackage ( 215 { 216 lib, 217 runCommandLocal, 218 fish, 219 hello, 220 patchRcPathFish, 221 }: 222 runCommandLocal "patch-rc-path-fish-test" 223 { 224 nativeBuildInputs = [ 225 fish 226 patchRcPathFish 227 ]; 228 meta = { 229 description = "Package test of patchActivateFish"; 230 inherit (patchRcPathFish.meta) maintainers; 231 }; 232 } 233 '' 234 set -eu -o pipefail 235 236 237 # Test patching a blank file 238 239 echo > blank.fish 240 241 echo "Generating blank_patched.fish from blank.fish" 242 cp blank.fish blank_patched.fish 243 patchRcPathFish blank_patched.fish "$PWD/delta:$PWD/foxtrot" 244 245 echo "Testing in Fish if blank.fish and blank_patched.fish modifies PATH the same way" 246 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 247 HOME="$HOME_TEMP" fish ${./test-sourcing-fish} blank.fish blank_patched.fish 248 rm -r "$HOME_TEMP" 249 250 251 # Test patching silent_hello file 252 253 echo "hello > /dev/null" > silent_hello.fish 254 255 echo "Generating silent_hello_patched.fish from silent_hello.fish" 256 cp silent_hello.fish silent_hello_patched.fish 257 patchRcPathFish silent_hello_patched.fish "${hello}/bin" 258 259 echo "Testing in Fish if silent_hello_patched.fish get sourced without error" 260 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 261 HOME="$HOME_TEMP" fish -c "source silent_hello_patched.fish" 262 rm -r "$HOME_TEMP" 263 264 265 # Test patching the sample source 266 267 cp ${./sample_source.fish} sample_source_patched.fish 268 chmod u+w sample_source_patched.fish 269 270 echo "Generating sample_source_patched.fish from ${./sample_source.fish}" 271 patchRcPathFish sample_source_patched.fish "$PWD/delta:$PWD/foxtrot" 272 echo "Testing in Fish if sample_source.fish and sample_source_patched.fish modifies PATH the same way" 273 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 274 HOME="$HOME_TEMP" fish ${./test-sourcing-fish} ${./sample_source.fish} sample_source_patched.fish 275 rm -r "$HOME_TEMP" 276 277 278 # Test double-patching the sample source 279 280 echo "Patching again sample_source_patched.fish from ${./sample_source.fish}" 281 patchRcPathFish sample_source_patched.fish "$PWD/foxtrot:$PWD/golf" 282 283 echo "Testing in Fish if sample_source.fish and sample_source_patched.fish modifies PATH the same way" 284 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 285 HOME="$HOME_TEMP" fish ${./test-sourcing-fish} ${./sample_source.fish} sample_source_patched.fish 286 rm -r "$HOME_TEMP" 287 288 289 # Create a dummy output 290 touch "$out" 291 '' 292 ) { }; 293 294 test-posix = callPackage ( 295 { 296 lib, 297 runCommandLocal, 298 bash, 299 dash, 300 gnused, 301 hello, 302 ksh, 303 patchRcPathPosix, 304 shellcheck, 305 }: 306 runCommandLocal "patch-rc-path-posix-test" 307 { 308 nativeBuildInputs = [ 309 bash 310 dash 311 ksh 312 patchRcPathPosix 313 shellcheck 314 ]; 315 meta = { 316 description = "Package test of patchActivatePosix"; 317 inherit (patchRcPathPosix.meta) maintainers; 318 }; 319 } 320 '' 321 set -eu -o pipefail 322 323 324 # Check the setup hook script 325 326 echo "Running shellcheck against ${./test-sourcing-posix}" 327 shellcheck -s sh --exclude SC1090 ${./test-sourcing-posix} 328 shellcheck -s dash --exclude SC1090 ${./test-sourcing-posix} 329 330 331 # Test patching a blank file 332 333 echo > blank.sh 334 335 echo "Generating blank_patched.sh from blank.sh" 336 cp blank.sh blank_patched.sh 337 patchRcPathPosix blank_patched.sh "$PWD/delta:$PWD/foxtrot" 338 339 echo "Running shellcheck against blank_patched.sh" 340 shellcheck -s sh blank_patched.sh 341 shellcheck -s dash blank_patched.sh 342 343 echo "Testing in Bash if blank.sh and blank_patched.sh modifies PATH the same way" 344 bash --posix ${./test-sourcing-posix} ./blank.sh ./blank_patched.sh 345 346 echo "Testing in Dash if blank.sh and blank_patched.sh modifies PATH the same way" 347 dash ${./test-sourcing-posix} ./blank.sh ./blank_patched.sh 348 349 echo "Testing in Ksh if ./blank.sh and ./blank_patched.sh modifies PATH the same way" 350 ksh ${./test-sourcing-posix} "$PWD/blank.sh" "$PWD/blank_patched.sh" 351 352 353 # Test patching silent_hello file 354 355 echo "hello > /dev/null" > silent_hello.sh 356 357 echo "Generating silent_hello_patched.sh from silent_hello.sh" 358 cp silent_hello.sh silent_hello_patched.sh 359 patchRcPathPosix silent_hello_patched.sh "${hello}/bin" 360 361 echo "Running shellcheck against silent_hello_patched.sh" 362 shellcheck -s sh silent_hello_patched.sh 363 shellcheck -s dash silent_hello_patched.sh 364 365 echo "Testing in Bash if silent_hello_patched.sh get sourced without error" 366 bash --posix -eu -c ". ./silent_hello_patched.sh" 367 368 echo "Testing in Dash if silent_hello_patched.sh get sourced without error" 369 dash -eu -c ". ./silent_hello_patched.sh" 370 371 echo "Testing in Ksh if silent_hello_patched.sh get sourced without error" 372 ksh -eu -c ". $PWD/silent_hello_patched.sh" 373 374 375 # Generate the sample source "$PWD/delta:$PWD/foxtrot" "$PWD/delta:$PWD/foxtrot" 376 377 substitute ${./sample_source.sh.in} sample_source.sh --replace @sed@ ${gnused}/bin/sed 378 chmod u+rw sample_source.sh 379 380 381 # Check the sample source 382 383 echo "Running shellcheck against sample_source.sh" 384 shellcheck -s sh sample_source.sh 385 shellcheck -s dash sample_source.sh 386 387 388 # Test patching the sample source 389 390 echo "Generating sample_source_patched.sh from sample_source.sh" 391 cp sample_source.sh sample_source_patched.sh 392 chmod u+w sample_source_patched.sh 393 patchRcPathPosix sample_source_patched.sh "$PWD/delta:$PWD/foxtrot" 394 395 echo "Running shellcheck against sample_source_patched.sh" 396 shellcheck -s sh sample_source_patched.sh 397 shellcheck -s dash sample_source_patched.sh 398 399 echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 400 bash --posix ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 401 402 echo "Testing in Dash if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 403 dash ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 404 405 echo "Testing in Ksh if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 406 ksh ${./test-sourcing-posix} "$PWD/sample_source.sh" "$PWD/sample_source_patched.sh" 407 408 409 # Test double-patching the sample source 410 411 echo "Patching again sample_source_patched.sh" 412 patchRcPathPosix sample_source_patched.sh "$PWD/foxtrot:$PWD/golf" 413 414 echo "Running shellcheck against sample_source_patched.sh" 415 shellcheck -s sh sample_source_patched.sh 416 shellcheck -s dash sample_source_patched.sh 417 418 echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 419 bash --posix ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 420 421 echo "Testing in Dash if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 422 dash ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 423 424 echo "Testing in Ksh if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 425 ksh ${./test-sourcing-posix} "$PWD/sample_source.sh" "$PWD/sample_source_patched.sh" 426 427 428 # Create a dummy output 429 touch "$out" 430 '' 431 ) { }; 432}