aboutsummaryrefslogtreecommitdiffstats
path: root/tools/node_modules/expresso/deps/jscoverage/tests/fatal.sh
blob: 90b8d94462803443fb2e5243d8aae286390f6cfa (plain)
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
#!/bin/sh
#    fatal.sh - test various fatal errors
#    Copyright (C) 2007, 2008 siliconforks.com
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

set -e

trap 'rm -fr DIR DIR2 OUT ERR' 1 2 3 15

export PATH=.:..:$PATH

rm -fr DIR DIR2

$VALGRIND jscoverage javascript-xml DIR > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr javascript-xml.expected.err ERR

rm -fr DIR

$VALGRIND jscoverage javascript-invalid DIR > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr javascript-invalid.expected.err ERR

rm -fr DIR

$VALGRIND jscoverage javascript-setter DIR > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr javascript-setter.expected.err ERR

rm -fr DIR

$VALGRIND jscoverage 1 2 3 > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr too-many-arguments.expected.err ERR

rm -fr DIR

$VALGRIND jscoverage --no-instrument > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr no-instrument-requires-argument.expected.err ERR

$VALGRIND jscoverage --exclude > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr exclude-requires-argument.expected.err ERR

$VALGRIND jscoverage --encoding > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
diff --strip-trailing-cr encoding-requires-argument.expected.err ERR

# first arg does not exist
rm -f foo
$VALGRIND jscoverage foo bar > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
# diff --strip-trailing-cr source-does-not-exist.expected.err ERR

# first arg is file
touch foo
$VALGRIND jscoverage foo bar > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
# diff --strip-trailing-cr source-is-file.expected.err ERR
rm foo

# second arg is file
rm -fr bar
touch bar
$VALGRIND jscoverage javascript bar > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
# diff --strip-trailing-cr destination-is-file.expected.err ERR
rm bar

# second arg is directory, but not from previous run
rm -fr bar
mkdir bar
touch bar/foo
$VALGRIND jscoverage javascript bar > OUT 2> ERR && exit 1
test ! -s OUT
test -s ERR
# diff --strip-trailing-cr destination-is-existing-directory.expected.err ERR
rm -fr bar

# huge JavaScript file
mkdir -p DIR
perl -e 'for (1 .. 65536) {print "x = $_\n";}' > DIR/big.js
$VALGRIND jscoverage DIR DIR2 > OUT 2> ERR && exit 1
echo 'jscoverage: file big.js contains more than 65,535 lines' | diff --strip-trailing-cr - ERR

rm -fr DIR DIR2 OUT ERR