File: issue538.sh

package info (click to toggle)
darcs 2.0.2-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 6,400 kB
  • ctags: 1,048
  • sloc: haskell: 24,937; perl: 9,736; sh: 3,369; ansic: 1,913; makefile: 17; xml: 14
file content (117 lines) | stat: -rw-r--r-- 3,085 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/env bash
# A test for issue 538 - that an executable test script will run successfully if
# it is recorded with --set-scripts-executable.

set -ev

if echo $OS | grep -i windows; then
    echo I do not know how to run a test program under windows
    exit 0
fi

function make_repo_with_test {
    mkdir temp1 ; cd temp1 ; darcs init
    echo "#!/bin/sh" > test.sh
    echo "echo 'hello world'" >> test.sh
    darcs add test.sh
    darcs record --author=test@test -am test
    darcs setpref test './test.sh'
}

# test record with --set-scripts-executable
rm -rf temp1
make_repo_with_test
touch blaat
darcs add blaat
if darcs record --set-scripts-executable -A test@test -am blaat ; then
    echo "ok 1"
else
    echo "not ok 1 recording second patch failed (because test failed?)"
    exit 1
fi
cd ..

# test record without --set-scripts-executable 
rm -rf temp1
make_repo_with_test
touch blaat
darcs add blaat
if darcs record --dont-set-scripts-executable -A test@test -am blaat ; then
    echo "not ok 2 recording second patch succeeded though test script should not be executable"
    exit 1
else
   echo "ok 2"
fi
cd ..

# test amend-record with --set-scripts-executable
rm -rf temp1
make_repo_with_test
touch blaat
darcs add blaat
if echo y | darcs amend-record --set-scripts-executable -A test@test -a ; then
    echo "ok 3"
else
    echo "not ok 3 amending patch failed (because test failed?)"
    exit 1
fi
cd ..

# test amend-record without --set-scripts-executable
rm -rf temp1
make_repo_with_test
touch blaat
darcs add blaat
if echo y | darcs amend-record --dont-set-scripts-executable -A test@test -a /dev/null ; then
    echo "not ok 4 amending patch succeeded even though --dont-set-scripts-executable specified"
    exit 1
else 
    echo "ok 4"
fi
cd ..

# trackdown with --set-scripts-executable
rm -rf temp1
make_repo_with_test
if darcs trackdown --set-scripts-executable | grep 'Success!' ; then
    echo "ok 5"
else
    echo "not ok 5 tracking down with --set-scripts-executable failed (because test failed?)"
    exit 1
fi
cd ..

# trackdown without --set-scripts-executable
rm -rf temp1
make_repo_with_test
if darcs trackdown --dont-set-scripts-executable | grep 'Noone passed the test!' ; then
    echo "ok 6"
else
    echo "not ok 6 tracking down did not find failure even though --dont-set-scripts-executable was given"
    exit 1
fi
cd ..

# check trackdown with files that become scripts during trackdown
rm -rf temp1
mkdir temp1 ; cd temp1 ; darcs init
echo "#!/bin/sh" > test.sh
echo "./helper.sh" >> test.sh
echo "#!/bin/sh" > helper.sh
echo "echo 'helper speaking'" >> helper.sh
darcs add test.sh
darcs add helper.sh
darcs record -am 'valid helper' -A test
echo 'this is definitely not a valid script' > helper.sh
darcs record -am 'invalid helper' -A test
darcs setpref test './test.sh'
darcs trackdown --set-scripts-executable > trackdown-out
if grep 'Test failed!' trackdown-out && grep 'Success!' trackdown-out ; then
    echo "ok 7"
else 
    echo "not ok 7 either no failure or no success (both should occur)"
    exit 1
fi
cd ..

rm -rf temp1