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

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

Issue 23445009: Prune the old deploy code. This CL does a few changes: (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) 2012, 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: call directly in the commandline as test/run.sh ensuring that you have
7 # both 'dart' and 'content_shell' in your path. Filter tests by passing a 7 # both 'dart' and 'content_shell' in your path. Filter tests by passing a
8 # pattern as an argument to this script. 8 # pattern as an argument to this script.
9 9
10 # TODO(sigmund): replace with a real test runner 10 # TODO(sigmund): replace with a real test runner
11 11
12 # bail on error 12 # bail on error
13 set -e 13 set -e
14 14
15 # print commands executed by this script 15 # print commands executed by this script
16 # set -x 16 # set -x
17 17
18 DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd ) 18 DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd )
19 # Note: dartanalyzer and some tests needs to be run from the root directory
20 pushd $DIR/.. > /dev/null
21
19 export DART_FLAGS="--checked" 22 export DART_FLAGS="--checked"
20 TEST_PATTERN=$1 23
24 # Search for the first argument that doesn't look like an option ('--foo')
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
35 TEST_PATTERN=$(first_non_option $@)
36
37 SDK_DIR=$(cd ../../out/ReleaseIA32/dart-sdk/; pwd)
38 dart=$SDK_DIR/bin/dart
39 dartanalyzer=$SDK_DIR/bin/dartanalyzer
21 40
22 function fail { 41 function fail {
23 return 1 42 return 1
24 } 43 }
25 44
26 function show_diff { 45 function show_diff {
27 diff -u -N $1 $2 | \ 46 diff -u -N $1 $2 | \
28 sed -e "s/^\(+.*\)/\1/" |\ 47 sed -e "s/^\(+.*\)/\1/" |\
29 sed -e "s/^\(-.*\)/\1/" 48 sed -e "s/^\(-.*\)/\1/"
30 return 1 49 return 1
(...skipping 13 matching lines...) Expand all
44 } 63 }
45 64
46 function compare { 65 function compare {
47 # use a standard diff, if they are not identical, format the diff nicely to 66 # use a standard diff, if they are not identical, format the diff nicely to
48 # see what's the error and prompt to see if they wish to update it. If they 67 # see what's the error and prompt to see if they wish to update it. If they
49 # do, continue running more tests. 68 # do, continue running more tests.
50 diff -q $1 $2 && pass || show_diff $1 $2 || update $1 $2 69 diff -q $1 $2 && pass || show_diff $1 $2 || update $1 $2
51 } 70 }
52 71
53 if [[ ($TEST_PATTERN == "") ]]; then 72 if [[ ($TEST_PATTERN == "") ]]; then
54 # Note: dartanalyzer needs to be run from the root directory for proper path
55 # canonicalization.
56 pushd $DIR/.. > /dev/null
57
58 echo Analyzing compiler for warnings or type errors 73 echo Analyzing compiler for warnings or type errors
59 dartanalyzer --hints --fatal-warnings --fatal-type-errors bin/dwc.dart 74 $dartanalyzer --hints --fatal-warnings --fatal-type-errors lib/deploy.dart
60 75
61 echo -e "\nAnalyzing runtime for warnings or type errors" 76 echo -e "\nAnalyzing runtime for warnings or type errors"
62 dartanalyzer --hints --fatal-warnings --fatal-type-errors lib/polymer.dart 77 $dartanalyzer --hints --fatal-warnings --fatal-type-errors lib/polymer.dart
63 78
64 popd > /dev/null 79 popd > /dev/null
65 fi 80 fi
66 81
67 function compare_all { 82 function compare_all {
68 # TODO(jmesserly): bash and dart regexp might not be 100% the same. Ideally we 83 # TODO(jmesserly): bash and dart regexp might not be 100% the same. Ideally we
69 # could do all the heavy lifting in Dart code, and keep this script as a thin 84 # could do all the heavy lifting in Dart code, and keep this script as a thin
70 # wrapper that sets `--enable-type-checks --enable-asserts` 85 # wrapper that sets `--enable-type-checks --enable-asserts`
71 for input in $DIR/../example/component/news/test/*_test.html \ 86 for input in $DIR/../example/component/news/test/*_test.html \
72 $DIR/../../../samples/third_party/todomvc/test/*_test.html; do 87 $DIR/../../../samples/third_party/todomvc/test/*_test.html; do
73 if [[ ($TEST_PATTERN == "") || ($input =~ $TEST_PATTERN) ]]; then 88 if [[ ($TEST_PATTERN == "") || ($input =~ $TEST_PATTERN) ]]; then
74 FILENAME=`basename $input` 89 FILENAME=`basename $input`
75 DIRNAME=`dirname $input` 90 DIRNAME=`dirname $input`
76 if [[ `basename $DIRNAME` == 'input' ]]; then 91 if [[ `basename $DIRNAME` == 'input' ]]; then
77 DIRNAME=`dirname $DIRNAME` 92 DIRNAME=`dirname $DIRNAME`
78 fi 93 fi
79 echo -e -n "Checking diff for $FILENAME " 94 echo -e -n "Checking diff for $FILENAME "
80 DUMP="$DIRNAME/out/$FILENAME.txt" 95 DUMP="test/data/out/example/test/$FILENAME.txt"
81 EXPECTATION="$DIRNAME/expected/$FILENAME.txt" 96 EXPECTATION="$DIRNAME/expected/$FILENAME.txt"
82 97
83 compare $EXPECTATION $DUMP 98 compare $EXPECTATION $DUMP
84 fi 99 fi
85 done 100 done
86 echo -e "Some tests failed" 101 echo -e "Some tests failed"
87 fail 102 fail
88 } 103 }
89 104
90 if [[ -e $DIR/data/input/example ]]; then
91 echo "WARNING: detected old data/input/example symlink."
92 echo "Removing it and rerunning pub install to fix broken example symlinks."
93 echo "See http://dartbug.com/9418 for more information."
94 echo "You should only see this message once."
95 if [[ -e $DIR/packages ]]; then
96 find . -name packages -type l | xargs rm
97 fi
98 rm $DIR/data/input/example
99 pushd $DIR/..
100 pub install
101 popd
102 fi
103
104 # TODO(jmesserly): dart:io fails if we run the Dart scripts with an absolute
105 # path. So use pushd/popd to change the working directory.
106 if [[ ($TEST_PATTERN == "") ]]; then 105 if [[ ($TEST_PATTERN == "") ]]; then
107 pushd $DIR/.. > /dev/null
108 echo -e "\nTesting build.dart... " 106 echo -e "\nTesting build.dart... "
109 dart $DART_FLAGS build.dart 107 $dart $DART_FLAGS build.dart
110 # Run it the way the editor does. Hide stdout because it is in noisy machine 108 # Run it the way the editor does. Hide stdout because it is in noisy machine
111 # format. Show stderr in case something breaks. 109 # format. Show stderr in case something breaks.
112 # NOTE: not using --checked because the editor doesn't use it, and to workarou nd 110 # NOTE: not using --checked because the editor doesn't use it, and to workarou nd
113 # http://dartbug.com/9637 111 # http://dartbug.com/9637
114 dart build.dart --machine --clean > /dev/null 112 $dart build.dart --machine --clean > /dev/null
115 dart build.dart --machine --full > /dev/null 113 $dart build.dart --machine --full > /dev/null
116 dart build.dart --machine --changed ../../samples/third_party/todomvc/web/inde x.html > /dev/null 114 $dart build.dart --machine --changed ../../samples/third_party/todomvc/web/ind ex.html > /dev/null
117 popd > /dev/null
118 fi 115 fi
119 116
120 pushd $DIR > /dev/null
121 echo -e "\nRunning unit tests... " 117 echo -e "\nRunning unit tests... "
122 dart $DART_FLAGS run_all.dart $@ || compare_all 118 $dart $DART_FLAGS test/run_all.dart $@ || compare_all
123 popd > /dev/null
124 119
125 # Run Dart analyzer to check that we're generating warning clean code. 120 # Run Dart analyzer to check that we're generating warning clean code.
126 # It's a bit slow, so only do this for TodoMVC and html5_utils tests. 121 # It's a bit slow, so only do this for TodoMVC.
127 OUT_PATTERN="$DIR/../../../third_party/samples/todomvc/test/out/test/*$TEST_PATT ERN*_bootstrap.dart" 122 OUT_PATTERN="$DIR/../../../third_party/samples/todomvc/test/out/test/*$TEST_PATT ERN*_bootstrap.dart"
128 if [[ `ls $OUT_PATTERN 2>/dev/null` != "" ]]; then 123 if [[ `ls $OUT_PATTERN 2>/dev/null` != "" ]]; then
129 echo -e "\nAnalyzing generated code for warnings or type errors." 124 echo -e "\nAnalyzing generated code for warnings or type errors."
130 ls $OUT_PATTERN 2>/dev/null | dartanalyzer --package-root=packages \ 125 ls $OUT_PATTERN 2>/dev/null | $dartanalyzer --package-root=packages \
131 --fatal-warnings --fatal-type-errors -batch 126 --fatal-warnings --fatal-type-errors -batch
132 fi 127 fi
133 128
134 echo -e "All tests pass" 129 echo -e "All tests pass"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698