diff --git a/examples/misc/analyzer-2-results.txt b/examples/misc/analyzer-2-results.txt index 4820bffe62..7fca74ba44 100644 --- a/examples/misc/analyzer-2-results.txt +++ b/examples/misc/analyzer-2-results.txt @@ -1,4 +1,4 @@ -Analyzing lib, test... +Analyzing analysis_options.yaml, lib, test... # https://github.com/dart-lang/sdk/issues/32236 - flow analysis can't yet figure out that the variable is of type Person. error • 'Object' doesn't extend 'SomeBaseClass' at lib/language_tour/generics/misc.dart:29:19 • type_argument_not_matching_bounds error • The argument type 'int' can't be assigned to the parameter type 'String' at lib/library_tour/core/collections.dart:5:14 • argument_type_not_assignable diff --git a/examples/strong/analyzer-2-results.txt b/examples/strong/analyzer-2-results.txt index 2de0176898..ef4c639224 100644 --- a/examples/strong/analyzer-2-results.txt +++ b/examples/strong/analyzer-2-results.txt @@ -1,4 +1,4 @@ -Analyzing lib, test... +Analyzing analysis_options.yaml, lib, test... error • 'HoneyBadger.parent' ('Root Function()') isn't a valid override of 'Animal.parent' ('parent') at lib/animal_bad.dart:15:3 • invalid_override error • 'Cat.chase' ('void Function(Mouse)') isn't a valid override of 'Animal.chase' ('chase') at lib/animal_bad.dart:26:3 • invalid_override error • A value of type 'List' can't be assigned to a variable of type 'List' at lib/animal_bad.dart:49:19 • invalid_assignment diff --git a/tool/analyze-and-test-examples.sh b/tool/analyze-and-test-examples.sh index df4242e7ad..f6ebb683c4 100755 --- a/tool/analyze-and-test-examples.sh +++ b/tool/analyze-and-test-examples.sh @@ -43,61 +43,71 @@ function analyze_and_test() { pub $PUB_ARGS travis_fold end analyzeAndTest.get + # TODO: rename DIR since it now more generally contains analysis targets, not only directories DIR=() - for d in bin lib test; do - if [[ -d $d ]]; then DIR+=($d); fi + for d in analysis_options.yaml bin lib test; do + if [[ -e $d ]]; then DIR+=($d); fi done if [[ ${#DIR} -le 0 ]]; then echo echo "NOTHING TO ANALYZE in this project." - else - echo - EXPECTED_FILE=$PROJECT_ROOT/analyzer-$DART_MAJOR_VERS-results.txt - if [[ ! -e $EXPECTED_FILE ]]; then - EXPECTED_FILE=$PROJECT_ROOT/analyzer-results.txt - fi - travis_fold start analyzeAndTest.analyze - if [[ -e $EXPECTED_FILE && -z $QUICK ]]; then - # Run the analyzer a first time to ensure that there are no errors. - # - # Note: catch non-zero exit codes to avoid aborting this script when the - # analyzer reports "foo.dart is a part and cannot be analyzed": - $ANALYZE ${DIR[*]} > $LOG_FILE || { - echo "WARNING: Ignoring Analyzer exit code $?" - } - if grep -qvE '^Analyzing|^No issues found' $LOG_FILE; then - cat $LOG_FILE - echo "No analysis errors or warnings should be present in original source files." - echo "Ensure that these issues are disabled using appropriate markers like: " - echo " // ignore_for_file: $DART_MAJOR_VERS, some_analyzer_error_or_warning_id" - EXIT_STATUS=1 - return 1; - fi - fi - disableInFileAnalyzerFlags ${DIR[*]} + return + fi + + echo + EXPECTED_FILE=$PROJECT_ROOT/analyzer-$DART_MAJOR_VERS-results.txt + if [[ ! -e $EXPECTED_FILE ]]; then + EXPECTED_FILE=$PROJECT_ROOT/analyzer-results.txt + fi + travis_fold start analyzeAndTest.analyze + if [[ -e $EXPECTED_FILE && -z $QUICK ]]; then + # Run the analyzer a first time to ensure that there are no errors. + # + # Note: catch non-zero exit codes to avoid aborting this script when the + # analyzer reports "foo.dart is a part and cannot be analyzed": + echo "$ $ANALYZE ${DIR[*]}" $ANALYZE ${DIR[*]} > $LOG_FILE || { echo "WARNING: Ignoring Analyzer exit code $?" } - if [[ -e $EXPECTED_FILE ]]; then - if grep -ve '^#' $EXPECTED_FILE | diff - $LOG_FILE > /dev/null; then - echo "Analyzer output is as expected ($EXPECTED_FILE)." - else - cat $LOG_FILE - echo "Unexpected analyzer output ($EXPECTED_FILE); here's the diff:" - (set -x; diff $LOG_FILE $EXPECTED_FILE) || true - EXIT_STATUS=1 - if [[ -n $SAVE_LOGS ]]; then cp $LOG_FILE $EXPECTED_FILE; fi - fi - elif grep -qvE '^Analyzing|^No issues found' $LOG_FILE; then + if grep -qvE '^Analyzing|^No issues found' $LOG_FILE; then cat $LOG_FILE + echo "No analysis errors or warnings should be present in original source files." + echo "Ensure that these issues are disabled using appropriate markers like: " + echo " // ignore_for_file: $DART_MAJOR_VERS, some_analyzer_error_or_warning_id" EXIT_STATUS=1 - if [[ -n $SAVE_LOGS ]]; then cp $LOG_FILE $EXPECTED_FILE; fi + return 1; + fi + fi + disableInFileAnalyzerFlags ${DIR[*]} + echo "$ $ANALYZE ${DIR[*]}" + $ANALYZE ${DIR[*]} > $LOG_FILE || { + echo "WARNING: Ignoring analyzer exit code $?" + } + if [[ -e $EXPECTED_FILE ]]; then + if grep -ve '^#' $EXPECTED_FILE | diff - $LOG_FILE > /dev/null; then + echo "Analyzer output is as expected ($EXPECTED_FILE)." else cat $LOG_FILE + echo "Unexpected analyzer output ($EXPECTED_FILE); here's the diff:" + (set -x; diff $LOG_FILE $EXPECTED_FILE) || true + EXIT_STATUS=1 + if [[ -n $SAVE_LOGS ]]; then cp $LOG_FILE $EXPECTED_FILE; fi fi - reEnableInFileAnalyzerFlags ${DIR[*]} - travis_fold end analyzeAndTest.analyze + elif grep -qvE '^Analyzing|^No issues found' $LOG_FILE; then + cat $LOG_FILE + EXIT_STATUS=1 + if [[ -n $SAVE_LOGS ]]; then cp $LOG_FILE $EXPECTED_FILE; fi + else + cat $LOG_FILE + fi + reEnableInFileAnalyzerFlags ${DIR[*]} + travis_fold end analyzeAndTest.analyze + + if [[ ! -d test ]]; then + echo + echo "NOTHING TO TEST in this project." + return fi echo @@ -107,7 +117,7 @@ function analyze_and_test() { TEST="pub run test" TEST_ARGS="--exclude-tags=browser" - echo $TEST $TEST_ARGS + echo "$ $TEST $TEST_ARGS" $TEST $TEST_ARGS | tee $LOG_FILE | $FILTER1 | $FILTER2 "$FILTER_ARG" LOG=$(grep -E 'All tests passed!|^No tests ran' $LOG_FILE) if [[ -z "$LOG" ]]; then EXIT_STATUS=1; fi @@ -125,6 +135,7 @@ function analyze_and_test() { if [[ -n $TRAVIS ]]; then PLATFORM=travischrome; fi # Name the sole browser test file, otherwise all other files get compiled too: TEST="pub run test" + echo "$ $TEST --tags browser --platform $PLATFORM $TEST_FILES" $TEST --tags browser --platform $PLATFORM $TEST_FILES \ | tee $LOG_FILE | $FILTER1 | $FILTER2 "$FILTER_ARG" LOG=$(grep 'All tests passed!' $LOG_FILE)