Follow upstream changes -- rest
[git-darcs-import.git] / tests / issue538.sh
blob4ecff13635385af7a225e2b00bdff84b85744fd0
1 #!/bin/env bash
2 # A test for issue 538 - that an executable test script will run successfully if
3 # it is recorded with --set-scripts-executable.
5 set -ev
7 if echo $OS | grep -i windows; then
8 echo I do not know how to run a test program under windows
9 exit 0
12 function make_repo_with_test {
13 mkdir temp1 ; cd temp1 ; darcs init
14 echo "#!/bin/sh" > test.sh
15 echo "echo 'hello world'" >> test.sh
16 darcs add test.sh
17 darcs record --author=test@test -am test
18 darcs setpref test './test.sh'
21 # test record with --set-scripts-executable
22 rm -rf temp1
23 make_repo_with_test
24 touch blaat
25 darcs add blaat
26 if darcs record --set-scripts-executable -A test@test -am blaat ; then
27 echo "ok 1"
28 else
29 echo "not ok 1 recording second patch failed (because test failed?)"
30 exit 1
32 cd ..
34 # test record without --set-scripts-executable
35 rm -rf temp1
36 make_repo_with_test
37 touch blaat
38 darcs add blaat
39 if darcs record --dont-set-scripts-executable -A test@test -am blaat ; then
40 echo "not ok 2 recording second patch succeeded though test script should not be executable"
41 exit 1
42 else
43 echo "ok 2"
45 cd ..
47 # test amend-record with --set-scripts-executable
48 rm -rf temp1
49 make_repo_with_test
50 touch blaat
51 darcs add blaat
52 if echo y | darcs amend-record --set-scripts-executable -A test@test -a ; then
53 echo "ok 3"
54 else
55 echo "not ok 3 amending patch failed (because test failed?)"
56 exit 1
58 cd ..
60 # test amend-record without --set-scripts-executable
61 rm -rf temp1
62 make_repo_with_test
63 touch blaat
64 darcs add blaat
65 if echo y | darcs amend-record --dont-set-scripts-executable -A test@test -a /dev/null ; then
66 echo "not ok 4 amending patch succeeded even though --dont-set-scripts-executable specified"
67 exit 1
68 else
69 echo "ok 4"
71 cd ..
73 # trackdown with --set-scripts-executable
74 rm -rf temp1
75 make_repo_with_test
76 if darcs trackdown --set-scripts-executable | grep 'Success!' ; then
77 echo "ok 5"
78 else
79 echo "not ok 5 tracking down with --set-scripts-executable failed (because test failed?)"
80 exit 1
82 cd ..
84 # trackdown without --set-scripts-executable
85 rm -rf temp1
86 make_repo_with_test
87 if darcs trackdown --dont-set-scripts-executable | grep 'Noone passed the test!' ; then
88 echo "ok 6"
89 else
90 echo "not ok 6 tracking down did not find failure even though --dont-set-scripts-executable was given"
91 exit 1
93 cd ..
95 # check trackdown with files that become scripts during trackdown
96 rm -rf temp1
97 mkdir temp1 ; cd temp1 ; darcs init
98 echo "#!/bin/sh" > test.sh
99 echo "./helper.sh" >> test.sh
100 echo "#!/bin/sh" > helper.sh
101 echo "echo 'helper speaking'" >> helper.sh
102 darcs add test.sh
103 darcs add helper.sh
104 darcs record -am 'valid helper' -A test
105 echo 'this is definitely not a valid script' > helper.sh
106 darcs record -am 'invalid helper' -A test
107 darcs setpref test './test.sh'
108 darcs trackdown --set-scripts-executable > trackdown-out
109 if grep 'Test failed!' trackdown-out && grep 'Success!' trackdown-out ; then
110 echo "ok 7"
111 else
112 echo "not ok 7 either no failure or no success (both should occur)"
113 exit 1
115 cd ..
117 rm -rf temp1