Skip to content

Commit 33aab9c

Browse files
author
John Messerly
committed
Merge pull request #114 from chalin/chalin-0327-test-script-refactor
Reuse test.sh under Travis and fixe failing test
2 parents f0e35ab + dfff27c commit 33aab9c

File tree

4 files changed

+85
-89
lines changed

4 files changed

+85
-89
lines changed

pkg/dev_compiler/.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ dart:
55
- stable
66
before_install:
77
- pub global activate dart_coveralls
8-
script: ./tool/travis.sh
8+
script:
9+
- ./tool/build_and_test.sh
10+
- ./tool/coveralls.sh

pkg/dev_compiler/test/test.sh

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,2 @@
11
#!/bin/bash
2-
set -e # bail on error
3-
4-
function fail {
5-
echo -e "Some tests failed"
6-
return 1
7-
}
8-
9-
# Arguments passed to the diff tool. We exclude:
10-
# - *.map files so they aren't compared, as the diff is not human readable.
11-
# - runtime JS files that are just copied over from the sources and are not
12-
# duplicated in the expected folder.
13-
DIFF_ARGS="-u -r -N --exclude=\*.map expect actual"
14-
15-
function show_diff {
16-
echo "Fail: actual output did not match expected"
17-
echo
18-
diff $DIFF_ARGS |\
19-
sed -e "s/^\(+.*\)/\1/" |\
20-
sed -e "s/^\(-.*\)/\1/"
21-
echo
22-
echo "You can update these expectations with:"
23-
echo "$ pushd `pwd` && cp -a actual/* expect && popd"
24-
fail
25-
}
26-
27-
# the directory of this script
28-
TEST_DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd )
29-
30-
# Some tests require being run from the package root
31-
cd $TEST_DIR/..
32-
33-
# Check minimum SDK version
34-
./tool/sdk_version_check.dart 1.9.0-dev.4.0 || fail
35-
36-
./tool/build_sdk.sh
37-
38-
dart -c test/all_tests.dart || fail
39-
40-
# validate codegen_test output
41-
pushd test/codegen/ &> /dev/null
42-
rm -r actual/dev_compiler/ actual/server_mode/dev_compiler/ \
43-
actual/sunflower/dev_compiler
44-
diff $DIFF_ARGS > /dev/null || show_diff
45-
popd &> /dev/null
46-
47-
# validate dart_codegen_test output
48-
pushd test/dart_codegen/ &> /dev/null
49-
diff $DIFF_ARGS > /dev/null || show_diff
50-
popd &> /dev/null
51-
52-
# run self host and analyzer after other tests, because they're ~seconds to run.
53-
dart -c test/checker/self_host_test.dart || fail
54-
55-
# Run analyzer on bin/devc.dart, as it includes most of the code we care about
56-
# via transitive dependencies. This seems to be the only fast way to avoid
57-
# repeated analysis of the same code.
58-
# TODO(jmesserly): ideally we could do test/all_tests.dart, but
59-
# dart_runtime_test.dart creates invalid generic type instantiation AA.
60-
echo "Running dartanalyzer to check for errors/warnings/hints..."
61-
dartanalyzer --fatal-warnings --package-warnings bin/devc.dart | (! grep $PWD) \
62-
|| fail
63-
64-
{
65-
fc=`find test -name "*.dart" |\
66-
xargs grep "/\*\S* should be \S*\*/" | wc -l`
67-
echo "There are" $fc "tests marked as known failures."
68-
}
69-
70-
# Run formatter in rewrite mode on all files that are part of the project.
71-
# This checks that all files are commited first to git, so no state is lost.
72-
# The formatter ignores:
73-
# * local files that have never been added to git,
74-
# * subdirectories of test/ and tool/, unless explicitly added. Those dirs
75-
# contain a lot of generated or external source we should not reformat.
76-
(files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \
77-
tool/*.dart | grep -v lib/src/js/`; git status -s $files | grep -q . \
78-
&& echo "Did not run the formatter, please commit edited files first." \
79-
|| (echo "Running dart formatter" ; pub run dart_style:format -w $files))
80-
popd &> /dev/null
81-
82-
echo -e "All tests pass"
2+
$(dirname "${BASH_SOURCE[0]}")/../tool/build_and_test.sh
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
set -e # bail on error
3+
4+
function fail {
5+
echo -e "Some tests failed"
6+
return 1
7+
}
8+
9+
# Arguments passed to the diff tool. We exclude:
10+
# - *.map files so they aren't compared, as the diff is not human readable.
11+
# - runtime JS files that are just copied over from the sources and are not
12+
# duplicated in the expected folder.
13+
DIFF_ARGS="-u -r -N --exclude=\*.map expect actual"
14+
15+
function show_diff {
16+
echo "Fail: actual output did not match expected"
17+
echo
18+
diff $DIFF_ARGS |\
19+
sed -e "s/^\(+.*\)/\1/" |\
20+
sed -e "s/^\(-.*\)/\1/"
21+
echo
22+
echo "You can update these expectations with:"
23+
echo "$ pushd `pwd` && cp -a actual/* expect && popd"
24+
fail
25+
}
26+
27+
# Some tests require being run from the package root
28+
# switch to the root directory of dev_compiler
29+
cd $( dirname "${BASH_SOURCE[0]}" )/..
30+
31+
# Check minimum SDK version
32+
./tool/sdk_version_check.dart 1.9.0-dev.4.0 || fail
33+
34+
./tool/build_sdk.sh
35+
36+
dart -c test/all_tests.dart || fail
37+
38+
# validate codegen_test output
39+
pushd test/codegen/ &> /dev/null
40+
rm -r actual/dev_compiler/ actual/server_mode/dev_compiler/ \
41+
actual/sunflower/dev_compiler
42+
diff $DIFF_ARGS > /dev/null || show_diff
43+
popd &> /dev/null
44+
45+
# validate dart_codegen_test output
46+
pushd test/dart_codegen/ &> /dev/null
47+
diff $DIFF_ARGS > /dev/null || show_diff
48+
popd &> /dev/null
49+
50+
# run self host and analyzer after other tests, because they're ~seconds to run.
51+
dart -c test/checker/self_host_test.dart || fail
52+
53+
# Run analyzer on bin/devc.dart, as it includes most of the code we care about
54+
# via transitive dependencies. This seems to be the only fast way to avoid
55+
# repeated analysis of the same code.
56+
# TODO(jmesserly): ideally we could do test/all_tests.dart, but
57+
# dart_runtime_test.dart creates invalid generic type instantiation AA.
58+
echo "Running dartanalyzer to check for errors/warnings/hints..."
59+
dartanalyzer --fatal-warnings --package-warnings bin/devc.dart | (! grep $PWD) \
60+
|| fail
61+
62+
{
63+
fc=`find test -name "*.dart" |\
64+
xargs grep "/\*\S* should be \S*\*/" | wc -l`
65+
echo "There are" $fc "tests marked as known failures."
66+
}
67+
68+
# Run formatter in rewrite mode on all files that are part of the project.
69+
# This checks that all files are commited first to git, so no state is lost.
70+
# The formatter ignores:
71+
# * local files that have never been added to git,
72+
# * subdirectories of test/ and tool/, unless explicitly added. Those dirs
73+
# contain a lot of generated or external source we should not reformat.
74+
(files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \
75+
tool/*.dart | grep -v lib/src/js/`; git status -s $files | grep -q . \
76+
&& echo "Did not run the formatter, please commit edited files first." \
77+
|| (echo "Running dart formatter" ; pub run dart_style:format -w $files))
78+
79+
echo -e "All tests pass"

pkg/dev_compiler/tool/travis.sh renamed to pkg/dev_compiler/tool/coveralls.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#!/bin/bash
2+
set -e # bail on error
23

3-
# Fast fail the script on failures.
4-
set -e
5-
6-
# Build first
7-
./tool/build_sdk.sh
8-
9-
dart --checked test/all_tests.dart
4+
# Prerequisite: ./tool/build_sdk.sh has been run.
105

116
# Install dart_coveralls; gather and send coverage data.
127
if [ "$COVERALLS_TOKEN" ] && [ "$TRAVIS_DART_VERSION" = "stable" ]; then

0 commit comments

Comments
 (0)