OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 set -e # bail on error | 2 set -e # bail on error |
3 | 3 |
4 function fail { | 4 function fail { |
5 echo -e "[31mSome tests failed[0m" | 5 echo -e "[31mSome tests failed[0m" |
6 return 1 | 6 return 1 |
7 } | 7 } |
8 | 8 |
| 9 # Arguments passed to the diff tool. We exclude runtime JS files that are just |
| 10 # copied over from the sources and are not duplicated in the expected folder. |
| 11 DIFF_ARGS="-u -r -N --exclude=dart_runtime.js \ |
| 12 --exclude=harmony_feature_check.js expect actual" |
| 13 |
9 function show_diff { | 14 function show_diff { |
10 echo "Fail: actual output did not match expected" | 15 echo "Fail: actual output did not match expected" |
11 echo | 16 echo |
12 diff -u -r -N $1 $2 |\ | 17 diff $DIFF_ARGS |\ |
13 sed -e "s/^\(+.*\)/[32m\1[0m/" |\ | 18 sed -e "s/^\(+.*\)/[32m\1[0m/" |\ |
14 sed -e "s/^\(-.*\)/[31m\1[0m/" | 19 sed -e "s/^\(-.*\)/[31m\1[0m/" |
15 echo | 20 echo |
16 echo "You can update these expectations with:" | 21 echo "You can update these expectations with:" |
17 echo "$ pushd `pwd` && cp -a actual/* expect && popd" | 22 echo "$ pushd `pwd` && cp -a actual/* expect && popd" |
18 fail | 23 fail |
19 } | 24 } |
20 | 25 |
21 # the directory of this script | 26 # the directory of this script |
22 TEST_DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd ) | 27 TEST_DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd ) |
23 | 28 |
24 # Some tests require being run from the package root | 29 # Some tests require being run from the package root |
25 cd $TEST_DIR/.. | 30 cd $TEST_DIR/.. |
26 | 31 |
27 # Check minimum SDK version | 32 # Check minimum SDK version |
28 ./tool/sdk_version_check.dart 1.9.0-dev.4.0 || fail | 33 ./tool/sdk_version_check.dart 1.9.0-dev.4.0 || fail |
29 | 34 |
30 # Remove packages symlinks, and old codegen output | 35 # Remove packages symlinks, and old codegen output |
31 find test/codegen -name packages -exec rm {} \; | 36 find test/codegen -name packages -exec rm {} \; |
32 rm -r test/codegen/actual 2> /dev/null || true | 37 rm -r test/codegen/actual 2> /dev/null || true |
33 find test/dart_codegen -name packages -exec rm {} \; | 38 find test/dart_codegen -name packages -exec rm {} \; |
34 rm -r test/dart_codegen/actual 2> /dev/null || true | 39 rm -r test/dart_codegen/actual 2> /dev/null || true |
35 dart -c test/all_tests.dart || fail | 40 dart -c test/all_tests.dart || fail |
36 | 41 |
37 # validate codegen_test output | 42 # validate codegen_test output |
38 pushd test/codegen/ &> /dev/null | 43 pushd test/codegen/ &> /dev/null |
39 diff -u -r -N expect actual > /dev/null || show_diff expect actual | 44 diff $DIFF_ARGS > /dev/null || show_diff |
40 popd &> /dev/null | 45 popd &> /dev/null |
41 | 46 |
42 # validate dart_codegen_test output | 47 # validate dart_codegen_test output |
43 pushd test/dart_codegen/ &> /dev/null | 48 pushd test/dart_codegen/ &> /dev/null |
44 diff -u -r -N expect actual > /dev/null || show_diff expect actual | 49 diff $DIFF_ARGS > /dev/null || show_diff |
45 popd &> /dev/null | 50 popd &> /dev/null |
46 | 51 |
47 # run self host and analyzer after other tests, because they're ~seconds to run. | 52 # run self host and analyzer after other tests, because they're ~seconds to run. |
48 dart -c test/checker/self_host_test.dart || fail | 53 dart -c test/checker/self_host_test.dart || fail |
49 | 54 |
50 # Run analyzer on bin/devc.dart, as it includes most of the code we care about | 55 # Run analyzer on bin/devc.dart, as it includes most of the code we care about |
51 # via transitive dependencies. This seems to be the only fast way to avoid | 56 # via transitive dependencies. This seems to be the only fast way to avoid |
52 # repeated analysis of the same code. | 57 # repeated analysis of the same code. |
53 # TODO(jmesserly): ideally we could do test/all_tests.dart, but | 58 # TODO(jmesserly): ideally we could do test/all_tests.dart, but |
54 # dart_runtime_test.dart creates invalid generic type instantiation AA. | 59 # dart_runtime_test.dart creates invalid generic type instantiation AA. |
(...skipping 13 matching lines...) Expand all Loading... |
68 # * local files that have never been added to git, | 73 # * local files that have never been added to git, |
69 # * subdirectories of test/ and tool/, unless explicitly added. Those dirs | 74 # * subdirectories of test/ and tool/, unless explicitly added. Those dirs |
70 # contain a lot of generated or external source we should not reformat. | 75 # contain a lot of generated or external source we should not reformat. |
71 (files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \ | 76 (files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \ |
72 tool/*.dart | grep -v lib/src/js/`; git status -s $files | grep -q . \ | 77 tool/*.dart | grep -v lib/src/js/`; git status -s $files | grep -q . \ |
73 && echo "Did not run the formatter, please commit edited files first." \ | 78 && echo "Did not run the formatter, please commit edited files first." \ |
74 || (echo "Running dart formatter" ; pub run dart_style:format -w $files)) | 79 || (echo "Running dart formatter" ; pub run dart_style:format -w $files)) |
75 popd &> /dev/null | 80 popd &> /dev/null |
76 | 81 |
77 echo -e "[32mAll tests pass[0m" | 82 echo -e "[32mAll tests pass[0m" |
OLD | NEW |