test.sh 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
  1. #!/bin/sh
  2. # Test cases for exists.sh
  3. # Copyright 2019-2020, 2022 orbea
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. IFS='
  23. '
  24. \unset -f command printf unalias 2>/dev/null
  25. \unalias -a 2>/dev/null
  26. PATH="$(command -p getconf PATH):$PATH"
  27. LC_ALL=C; export LC_ALL
  28. set -euf
  29. COMMAND=
  30. FULLRUN=
  31. TESTSHELL=
  32. VAR=
  33. VERBOSE=
  34. WRAPPER=
  35. usage='test.sh - Test framework for exists.sh.
  36. Usage: test.sh [OPTIONS]
  37. -f, --full, Run all tests including very slow tests.
  38. -h, --help, Show this help message.
  39. -s, --shell, Path of the shell.
  40. -v, --verbose, Verbose logging.
  41. -w, --wrapper, Select tests to run.
  42. Supported tests:
  43. command, exists (default), which'
  44. chkscript () {
  45. case "$1" in
  46. command|exists|which ) WRAPPER="$1" ;;
  47. * ) die 1 "Unrecognized script '$1.sh', use -h for help." ;;
  48. esac
  49. }
  50. chkvar () {
  51. case "$1" in
  52. '' ) die 1 "Unrecognized option '$2', use -h for help." ;;
  53. WRAPPER ) chkscript "$2"; VAR= ;;
  54. * ) eval "$VAR=\"$2\""; VAR= ;;
  55. esac
  56. }
  57. die () {
  58. ret="$1"; shift
  59. case "$ret" in
  60. : ) printf %s\\n "$@" >&2; return 0 ;;
  61. 0 ) printf %s\\n "$@" ;;
  62. * ) printf %s\\n "$@" >&2 ;;
  63. esac
  64. exit "$ret"
  65. }
  66. for flag do
  67. case "$flag" in
  68. '' ) : ;;
  69. -- ) break ;;
  70. -f|--full ) FULLRUN=1 ;;
  71. -h|--help ) die 0 "$usage" ;;
  72. -s|--shell ) VAR=TESTSHELL ;;
  73. -v|--verbose ) VERBOSE=1; VAR= ;;
  74. -w|--wrapper ) VAR=WRAPPER ;;
  75. -* ) die 1 "Unrecognized option '$flag', use -h for help." ;;
  76. * ) chkvar "$VAR" "$flag" ;;
  77. esac
  78. done
  79. if [ ! -x "${TESTSHELL:=/bin/sh}" ] || [ ! -f "$TESTSHELL" ]; then
  80. die 1 "ERROR: Shell '$TESTSHELL' is not an executable file."
  81. fi
  82. checkfile () {
  83. [ -z "$skip" ] || return 0
  84. fail=0
  85. v=2
  86. # Some shells do not have a builtin printf and $PATH is unset
  87. printf_hack "${NEWPATH:=tests}"
  88. case "$NEWPATH" in
  89. __empty__ ) PATH= ;;
  90. __unset__ ) unset PATH ;;
  91. * ) PATH="$NEWPATH" ;;
  92. esac
  93. if [ -n "${1+x}" ]; then
  94. CMD="$("$TESTSHELL" -- "$rootdir"/$WRAPPER.sh "${@:-}")" || fail=1
  95. else
  96. CMD="$("$TESTSHELL" -- "$rootdir"/$WRAPPER.sh)" || fail=1
  97. fi
  98. export PATH="$ORIGPATH"
  99. NEWPATH=
  100. if [ $fail -lt 1 ] && [ "${CMD}" = "${test:-}" ]; then
  101. v=0
  102. elif [ $fail -gt 0 ] && [ "${CMD}" = "${test:-}" ]; then
  103. v=1
  104. fi
  105. log "output = $CMD" "match = ${test:-}" "input = ${@:-}" "result = $fail"
  106. set +f
  107. rm -rf -- tests/*
  108. set -f
  109. }
  110. makefile () {
  111. [ -z "$skip" ] || return 0
  112. while [ $# -gt 0 ]; do
  113. file="${1%:*}"
  114. perm="${1##*:}"
  115. shift
  116. [ "$file" = "${file%/*}" ] || mkdir -p "tests/${file%/*}"
  117. touch "tests/$file"
  118. chmod "$perm" "tests/$file"
  119. if [ -x "tests/$file" ] && [ -f "tests/$file" ]; then
  120. printf %s\\n "$rootdir/tests/$file"
  121. fi
  122. done
  123. }
  124. printf_hack () {
  125. case "$1" in
  126. __empty__|__unset__ ) p=':.' ;;
  127. * ) p=":$1" ;;
  128. esac
  129. while [ "$p" != "${p%:*}" ]; do
  130. dir="${p##*:}"
  131. if [ -d "${dir#:}" ]; then
  132. cp -- "$rootdir"/scripts/printf "${p##*:}/"
  133. chmod 0755 "${p##*:}/printf"
  134. break
  135. fi
  136. p="${p%:*}"
  137. done
  138. }
  139. result () {
  140. case "$1" in
  141. 0 ) result=PASS ;;
  142. 1 ) result=FAIL ;;
  143. esac
  144. if [ -n "$skip" ]; then
  145. printf %s\\n "SKIP - $2 || $result" >&2
  146. shift 2
  147. [ -z "${1+x}" ] || log "$@" >&2
  148. elif [ "$v" = "$1" ]; then
  149. printf %s\\n "PASS - $2 || $result"
  150. else
  151. printf %s\\n "FAIL - $2 || $result" >&2
  152. fi
  153. }
  154. settest () { test="$(printf %s\\n "$@")"; }
  155. quit () { err=$?; rm -f ./printf; rm -rf ./tests/; }
  156. case "$VERBOSE" in
  157. 1 ) log () { printf %s\\n "$@"; } ;;
  158. * ) log () { :; } ;;
  159. esac
  160. # Test if the command builtin accepts multiple arguments with -v
  161. if [ "$WRAPPER" = command ] && "$TESTSHELL" scripts/command-args-test.sh; then
  162. COMMAND=1
  163. # Test if the command builtin exits on the first missing executable with -v
  164. if "$TESTSHELL" scripts/command-args2-test.sh; then
  165. COMMAND=2
  166. fi
  167. fi
  168. # HACK for broken shells like posh and Slackware ash.
  169. if "$TESTSHELL" scripts/pwd-test.sh "$(pwd)" >/dev/null 2>&1; then
  170. retpwd () { pwd; }
  171. else
  172. retpwd () { pwd -P; }
  173. fi
  174. if [ "$0" != "${0%/*}" ]; then
  175. rootdir="$(cd -- "${0%/*}/" && retpwd)"
  176. cd -- "$rootdir"
  177. else
  178. rootdir="$(retpwd)"
  179. fi
  180. NEWPATH=
  181. ORIGPATH="$PATH"
  182. WRAPPER="${WRAPPER:-exists}"
  183. #########################
  184. #### Shell bug tests ####
  185. #########################
  186. skip=
  187. SKIP_EMPTY_PATH=
  188. SKIP_UNSET_PATH=
  189. # Test if an empty PATH variable is replaced
  190. # This happens with ksh93-20191228_5abcbd06 in Slackware
  191. if PATH= "$TESTSHELL" scripts/path-empty-test.sh; then
  192. SKIP_EMPTY_PATH=1
  193. fi
  194. # Test if an unset PATH variable is replaced
  195. # This happens with all shells other than yash
  196. unset PATH
  197. if "$TESTSHELL" scripts/path-empty-test.sh; then
  198. SKIP_UNSET_PATH=1
  199. fi
  200. export PATH="$ORIGPATH"
  201. ##########################
  202. #### Tests start here ####
  203. ##########################
  204. rm -rf tests
  205. trap 'quit; trap - EXIT; exit $err' EXIT INT
  206. mkdir tests
  207. # test an executable file - pass
  208. (
  209. test="$(makefile testfile:0755)"
  210. checkfile testfile
  211. result 0 'Executable File'
  212. )
  213. # test a non-executable file - fail
  214. (
  215. test="$(makefile testfile:0644)"
  216. checkfile testfile
  217. result 1 'Non-executable File'
  218. )
  219. # test $0 as an executable file - pass
  220. (
  221. test="$rootdir/$0"
  222. NEWPATH="$rootdir"
  223. checkfile "$0"
  224. result 0 "\$0 Executable File"
  225. )
  226. # test an executable file with a trailing forward slash - fail
  227. (
  228. test="$(makefile testfile:0755)"
  229. test=
  230. checkfile testfile/
  231. result 1 'Executable File with a Trailing Forward Slash'
  232. )
  233. # test an non-executable file with a trailing forward slash - fail
  234. (
  235. test="$(makefile testfile:0644)"
  236. checkfile testfile/
  237. result 1 'Non-executable File with a Trailing Forward Slash'
  238. )
  239. # test an executable file with a colon - pass
  240. (
  241. test="$(makefile test:file:0755)"
  242. checkfile test:file
  243. result 0 'Executable File with a Colon'
  244. )
  245. # test an executable file with a space - pass
  246. (
  247. test="$(makefile test\ file:0755)"
  248. checkfile test\ file
  249. result 0 'Executable File with a Space'
  250. )
  251. # test an executable file with a backslash - pass
  252. (
  253. test="$(makefile test\\file:0755)"
  254. checkfile test\\file
  255. result 0 'Executable File with a Backslash'
  256. )
  257. # test an executable file with a dollar sign - pass
  258. (
  259. test="$(makefile test\$file:0755)"
  260. checkfile test\$file
  261. result 0 'Executable File with a Dollar Sign'
  262. )
  263. # test an executable file with a grave - pass
  264. (
  265. test="$(makefile test\`file:0755)"
  266. checkfile test\`file
  267. result 0 'Executable File with a Grave'
  268. )
  269. # test an executable file with a wildcard sign - pass
  270. (
  271. test="$(makefile test\*file:0755)"
  272. checkfile test\*file
  273. result 0 'Executable File with a Wildcard Sign - 1'
  274. )
  275. (
  276. test="$(makefile test\*file:0755 test1file:0755)"
  277. settest "$rootdir"/tests/test\*file
  278. checkfile test\*file
  279. result 0 'Executable File with a Wildcard Sign - 2'
  280. )
  281. (
  282. test="$(makefile test\*file:0755 test1file:0755)"
  283. settest "$rootdir"/tests/test\*file
  284. cd tests/
  285. NEWPATH="$rootdir/tests"
  286. checkfile test\*file
  287. result 0 'Executable File with a Wildcard Sign - 3'
  288. )
  289. # test an executable file with a single quote - pass
  290. (
  291. test="$(makefile test\'file:0755)"
  292. checkfile test\'file
  293. result 0 'Executable File with a Single Quote'
  294. )
  295. # test an executable file with a double quote - pass
  296. (
  297. test="$(makefile test\"file:0755)"
  298. checkfile test\"file
  299. result 0 'Executable File with a Double Quote'
  300. )
  301. # test an executable file with mixed quotes - pass
  302. (
  303. test="$(makefile \"test\'file:0755)"
  304. checkfile \"test\'file
  305. result 0 'Executable File with Mixed Quotes'
  306. )
  307. # test an executable file as a dash - pass
  308. (
  309. test="$(makefile -:0755)"
  310. checkfile -- -
  311. result 0 'Executable File as a Dash - 1'
  312. )
  313. (
  314. test="$(makefile --:0755)"
  315. checkfile -- --
  316. result 0 'Executable File as a Dash - 2'
  317. )
  318. (
  319. test="$(makefile ---:0755)"
  320. checkfile -- ---
  321. result 0 'Executable File as a Dash - 3'
  322. )
  323. # test an executable file prefixed with a dash - pass
  324. (
  325. test="$(makefile -testfile:0755)"
  326. checkfile -- -testfile
  327. result 0 'Executable File Prefixed with a Dash - 1'
  328. )
  329. (
  330. test="$(makefile --testfile:0755)"
  331. checkfile -- --testfile
  332. result 0 'Executable File Prefixed with a Dash - 2'
  333. )
  334. (
  335. test="$(makefile ---testfile:0755)"
  336. checkfile -- ---testfile
  337. result 0 'Executable File Prefixed with a Dash - 3'
  338. )
  339. # test an executable file as a symlink - pass
  340. (
  341. test="$(makefile testfile1:0755)"
  342. settest "$rootdir"/tests/testfile2
  343. ln -s "$rootdir/tests/testfile1" "$rootdir/tests/testfile2"
  344. checkfile testfile2
  345. result 0 'Executable File as as Symlink'
  346. )
  347. # test and non-executable file as a symlink - fail
  348. (
  349. test="$(makefile testfile1:0644)"
  350. ln -s "$rootdir/tests/testfile1" "$rootdir/tests/testfile2"
  351. checkfile testfile2
  352. result 1 'Non-executable File as as Symlink'
  353. )
  354. # test an absolute file path - pass
  355. (
  356. test="$(makefile testfile:0755)"
  357. checkfile "$rootdir/tests/testfile"
  358. result 0 'Absolute File Path'
  359. )
  360. # test an absolute file path with a double forward slash - pass
  361. (
  362. test="$(makefile foobar//testfile:0755)"
  363. checkfile "$rootdir/tests/foobar//testfile"
  364. result 0 'Absolute File Path with a Double Forward Slash'
  365. )
  366. # test an absolute file path with a colon - pass
  367. (
  368. test="$(makefile foo:bar/testfile:0755)"
  369. checkfile "$rootdir/tests/foo:bar/testfile"
  370. result 0 'Absolute File Path with a Colon'
  371. )
  372. # test an absolute file path with spaces - pass
  373. (
  374. test="$(makefile foo\ bar/test\ file:0755)"
  375. checkfile "$rootdir/tests/foo bar/test file"
  376. result 0 'Absolute File Path with Spaces'
  377. )
  378. # test a relative file path - pass
  379. (
  380. test="$(makefile testfile:0755)"
  381. checkfile tests/testfile
  382. result 0 'Relative File Path - 1'
  383. )
  384. (
  385. test="$(makefile testfile:0755)"
  386. settest "$rootdir"/./tests/testfile
  387. checkfile ./tests/testfile
  388. result 0 'Relative File Path - 2'
  389. )
  390. # test a relative file path with a double forward slash - pass
  391. (
  392. test="$(makefile foobar//testfile:0755)"
  393. checkfile tests/foobar//testfile
  394. result 0 'Relative File Path with a Double Forward Slash - 1'
  395. )
  396. (
  397. test="$(makefile foobar//testfile:0755)"
  398. settest "$rootdir"/./tests/foobar//testfile
  399. checkfile ./tests/foobar//testfile
  400. result 0 'Relative File Path with a Double Forward Slash - 2'
  401. )
  402. # test a relative file path with a colon - pass
  403. (
  404. test="$(makefile foo:bar/testfile:0755)"
  405. checkfile tests/foo:bar/testfile
  406. result 0 'Relative File Path with a Colon - 1'
  407. )
  408. (
  409. test="$(makefile foo:bar/testfile:0755)"
  410. settest "$rootdir"/./tests/foo:bar/testfile
  411. checkfile ./tests/foo:bar/testfile
  412. result 0 'Relative File Path with a Colon - 2'
  413. )
  414. # test a relative file path with spaces - pass
  415. (
  416. test="$(makefile foo\ bar/test\ file:0755)"
  417. checkfile tests/foo\ bar/test\ file
  418. result 0 'Relative File Path with Spaces - 1'
  419. )
  420. (
  421. test="$(makefile foo\ bar/test\ file:0755)"
  422. settest "$rootdir"/./tests/foo\ bar/test\ file
  423. checkfile ./tests/foo\ bar/test\ file
  424. result 0 'Relative File Path with Spaces - 2'
  425. )
  426. # test first directory in $PATH - pass
  427. (
  428. test="$(makefile local/bin/testfile1:0755)"
  429. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  430. checkfile testfile1
  431. result 0 "First Directory in \$PATH - 1"
  432. )
  433. (
  434. test="$(makefile local/bin/testfile1:0755 bin/testfile2:0755 \
  435. usr/bin/testfile3:0755)"
  436. settest "$rootdir"/tests/local/bin/testfile1
  437. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  438. checkfile testfile1
  439. result 0 "First Directory in \$PATH - 2"
  440. )
  441. # test middle directory in $PATH - pass
  442. (
  443. test="$(makefile bin/testfile2:0755)"
  444. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  445. checkfile testfile2
  446. result 0 "Middle Directory in \$PATH - 1"
  447. )
  448. (
  449. test="$(makefile local/bin/testfile1:0755 bin/testfile2:0755 \
  450. usr/bin/testfile3:0755)"
  451. settest "$rootdir"/tests/bin/testfile2
  452. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  453. checkfile testfile2
  454. result 0 "Middle Directory in \$PATH - 2"
  455. )
  456. # test final directory in $PATH - pass
  457. (
  458. test="$(makefile usr/bin/testfile3:0755)"
  459. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  460. checkfile testfile3
  461. result 0 "Final Directory in \$PATH - 1"
  462. )
  463. (
  464. test="$(makefile local/bin/testfile1:0755 bin/testfile2:0755 \
  465. usr/bin/testfile3:0755)"
  466. settest "$rootdir"/tests/usr/bin/testfile3
  467. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  468. checkfile testfile3
  469. result 0 "Final Directory in \$PATH - 2"
  470. )
  471. # test matching directory and file names - pass
  472. (
  473. test="$(makefile tests:0755)"
  474. checkfile tests
  475. result 0 'Matching Directory and File Name - Executable'
  476. )
  477. # test matching directory and file names - fail
  478. (
  479. test="$(makefile tests:0644)"
  480. checkfile tests
  481. result 1 'Matching Directory and File Name - Non-Executable'
  482. )
  483. # test a directory - fail
  484. (
  485. mkdir tests/testdir
  486. checkfile testdir
  487. result 1 'Directory is not a File'
  488. )
  489. (
  490. mkdir tests/tests
  491. checkfile tests
  492. result 1 'Directory is not a File - Matching Directory and Path Name'
  493. )
  494. (
  495. mkdir tests/testdir1 tests/testdir2 tests/testdir3
  496. checkfile testdir1 testdir2 testdir3
  497. result 1 'Multiple Directories are not Files'
  498. )
  499. # test a missing file - fail
  500. (
  501. checkfile testfile
  502. result 1 'Missing File'
  503. )
  504. # test a wildcard with no files - fail
  505. (
  506. cd tests/
  507. set +f
  508. checkfile *
  509. set -f
  510. result 1 'Wildcard Sign with no Files'
  511. )
  512. # test the working directory with an executable file - pass
  513. (
  514. test="$(makefile testfile:0755)"
  515. NEWPATH=.
  516. cd tests
  517. settest "$rootdir"/tests/./testfile
  518. checkfile testfile
  519. result 0 'Working Directory with an Executable File'
  520. )
  521. # test the working directory with an executable file - fail
  522. (
  523. test="$(makefile testfile:0755)"
  524. NEWPATH=.
  525. test=
  526. checkfile testfile
  527. result 1 'Working Directory with an Executable File'
  528. )
  529. # test the working directory with a non-executable file - fail
  530. (
  531. test="$(makefile testfile:0644)"
  532. NEWPATH=.
  533. cd tests
  534. checkfile testfile
  535. result 1 'Working Directory with a Non-executable File'
  536. )
  537. # test the working directory with an executable absolute file path - pass
  538. (
  539. test="$(makefile testfile:0755)"
  540. NEWPATH=.
  541. cd tests
  542. checkfile "$rootdir"/tests/testfile
  543. result 0 'Working Directory with an Executable File Absolute Path - 1'
  544. )
  545. (
  546. test="$(makefile testfile:0755)"
  547. NEWPATH=.
  548. checkfile "$rootdir"/tests/testfile
  549. result 0 'Working Directory with an Executable File Absolute Path - 2'
  550. )
  551. # test the working directory with an executable relative file path - pass
  552. (
  553. test="$(makefile testfile:0755)"
  554. NEWPATH=.
  555. checkfile tests/testfile
  556. result 0 'Working Directory with an Executable File Relative Path - 1'
  557. )
  558. (
  559. test="$(makefile testfile:0755)"
  560. NEWPATH=.
  561. cd tests
  562. settest "$rootdir"/tests/./testfile
  563. checkfile ./testfile
  564. result 0 'Working Directory with an Executable File Relative Path - 2'
  565. )
  566. # test the working directory with a non-executable absolute file path - fail
  567. (
  568. test="$(makefile testfile:0644)"
  569. NEWPATH=.
  570. checkfile "$rootdir"/testfile
  571. result 1 'Working Directory with a Non-executable File Absolute Path - 1'
  572. )
  573. (
  574. test="$(makefile testfile:0644)"
  575. NEWPATH=.
  576. cd tests
  577. checkfile "$rootdir"/testfile
  578. result 1 'Working Directory with a Non-executable File Absolute Path - 2'
  579. )
  580. # test the working directory with a non-executable relative file path - fail
  581. (
  582. test="$(makefile testfile:0644)"
  583. NEWPATH=.
  584. checkfile tests/testfile
  585. result 1 'Working Directory with a Non-executable File Relative Path - 1'
  586. )
  587. (
  588. test="$(makefile testfile:0644)"
  589. NEWPATH=.
  590. cd tests
  591. checkfile ./testfile
  592. result 1 'Working Directory with a Non-executable File Relative Path - 2'
  593. )
  594. # test an empty $PATH with an executable file - pass
  595. (
  596. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  597. test="$(makefile testfile:0755)"
  598. NEWPATH=__empty__
  599. cd tests
  600. checkfile testfile
  601. result 0 "Empty \$PATH with an Executable File" \
  602. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  603. )
  604. # test an empty $PATH with an executable file - fail
  605. (
  606. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  607. test="$(makefile testfile:0755)"
  608. NEWPATH=__empty__
  609. test=
  610. checkfile testfile
  611. result 1 "Empty \$PATH with an Executable File" \
  612. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  613. )
  614. # test an empty $PATH with a non-executable file - fail
  615. (
  616. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  617. test="$(makefile testfile:0644)"
  618. NEWPATH=__empty__
  619. cd tests
  620. checkfile testfile
  621. result 1 "Empty \$PATH with a Non-executable File - 1" \
  622. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  623. )
  624. (
  625. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  626. test="$(makefile testfile:0644)"
  627. NEWPATH=__empty__
  628. checkfile testfile
  629. result 1 "Empty \$PATH with a Non-executable File - 2" \
  630. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  631. )
  632. # test an empty $PATH with an executable absolute file path - pass
  633. (
  634. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  635. test="$(makefile testfile:0755)"
  636. NEWPATH=__empty__
  637. checkfile "$rootdir"/tests/testfile
  638. result 0 "Empty \$PATH with an Executable File Absolute Path" \
  639. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  640. )
  641. # test an empty $PATH with an executable relative file path - pass
  642. (
  643. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  644. test="$(makefile testfile:0755)"
  645. NEWPATH=__empty__
  646. checkfile tests/testfile
  647. result 0 "Empty \$PATH with an Executable File Relative Path - 1" \
  648. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  649. )
  650. (
  651. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  652. test="$(makefile testfile:0755)"
  653. NEWPATH=__empty__
  654. cd tests
  655. settest "$rootdir"/tests/./testfile
  656. checkfile ./testfile
  657. result 0 "Empty \$PATH with an Executable File Relative Path - 2" \
  658. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  659. )
  660. # test an empty $PATH with a non-executable absolute file path - fail
  661. (
  662. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  663. test="$(makefile testfile:0644)"
  664. NEWPATH=__empty__
  665. checkfile "$rootdir"/testfile
  666. result 1 "Empty \$PATH with a Non-executable File Absolute Path" \
  667. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  668. )
  669. # test an empty $PATH with a non-executable relative file path - fail
  670. (
  671. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  672. test="$(makefile testfile:0644)"
  673. NEWPATH=__empty__
  674. checkfile tests/testfile
  675. result 1 "Empty \$PATH with a Non-executable File Relative Path - 1" \
  676. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  677. )
  678. (
  679. [ -z "${SKIP_EMPTY_PATH}" ] || skip=1
  680. test="$(makefile testfile:0644)"
  681. NEWPATH=__empty__
  682. cd tests
  683. checkfile ./testfile
  684. result 1 "Empty \$PATH with a Non-executable File Relative Path - 2" \
  685. "With '$TESTSHELL' an empty PATH is helpfully replaced."
  686. )
  687. # test an unset $PATH with an executable file - fail
  688. (
  689. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  690. test="$(makefile testfile:0755)"
  691. NEWPATH=__unset__
  692. cd tests
  693. test=
  694. checkfile testfile
  695. result 1 "Unset \$PATH with an Executable File - 1" \
  696. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  697. )
  698. # test an unset $PATH with an executable file - fail
  699. (
  700. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  701. test="$(makefile testfile:0755)"
  702. NEWPATH=__unset__
  703. test=
  704. checkfile testfile
  705. result 1 "Unset \$PATH with an Executable File - 2" \
  706. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  707. )
  708. # test an unset $PATH with a non-executable file - fail
  709. (
  710. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  711. test="$(makefile testfile:0644)"
  712. NEWPATH=__unset__
  713. cd tests
  714. checkfile testfile
  715. result 1 "Unset \$PATH with a Non-executable File - 1" \
  716. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  717. )
  718. (
  719. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  720. test="$(makefile testfile:0644)"
  721. NEWPATH=__unset__
  722. checkfile testfile
  723. result 1 "Unset \$PATH with a Non-executable File - 2" \
  724. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  725. )
  726. # test an unset $PATH with an executable absolute file path - pass
  727. (
  728. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  729. test="$(makefile testfile:0755)"
  730. NEWPATH=__unset__
  731. checkfile "$rootdir"/tests/testfile
  732. result 0 "Unset \$PATH with an Executable File Absolute Path" \
  733. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  734. )
  735. # test an unset $PATH with an executable relative file path - pass
  736. (
  737. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  738. test="$(makefile testfile:0755)"
  739. NEWPATH=__unset__
  740. checkfile tests/testfile
  741. result 0 "Unset \$PATH with an Executable File Relative Path - 1" \
  742. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  743. )
  744. (
  745. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  746. test="$(makefile testfile:0755)"
  747. NEWPATH=__unset__
  748. cd tests
  749. settest "$rootdir"/tests/./testfile
  750. checkfile ./testfile
  751. result 0 "Unset \$PATH with an Executable File Relative Path - 2" \
  752. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  753. )
  754. # test an unset $PATH with a non-executable absolute file path - fail
  755. (
  756. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  757. test="$(makefile testfile:0644)"
  758. NEWPATH=__unset__
  759. checkfile "$rootdir"/testfile
  760. result 1 "Unset \$PATH with a Non-executable File Absolute Path" \
  761. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  762. )
  763. # test an unset $PATH with a non-executable relative file path - fail
  764. (
  765. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  766. test="$(makefile testfile:0644)"
  767. NEWPATH=__unset__
  768. checkfile tests/testfile
  769. result 1 "Unset \$PATH with a Non-executable File Relative Path - 1" \
  770. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  771. )
  772. (
  773. [ -z "${SKIP_UNSET_PATH}" ] || skip=1
  774. test="$(makefile testfile:0644)"
  775. NEWPATH=__unset__
  776. cd tests
  777. checkfile ./testfile
  778. result 1 "Unset \$PATH with a Non-executable File Relative Path - 2" \
  779. "With '$TESTSHELL' an unset PATH is helpfully replaced."
  780. )
  781. # test an empty argument - fail
  782. (
  783. checkfile ''
  784. result 1 'Empty Argument'
  785. )
  786. # test an unset argument - pass
  787. (
  788. checkfile
  789. result 0 'Unset Argument'
  790. )
  791. if [ "$WRAPPER" = exists ] || [ "$WRAPPER" = which ] || [ -n "$COMMAND" ]; then
  792. # test multiple executable files - pass
  793. (
  794. test="$(makefile testfile1:0755 testfile2:0755)"
  795. checkfile testfile1 testfile2
  796. result 0 'Multiple Executable Files - 1'
  797. )
  798. (
  799. test="$(makefile testfile1:0755 testfile2:0755 testfile3:0755)"
  800. checkfile testfile1 testfile2 testfile3
  801. result 0 'Multiple Executable Files - 2'
  802. )
  803. # test multiple non-executable files - pass
  804. (
  805. test="$(makefile testfile1:0644 testfile2:0644)"
  806. checkfile testfile1 testfile2
  807. result 1 'Multiple Non-executable Files - 1'
  808. )
  809. (
  810. test="$(makefile testfile1:0644 testfile2:0644 testfile3:0644)"
  811. checkfile testfile1 testfile2 testfile3
  812. result 1 'Multiple Non-executable Files - 2'
  813. )
  814. # test multiple missing files - fail
  815. (
  816. checkfile testfile1 testfile2
  817. result 1 'Multiple Missing Files - 1'
  818. )
  819. (
  820. checkfile testfile1 testfile2 testfile3
  821. result 1 'Multiple Missing Files - 2'
  822. )
  823. # test multiple executable and non-executable files - fail
  824. (
  825. test="$(makefile testfile1:0755 testfile2:0644)"
  826. settest "$rootdir"/tests/testfile1
  827. checkfile testfile1 testfile2
  828. result 1 'Multiple Executable and Non-Executable Files - 1'
  829. )
  830. (
  831. test="$(makefile testfile1:0755 testfile2:0755 testfile3:0644)"
  832. settest "$rootdir"/tests/testfile1 "$rootdir"/tests/testfile2
  833. checkfile testfile1 testfile2 testfile3
  834. result 1 'Multiple Executable and Non-Executable Files - 2'
  835. )
  836. # test an absolute file path with a wildcard - pass
  837. (
  838. test="$(makefile testfile1:0755 testfile2:0755 testfile3:0755)"
  839. settest "$rootdir/tests/testfile1" "$rootdir/tests/testfile2" \
  840. "$rootdir/tests/testfile3"
  841. set +f
  842. checkfile "$rootdir"/tests/test*
  843. set -f
  844. result 0 'Absolute File Path with a Wildcard'
  845. )
  846. # test multiple files and directories - fail
  847. (
  848. test="$(makefile testfile1:0755 testfile2:0755)"
  849. mkdir tests/testdir1 tests/testdir2
  850. settest "$rootdir"/tests/testfile1 "$rootdir"/tests/testfile2
  851. checkfile testfile1 testfile2 testdir1 testdir2
  852. result 1 'Multiple Executable Files and Directories'
  853. )
  854. # test multiple present and missing files - fail
  855. (
  856. test="$(makefile testfile1:0755)"
  857. checkfile testfile1 testfile2
  858. result 1 'Multiple Present and Missing Files - 1'
  859. )
  860. (
  861. test="$(makefile testfile1:0755 testfile2:0755)"
  862. checkfile testfile1 testfile2 testfile3
  863. result 1 'Multiple Present and Missing Files - 2'
  864. )
  865. (
  866. test="$(makefile testfile1:0755 testfile2:0755 testfile3:0755)"
  867. checkfile testfile1 testfile2 testfile3 testifile4
  868. result 1 'Multiple Present and Missing Files - 3'
  869. )
  870. if [ "$WRAPPER" != command ] || [ "$COMMAND" = 2 ]; then
  871. (
  872. test="$(makefile testfile2:0755 testfile3:0755)"
  873. checkfile testfile1 testfile2 testfile3
  874. result 1 'Multiple Present and Missing Files - 4'
  875. )
  876. (
  877. test="$(makefile testfile1:0755 testfile3:0755)"
  878. checkfile testfile1 testfile2 testfile3
  879. result 1 'Multiple Present and Missing Files - 5'
  880. )
  881. # test multiple files and directories - fail
  882. (
  883. test="$(makefile testfile1:0644 testfile2:0755)"
  884. mkdir tests/testdir1 tests/testdir2
  885. settest "$rootdir"/tests/testfile2
  886. checkfile testfile1 testfile2 testdir1 testdir2
  887. result 1 'Multiple Executable Files, Non-executable Files and Directories'
  888. )
  889. # test multiple files in the $PATH with a wildcard - fail
  890. (
  891. test="$(makefile testfile1:0644 testfile2:0644 bin/testfile1:0755 \
  892. usr/bin/testfile2:0755)"
  893. settest "$rootdir"/tests/bin/testfile1 "$rootdir"/tests/usr/bin/testfile2
  894. cd tests/
  895. NEWPATH=bin:usr/bin
  896. set +f
  897. checkfile *
  898. set -f
  899. result 1 "Multiple Executable Files in the \$PATH with a Wildcard"
  900. )
  901. # test multiple files with dashes - fail
  902. (
  903. test="$(makefile --:0755 -testfile:0644 -:0755 --testfile:0755 ---:0644 \
  904. ---testfile:0755)"
  905. settest "$rootdir"/tests/-- "$rootdir"/tests/- "$rootdir"/tests/--testfile \
  906. "$rootdir"/tests/---testfile
  907. checkfile -- -- -testfile - --testfile --- ---testfile
  908. result 1 'Multiple files with dashes - 1'
  909. )
  910. (
  911. test="$(makefile --:0644 -testfile:0755 -:0644 --testfile:0644 ---:0755 \
  912. ---testfile:0644)"
  913. settest "$rootdir"/tests/-testfile "$rootdir"/tests/---
  914. checkfile -- -- -testfile - --testfile --- ---testfile
  915. result 1 'Multiple files with dashes - 2'
  916. )
  917. (
  918. test="$(makefile -testfile:0755 ---:0644 --testfile:0644 --:0755 \
  919. ---testfile:0755 -:0755)"
  920. settest "$rootdir"/tests/-testfile "$rootdir"/tests/-- \
  921. "$rootdir"/tests/---testfile "$rootdir"/tests/-
  922. checkfile -- -testfile --- --testfile -- ---testfile -
  923. result 1 'Multiple files with dashes - 3'
  924. )
  925. fi
  926. # test 100 executable files - pass
  927. (
  928. files1=
  929. files2=
  930. for i in $(seq 100); do
  931. files1="${files1} $i"
  932. files2="${files2} $i:0755"
  933. done
  934. eval "set -- $files2"
  935. test="$(makefile "$@")"
  936. eval "set -- $files1"
  937. checkfile "$@"
  938. result 0 '100 Executable Files'
  939. )
  940. # Very slow tests
  941. if [ "$FULLRUN" = 1 ]; then
  942. # test 1000 executable files - pass
  943. (
  944. files1=
  945. files2=
  946. for i in $(seq 1000); do
  947. files1="${files1} $i"
  948. files2="${files2} $i:0755"
  949. done
  950. eval "set -- $files2"
  951. test="$(makefile "$@")"
  952. eval "set -- $files1"
  953. checkfile "$@"
  954. result 0 '1000 Executable Files'
  955. )
  956. # test 10000 executable files - pass
  957. (
  958. files1=
  959. files2=
  960. for i in $(seq 10000); do
  961. files1="${files1} $i"
  962. files2="${files2} $i:0755"
  963. done
  964. eval "set -- $files2"
  965. test="$(makefile "$@")"
  966. eval "set -- $files1"
  967. checkfile "$@"
  968. result 0 '10000 Executable Files'
  969. )
  970. fi
  971. fi
  972. if [ "$WRAPPER" = exists ] || [ "$WRAPPER" = which ]; then
  973. # test --all - pass
  974. (
  975. test="$(makefile bin/testfile:0755 usr/bin/testfile:0755)"
  976. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  977. checkfile --all testfile
  978. result 0 'All matches with --all and executable files - 1'
  979. )
  980. (
  981. test="$(makefile bin/testfile:0755 usr/bin/testfile:0755)"
  982. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  983. checkfile -a testfile
  984. result 0 'All matches with --all and executable files - 2'
  985. )
  986. (
  987. test="$(makefile local/bin/testfile:0755 bin/testfile:0644 \
  988. usr/bin/testfile:0755)"
  989. settest "$rootdir"/tests/local/bin/testfile \
  990. "$rootdir"/tests/usr/bin/testfile
  991. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  992. checkfile --all testfile
  993. result 0 'All matches with --all and executable files - 3'
  994. )
  995. (
  996. test="$(makefile local/bin/testfile:0755 bin/testfile:0644 \
  997. usr/bin/testfile:0755)"
  998. settest "$rootdir"/tests/local/bin/testfile \
  999. "$rootdir"/tests/usr/bin/testfile
  1000. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1001. checkfile -a testfile
  1002. result 0 'All matches with --all and executable files - 4'
  1003. )
  1004. # test --all with non-exuectubable files - fail
  1005. (
  1006. test="$(makefile bin/testfile:0644 usr/bin/testfile:0644)"
  1007. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1008. checkfile --all testfile
  1009. result 1 'All matches with --all and non-executable files - 1'
  1010. )
  1011. (
  1012. test="$(makefile bin/testfile:0644 usr/bin/testfile:0644)"
  1013. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1014. checkfile -a testfile
  1015. result 1 'All matches with --all and non-executable files - 2'
  1016. )
  1017. # test executable files titled --all - pass
  1018. (
  1019. test="$(makefile --all:0755)"
  1020. checkfile -- --all
  1021. result 0 'Executable file titled --all - 1'
  1022. )
  1023. (
  1024. test="$(makefile -a:0755)"
  1025. checkfile -- -a
  1026. result 0 'Executable file titled --all - 2'
  1027. )
  1028. (
  1029. test="$(makefile bin/--all:0755 usr/bin/--all:0755)"
  1030. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1031. checkfile --all -- --all
  1032. result 0 'Executable file titled --all - 3'
  1033. )
  1034. (
  1035. test="$(makefile bin/-a:0755 usr/bin/-a:0755)"
  1036. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1037. checkfile -a -- -a
  1038. result 0 'Executable file titled --all - 4'
  1039. )
  1040. (
  1041. test="$(makefile bin/--all:0755 usr/bin/--all:0755)"
  1042. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1043. checkfile -a -- --all
  1044. result 0 'Executable file titled --all - 5'
  1045. )
  1046. (
  1047. test="$(makefile bin/-a:0755 usr/bin/-a:0755)"
  1048. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1049. checkfile --all -- -a
  1050. result 0 'Executable file titled --all - 6'
  1051. )
  1052. # test non-executable files titled --all - fail
  1053. (
  1054. test="$(makefile --all:0644)"
  1055. checkfile -- --all
  1056. result 1 'Non-executable file titled --all - 1'
  1057. )
  1058. (
  1059. test="$(makefile -a:0644)"
  1060. checkfile -- -a
  1061. result 1 'Non-executable file titled --all - 2'
  1062. )
  1063. (
  1064. test="$(makefile bin/--all:0644 usr/bin/--all:0644)"
  1065. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1066. checkfile --all -- --all
  1067. result 1 'Non-executable file titled --all - 3'
  1068. )
  1069. (
  1070. test="$(makefile bin/-a:0644 usr/bin/-a:0644)"
  1071. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1072. checkfile -a -- -a
  1073. result 1 'Non-executable file titled --all - 4'
  1074. )
  1075. (
  1076. test="$(makefile bin/--all:0644 usr/bin/--all:0644)"
  1077. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1078. checkfile -a -- --all
  1079. result 1 'Non-executable file titled --all - 5'
  1080. )
  1081. (
  1082. test="$(makefile bin/-a:0644 usr/bin/-a:0644)"
  1083. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1084. checkfile --all -- -a
  1085. result 1 'Non-executable file titled --all - 6'
  1086. )
  1087. # Invalid command-line with --all - pass
  1088. (
  1089. test="$(makefile --all:0755)"
  1090. test=
  1091. checkfile --all
  1092. result 0 'Invalid command-line with --all - 1'
  1093. )
  1094. (
  1095. test="$(makefile -a:0755)"
  1096. test=
  1097. checkfile -a
  1098. result 0 'Invalid command-line with --all - 2'
  1099. )
  1100. (
  1101. test="$(makefile bin/--all:0755 usr/bin/--all:0755)"
  1102. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1103. test=
  1104. checkfile --all --all
  1105. result 0 'Invalid command-line with --all - 3'
  1106. )
  1107. (
  1108. test="$(makefile bin/-a:0755 usr/bin/-a:0755)"
  1109. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1110. test=
  1111. checkfile -a -a
  1112. result 0 'Invalid command-line with --all - 4'
  1113. )
  1114. (
  1115. test="$(makefile bin/--all:0755 usr/bin/--all:0755)"
  1116. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1117. test=
  1118. checkfile -a --all
  1119. result 0 'Invalid command-line with --all - 5'
  1120. )
  1121. (
  1122. test="$(makefile bin/-a:0755 usr/bin/-a:0755)"
  1123. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1124. test=
  1125. checkfile --all -a
  1126. result 0 'Invalid command-line with --all - 6'
  1127. )
  1128. # test --all at the end of the commandline - pass
  1129. (
  1130. test="$(makefile bin/-a:0755 bin/testfile:0755 usr/bin/testfile:0755)"
  1131. settest "$rootdir"/tests/bin/testfile "$rootdir"/tests/bin/-a
  1132. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1133. checkfile testfile -a
  1134. result 0 'Executable files with --all at the end of the command-line - 1'
  1135. )
  1136. (
  1137. test="$(makefile bin/--all:0755 bin/testfile:0755 usr/bin/testfile:0755)"
  1138. settest "$rootdir"/tests/bin/testfile "$rootdir"/tests/bin/--all
  1139. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1140. checkfile testfile --all
  1141. result 0 'Executable files with --all at the end of the command-line - 2'
  1142. )
  1143. # test --all at the end of the commandline - fail
  1144. (
  1145. test="$(makefile bin/testfile:0755 usr/bin/testfile:0755)"
  1146. settest "$rootdir"/tests/bin/testfile
  1147. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1148. checkfile testfile -a
  1149. result 1 'Executable files with --all at the end of the command-line - 3'
  1150. )
  1151. (
  1152. test="$(makefile bin/testfile:0755 usr/bin/testfile:0755)"
  1153. settest "$rootdir"/tests/bin/testfile
  1154. NEWPATH=tests/local/bin:tests/bin:tests/usr/bin
  1155. checkfile testfile --all
  1156. result 1 'Executable files with --all at the end of the command-line - 4'
  1157. )
  1158. fi