Skip to content

Commit

Permalink
Merge pull request #116 from dart-lang/revert-114-chalin-0327-test-sc…
Browse files Browse the repository at this point in the history
…ript-refactor

Revert "Reuse test.sh under Travis and fixe failing test"
John Messerly committed Mar 30, 2015
2 parents 33aab9c + 2de38f1 commit 4b2a961
Showing 4 changed files with 89 additions and 85 deletions.
4 changes: 1 addition & 3 deletions pkg/dev_compiler/.travis.yml
Original file line number Diff line number Diff line change
@@ -5,6 +5,4 @@ dart:
- stable
before_install:
- pub global activate dart_coveralls
script:
- ./tool/build_and_test.sh
- ./tool/coveralls.sh
script: ./tool/travis.sh
82 changes: 81 additions & 1 deletion pkg/dev_compiler/test/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,82 @@
#!/bin/bash
$(dirname "${BASH_SOURCE[0]}")/../tool/build_and_test.sh
set -e # bail on error

function fail {
echo -e "Some tests failed"
return 1
}

# Arguments passed to the diff tool. We exclude:
# - *.map files so they aren't compared, as the diff is not human readable.
# - runtime JS files that are just copied over from the sources and are not
# duplicated in the expected folder.
DIFF_ARGS="-u -r -N --exclude=\*.map expect actual"

function show_diff {
echo "Fail: actual output did not match expected"
echo
diff $DIFF_ARGS |\
sed -e "s/^\(+.*\)/\1/" |\
sed -e "s/^\(-.*\)/\1/"
echo
echo "You can update these expectations with:"
echo "$ pushd `pwd` && cp -a actual/* expect && popd"
fail
}

# the directory of this script
TEST_DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd )

# Some tests require being run from the package root
cd $TEST_DIR/..

# Check minimum SDK version
./tool/sdk_version_check.dart 1.9.0-dev.4.0 || fail

./tool/build_sdk.sh

dart -c test/all_tests.dart || fail

# validate codegen_test output
pushd test/codegen/ &> /dev/null
rm -r actual/dev_compiler/ actual/server_mode/dev_compiler/ \
actual/sunflower/dev_compiler
diff $DIFF_ARGS > /dev/null || show_diff
popd &> /dev/null

# validate dart_codegen_test output
pushd test/dart_codegen/ &> /dev/null
diff $DIFF_ARGS > /dev/null || show_diff
popd &> /dev/null

# run self host and analyzer after other tests, because they're ~seconds to run.
dart -c test/checker/self_host_test.dart || fail

# Run analyzer on bin/devc.dart, as it includes most of the code we care about
# via transitive dependencies. This seems to be the only fast way to avoid
# repeated analysis of the same code.
# TODO(jmesserly): ideally we could do test/all_tests.dart, but
# dart_runtime_test.dart creates invalid generic type instantiation AA.
echo "Running dartanalyzer to check for errors/warnings/hints..."
dartanalyzer --fatal-warnings --package-warnings bin/devc.dart | (! grep $PWD) \
|| fail

{
fc=`find test -name "*.dart" |\
xargs grep "/\*\S* should be \S*\*/" | wc -l`
echo "There are" $fc "tests marked as known failures."
}

# Run formatter in rewrite mode on all files that are part of the project.
# This checks that all files are commited first to git, so no state is lost.
# The formatter ignores:
# * local files that have never been added to git,
# * subdirectories of test/ and tool/, unless explicitly added. Those dirs
# contain a lot of generated or external source we should not reformat.
(files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \
tool/*.dart | grep -v lib/src/js/`; git status -s $files | grep -q . \
&& echo "Did not run the formatter, please commit edited files first." \
|| (echo "Running dart formatter" ; pub run dart_style:format -w $files))
popd &> /dev/null

echo -e "All tests pass"
79 changes: 0 additions & 79 deletions pkg/dev_compiler/tool/build_and_test.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash
set -e # bail on error

# Prerequisite: ./tool/build_sdk.sh has been run.
# Fast fail the script on failures.
set -e

# Build first
./tool/build_sdk.sh

dart --checked test/all_tests.dart

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

0 comments on commit 4b2a961

Please sign in to comment.