-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_tests.sh
executable file
·106 lines (81 loc) · 2.47 KB
/
run_tests.sh
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
#!/bin/bash
# A web-component-tester wrapper that does the plumbing necessary to get
# tests running.
set -e
# Test the context we're running in.
pushd "$(dirname "$0")"
export SRC_DIR="$PWD"
popd
echo SRC_DIR=$SRC_DIR
[ -d "$SRC_DIR" ]
[ -f "$SRC_DIR/polymer-resin.js" ]
export TEST_ROOT_DIR="$(mktemp -d "$TMPDIR"/wct_root.XXXXXXXXXX)"
[ -d "$TEST_ROOT_DIR" ]
# `copy_over $d $f` copies $f to the relative path $d/$f under the
# test root creating parent directories as necessary.
function copy_over() {
local D="$1"
local F="$2"
# Hard links make it possible to edit the file in the
# main directory and reload when running via
# $ run_tests -p -l chrome
mkdir -p "$(dirname "$TEST_ROOT_DIR"/"$D"/"$F")" \
&& ln "$F" "$TEST_ROOT_DIR"/"$D"/"$F"
}
pushd "$SRC_DIR"
for f in *test.{html,js} standalone/*.{html,js}
do
copy_over polymer-resin "$f"
done
# Generate a test/tests.html for wct to find that
# serves as a master test suite.
export TEST_SUITE_HTML="$TEST_ROOT_DIR"/polymer-resin/test/tests.html
mkdir -p "$(dirname "$TEST_SUITE_HTML")"
echo '
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="/components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="/components/web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([' \
> "$TEST_SUITE_HTML"
for f in *test.html standalone/*test.html
do
echo " '../$f'," >> "$TEST_SUITE_HTML"
done
echo '
]);
</script>
</body>
</html>' \
>> "$TEST_SUITE_HTML"
popd
# For dependencies we just copy the components over.
cp -r "$SRC_DIR"/bower_components/webcomponentsjs \
"$TEST_ROOT_DIR"/webcomponentsjs
cp -r "$SRC_DIR"/bower_components/polymer \
"$TEST_ROOT_DIR"/polymer
# wct 6 needs to have bower available
cp -r "$SRC_DIR"/bower_components \
"$TEST_ROOT_DIR"/polymer-resin/bower_components
# TODO: allow running the tests against both debug and non-debug
# versions.
ln "$SRC_DIR"/standalone/polymer-resin-debug.js \
"$TEST_ROOT_DIR"/polymer-resin/polymer-resin.js
ln "$SRC_DIR"/polymer-resin.html \
"$TEST_ROOT_DIR"/polymer-resin/polymer-resin.html
ln "$SRC_DIR"/standalone/resin-plus-bridge-for-test.js \
"$TEST_ROOT_DIR"/polymer-resin/resin-plus-bridge-for-test.js
ln "$SRC_DIR"/bower.json \
"$TEST_ROOT_DIR"/polymer-resin/bower.json
# Invoke wct
pushd "$TEST_ROOT_DIR/polymer-resin"
export FAILED=""
"$SRC_DIR"/node_modules/.bin/wct "$@" || export FAILED="1"
popd
rm -rf "$TEST_ROOT_DIR"
[ -z "$FAILED" ]