Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: pkg/polymer/test/run.sh

Issue 24077003: fix polymer tests -- replace run.sh and run tests using bots (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 # Usage: call directly in the commandline as test/run.sh ensuring that you have 6 # Usage: run from a Dart SVN checkout after building.
7 # both 'dart' and 'content_shell' in your path. Filter tests by passing a
8 # pattern as an argument to this script.
9
10 # TODO(sigmund): replace with a real test runner
11 7
12 # bail on error 8 # bail on error
13 set -e 9 set -e
14 10
15 # print commands executed by this script 11 # Note: test.dart needs to be run from the root of the Dart checkout
16 # set -x 12 DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd )
13 pushd $DIR/../../.. > /dev/null
17 14
18 DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd ) 15 echo "*** Running unit tests for Polymer.dart and its dependencies."
19 # Note: dartanalyzer and some tests needs to be run from the root directory
20 pushd $DIR/.. > /dev/null
21 16
22 export DART_FLAGS="--checked" 17 SUITES="pkg/polymer samples/third_party/todomvc"
23 18
24 # Search for the first argument that doesn't look like an option ('--foo') 19 CONFIG="-m release -r vm,drt,ff -c none,dart2js,dartanalyzer --checked $*"
25 function first_non_option {
26 while [[ $# -gt 0 ]]; do
27 if [[ $1 != --* ]]; then # Note: --* is a regex
28 echo $1
29 return
30 fi
31 shift
32 done
33 }
34 20
35 TEST_PATTERN=$(first_non_option $@) 21 CMD="xvfb-run ./tools/test.py $CONFIG $SUITES"
36 22 echo "*** $CMD"
37 SDK_DIR=$(cd ../../out/ReleaseIA32/dart-sdk/; pwd) 23 $CMD
38 package_root=$SDK_DIR/../packages
39 dart="$SDK_DIR/bin/dart --package-root=$package_root"
40 dartanalyzer="$SDK_DIR/bin/dartanalyzer --package-root=$package_root"
41
42 function fail {
43 return 1
44 }
45
46 function show_diff {
47 diff -u -N $1 $2 | \
48 sed -e "s/^\(+.*\)/\1/" |\
49 sed -e "s/^\(-.*\)/\1/"
50 return 1
51 }
52
53 function update {
54 read -p "Would you like to update the expectations? [y/N]: " answer
55 if [[ $answer == 'y' || $answer == 'Y' ]]; then
56 cp $2 $1
57 return 0
58 fi
59 return 1
60 }
61
62 function pass {
63 echo -e "OK"
64 }
65
66 function compare {
67 # use a standard diff, if they are not identical, format the diff nicely to
68 # see what's the error and prompt to see if they wish to update it. If they
69 # do, continue running more tests.
70 diff -q $1 $2 && pass || show_diff $1 $2 || update $1 $2
71 }
72
73 if [[ ($TEST_PATTERN == "") ]]; then
74 echo Analyzing analyzer for warnings or type errors
75 $dartanalyzer --hints --fatal-warnings --fatal-type-errors lib/dwc.dart
76
77 echo Analyzing deploy-compiler for warnings or type errors
78 $dartanalyzer --hints --fatal-warnings --fatal-type-errors lib/deploy.dart
79
80 echo -e "\nAnalyzing runtime for warnings or type errors"
81 $dartanalyzer --hints --fatal-warnings --fatal-type-errors lib/polymer.dart
82
83 popd > /dev/null
84 fi
85
86 function compare_all {
87 # TODO(jmesserly): bash and dart regexp might not be 100% the same. Ideally we
88 # could do all the heavy lifting in Dart code, and keep this script as a thin
89 # wrapper that sets `--enable-type-checks --enable-asserts`
90 for input in $DIR/../example/component/news/test/*_test.html; do
91 if [[ ($TEST_PATTERN == "") || ($input =~ $TEST_PATTERN) ]]; then
92 FILENAME=`basename $input`
93 DIRNAME=`dirname $input`
94 if [[ `basename $DIRNAME` == 'input' ]]; then
95 DIRNAME=`dirname $DIRNAME`
96 fi
97 echo -e -n "Checking diff for $FILENAME "
98 DUMP="test/data/out/example/test/$FILENAME.txt"
99 EXPECTATION="$DIRNAME/expected/$FILENAME.txt"
100
101 compare $EXPECTATION $DUMP
102 fi
103 done
104 echo -e "Some tests failed"
105 fail
106 }
107
108 if [[ ($TEST_PATTERN == "") ]]; then
109 echo -e "\nTesting build.dart... "
110 $dart $DART_FLAGS build.dart
111 # Run it the way the editor does. Hide stdout because it is in noisy machine
112 # format. Show stderr in case something breaks.
113 # NOTE: not using --checked because the editor doesn't use it, and to workarou nd
114 # http://dartbug.com/9637
115 $dart build.dart --machine --clean > /dev/null
116 $dart build.dart --machine --full > /dev/null
117 fi
118
119 echo -e "\nRunning unit tests... "
120 $dart $DART_FLAGS test/run_all.dart $@ || compare_all
121
122 # Run Dart analyzer to check that we're generating warning clean code.
123 # It's a bit slow, so only do this for one test.
124 OUT_PATTERN="$DIR/../example/component/news/test/out/test/*$TEST_PATTERN*_bootst rap.dart"
125 if [[ `ls $OUT_PATTERN 2>/dev/null` != "" ]]; then
126 echo -e "\nAnalyzing generated code for warnings or type errors."
127 ls $OUT_PATTERN 2>/dev/null | $dartanalyzer \
128 --fatal-warnings --fatal-type-errors -batch
129 fi
130 24
131 echo -e "All tests pass" 25 echo -e "All tests pass"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698