Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 442 lines 16 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 136 137 138 test-csh = callPackage 139 ( 140 { lib 141 , runCommandLocal 142 , gnused 143 , hello 144 , patchRcPathCsh 145 , tcsh 146 }: 147 runCommandLocal "patch-rc-path-csh-test" 148 { 149 nativeBuildInputs = [ 150 patchRcPathCsh 151 tcsh 152 ]; 153 meta = { 154 description = "Package test of patchActivateCsh"; 155 inherit (patchRcPathCsh.meta) maintainers; 156 }; 157 } 158 '' 159 set -eu -o pipefail 160 161 162 # Test patching a blank file 163 164 echo > blank.csh 165 166 echo "Generating blank_patched.csh from blank.csh" 167 cp blank.csh blank_patched.csh 168 patchRcPathCsh blank_patched.csh "$PWD/delta:$PWD/foxtrot" 169 170 echo "Testing in Csh if blank.csh and blank_patched.csh modifies PATH the same way" 171 tcsh -e ${./test-sourcing-csh} blank.csh blank_patched.csh 172 173 174 # Test patching silent_hello file 175 176 echo "hello > /dev/null" > silent_hello.csh 177 178 echo "Generating silent_hello_patched.csh from silent_hello.csh" 179 cp silent_hello.csh silent_hello_patched.csh 180 patchRcPathCsh silent_hello_patched.csh "${hello}/bin" 181 182 echo "Testing in Csh if silent_hello_patched.csh get sourced without errer" 183 tcsh -e -c "source silent_hello_patched.csh" 184 185 186 # Generate the sample source 187 188 substitute ${./sample_source.csh.in} sample_source.csh --replace @sed@ ${gnused}/bin/sed 189 chmod u+rw sample_source.csh 190 191 192 # Test patching the sample source 193 194 echo "Generating sample_source_patched.csh from sample_source.csh" 195 cp sample_source.csh sample_source_patched.csh 196 chmod u+w sample_source_patched.csh 197 patchRcPathCsh sample_source_patched.csh "$PWD/delta:$PWD/foxtrot" 198 199 echo "Testing in Csh if sample_source.csh and sample_source_patched.csh modifies PATH the same way" 200 tcsh -e ${./test-sourcing-csh} sample_source.csh sample_source_patched.csh 201 202 203 # Test double-patching the sample source 204 205 echo "Patching again sample_source_patched.csh from sample_source.csh" 206 patchRcPathCsh sample_source_patched.csh "$PWD/foxtrot:$PWD/golf" 207 208 echo "Testing in Csh if sample_source.csh and sample_source_patched.csh modifies PATH the same way" 209 tcsh -e ${./test-sourcing-csh} sample_source.csh sample_source_patched.csh 210 211 212 # Create a dummy output 213 touch "$out" 214 '' 215 ) 216 { }; 217 218 219 220 test-fish = callPackage 221 ( 222 { lib 223 , runCommandLocal 224 , fish 225 , hello 226 , patchRcPathFish 227 }: 228 runCommandLocal "patch-rc-path-fish-test" 229 { 230 nativeBuildInputs = [ 231 fish 232 patchRcPathFish 233 ]; 234 meta = { 235 description = "Package test of patchActivateFish"; 236 inherit (patchRcPathFish.meta) maintainers; 237 }; 238 } 239 '' 240 set -eu -o pipefail 241 242 243 # Test patching a blank file 244 245 echo > blank.fish 246 247 echo "Generating blank_patched.fish from blank.fish" 248 cp blank.fish blank_patched.fish 249 patchRcPathFish blank_patched.fish "$PWD/delta:$PWD/foxtrot" 250 251 echo "Testing in Fish if blank.fish and blank_patched.fish modifies PATH the same way" 252 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 253 HOME="$HOME_TEMP" fish ${./test-sourcing-fish} blank.fish blank_patched.fish 254 rm -r "$HOME_TEMP" 255 256 257 # Test patching silent_hello file 258 259 echo "hello > /dev/null" > silent_hello.fish 260 261 echo "Generating silent_hello_patched.fish from silent_hello.fish" 262 cp silent_hello.fish silent_hello_patched.fish 263 patchRcPathFish silent_hello_patched.fish "${hello}/bin" 264 265 echo "Testing in Fish if silent_hello_patched.fish get sourced without error" 266 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 267 HOME="$HOME_TEMP" fish -c "source silent_hello_patched.fish" 268 rm -r "$HOME_TEMP" 269 270 271 # Test patching the sample source 272 273 cp ${./sample_source.fish} sample_source_patched.fish 274 chmod u+w sample_source_patched.fish 275 276 echo "Generating sample_source_patched.fish from ${./sample_source.fish}" 277 patchRcPathFish sample_source_patched.fish "$PWD/delta:$PWD/foxtrot" 278 echo "Testing in Fish if sample_source.fish and sample_source_patched.fish modifies PATH the same way" 279 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 280 HOME="$HOME_TEMP" fish ${./test-sourcing-fish} ${./sample_source.fish} sample_source_patched.fish 281 rm -r "$HOME_TEMP" 282 283 284 # Test double-patching the sample source 285 286 echo "Patching again sample_source_patched.fish from ${./sample_source.fish}" 287 patchRcPathFish sample_source_patched.fish "$PWD/foxtrot:$PWD/golf" 288 289 echo "Testing in Fish if sample_source.fish and sample_source_patched.fish modifies PATH the same way" 290 HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)" 291 HOME="$HOME_TEMP" fish ${./test-sourcing-fish} ${./sample_source.fish} sample_source_patched.fish 292 rm -r "$HOME_TEMP" 293 294 295 # Create a dummy output 296 touch "$out" 297 '' 298 ) 299 { }; 300 301 302 303 test-posix = callPackage 304 ( 305 { lib 306 , runCommandLocal 307 , bash 308 , dash 309 , gnused 310 , hello 311 , ksh 312 , patchRcPathPosix 313 , shellcheck 314 }: 315 runCommandLocal "patch-rc-path-posix-test" 316 { 317 nativeBuildInputs = [ 318 bash 319 dash 320 ksh 321 patchRcPathPosix 322 shellcheck 323 ]; 324 meta = { 325 description = "Package test of patchActivatePosix"; 326 inherit (patchRcPathPosix.meta) maintainers; 327 }; 328 } 329 '' 330 set -eu -o pipefail 331 332 333 # Check the setup hook script 334 335 echo "Running shellcheck against ${./test-sourcing-posix}" 336 shellcheck -s sh --exclude SC1090 ${./test-sourcing-posix} 337 shellcheck -s dash --exclude SC1090 ${./test-sourcing-posix} 338 339 340 # Test patching a blank file 341 342 echo > blank.sh 343 344 echo "Generating blank_patched.sh from blank.sh" 345 cp blank.sh blank_patched.sh 346 patchRcPathPosix blank_patched.sh "$PWD/delta:$PWD/foxtrot" 347 348 echo "Running shellcheck against blank_patched.sh" 349 shellcheck -s sh blank_patched.sh 350 shellcheck -s dash blank_patched.sh 351 352 echo "Testing in Bash if blank.sh and blank_patched.sh modifies PATH the same way" 353 bash --posix ${./test-sourcing-posix} ./blank.sh ./blank_patched.sh 354 355 echo "Testing in Dash if blank.sh and blank_patched.sh modifies PATH the same way" 356 dash ${./test-sourcing-posix} ./blank.sh ./blank_patched.sh 357 358 echo "Testing in Ksh if ./blank.sh and ./blank_patched.sh modifies PATH the same way" 359 ksh ${./test-sourcing-posix} "$PWD/blank.sh" "$PWD/blank_patched.sh" 360 361 362 # Test patching silent_hello file 363 364 echo "hello > /dev/null" > silent_hello.sh 365 366 echo "Generating silent_hello_patched.sh from silent_hello.sh" 367 cp silent_hello.sh silent_hello_patched.sh 368 patchRcPathPosix silent_hello_patched.sh "${hello}/bin" 369 370 echo "Running shellcheck against silent_hello_patched.sh" 371 shellcheck -s sh silent_hello_patched.sh 372 shellcheck -s dash silent_hello_patched.sh 373 374 echo "Testing in Bash if silent_hello_patched.sh get sourced without error" 375 bash --posix -eu -c ". ./silent_hello_patched.sh" 376 377 echo "Testing in Dash if silent_hello_patched.sh get sourced without error" 378 dash -eu -c ". ./silent_hello_patched.sh" 379 380 echo "Testing in Ksh if silent_hello_patched.sh get sourced without error" 381 ksh -eu -c ". $PWD/silent_hello_patched.sh" 382 383 384 # Generate the sample source "$PWD/delta:$PWD/foxtrot" "$PWD/delta:$PWD/foxtrot" 385 386 substitute ${./sample_source.sh.in} sample_source.sh --replace @sed@ ${gnused}/bin/sed 387 chmod u+rw sample_source.sh 388 389 390 # Check the sample source 391 392 echo "Running shellcheck against sample_source.sh" 393 shellcheck -s sh sample_source.sh 394 shellcheck -s dash sample_source.sh 395 396 397 # Test patching the sample source 398 399 echo "Generating sample_source_patched.sh from sample_source.sh" 400 cp sample_source.sh sample_source_patched.sh 401 chmod u+w sample_source_patched.sh 402 patchRcPathPosix sample_source_patched.sh "$PWD/delta:$PWD/foxtrot" 403 404 echo "Running shellcheck against sample_source_patched.sh" 405 shellcheck -s sh sample_source_patched.sh 406 shellcheck -s dash sample_source_patched.sh 407 408 echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 409 bash --posix ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 410 411 echo "Testing in Dash if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 412 dash ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 413 414 echo "Testing in Ksh if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 415 ksh ${./test-sourcing-posix} "$PWD/sample_source.sh" "$PWD/sample_source_patched.sh" 416 417 418 # Test double-patching the sample source 419 420 echo "Patching again sample_source_patched.sh" 421 patchRcPathPosix sample_source_patched.sh "$PWD/foxtrot:$PWD/golf" 422 423 echo "Running shellcheck against sample_source_patched.sh" 424 shellcheck -s sh sample_source_patched.sh 425 shellcheck -s dash sample_source_patched.sh 426 427 echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way" 428 bash --posix ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 429 430 echo "Testing in Dash if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 431 dash ${./test-sourcing-posix} "./sample_source.sh" "./sample_source_patched.sh" 432 433 echo "Testing in Ksh if sample_source.sh and sample_source_patched.sh modifies PATH the same way" 434 ksh ${./test-sourcing-posix} "$PWD/sample_source.sh" "$PWD/sample_source_patched.sh" 435 436 437 # Create a dummy output 438 touch "$out" 439 '' 440 ) 441 { }; 442}