@@ -35,14 +35,18 @@ PATH="$DART_BIN:$PATH"
3535
3636# Use:
3737# env VERBOSE=1 ./ci/licenses.sh
38- # to turn on verbose progress report printing.
38+ # to turn on verbose progress report printing. Set it to 2 to also output
39+ # information about which patterns are taking the most time.
3940QUIET=" --quiet"
4041if [[ " ${VERBOSE} " == " 1" ]]; then
4142 QUIET=" "
4243fi
44+ if [[ " ${VERBOSE} " == " 2" ]]; then
45+ QUIET=" --verbose"
46+ fi
4347
4448echo " Verifying license script is still happy..."
45- echo " Using pub from $( command -v pub ) , dart from $( command -v dart) "
49+ echo " Using dart from: $( command -v dart) "
4650
4751untracked_files=" $( cd " $SRC_DIR /flutter" ; git status --ignored --short | grep -E " ^!" | awk " {print\$ 2}" ) "
4852untracked_count=" $( echo " $untracked_files " | wc -l) "
5862
5963dart --version
6064
65+ # Runs the tests for the license script.
66+ function run_tests() (
67+ cd " $SRC_DIR /flutter/tools/licenses"
68+ find -name " *_test.dart" | xargs -n 1 dart --enable-asserts
69+ )
70+
6171# Collects the license information from the repo.
6272# Runs in a subshell.
6373function collect_licenses() (
@@ -117,11 +127,29 @@ function verify_licenses() (
117127 exitStatus=1
118128 fi
119129
130+ echo " Verifying excluded files list..."
131+ if ! cmp -s " flutter/ci/licenses_golden/excluded_files" " out/license_script_output/excluded_files" ; then
132+ echo " ============================= ERROR ============================="
133+ echo " The license is excluding a different number of files than previously."
134+ echo " This is only expected when new non-source files have been introduced."
135+ echo " Verify that all the newly ignored files are definitely not shipped with"
136+ echo " any binaries that we compile (including impellerc and Wasm)."
137+ echo " If the changes look correct, update this file:"
138+ echo " ci/licenses_golden/excluded_files"
139+ echo " For more information, see the script in:"
140+ echo " https://github.com/flutter/engine/tree/main/tools/licenses"
141+ echo " "
142+ diff -U 6 " flutter/ci/licenses_golden/excluded_files" " out/license_script_output/excluded_files"
143+ echo " ================================================================="
144+ echo " "
145+ exitStatus=1
146+ fi
147+
120148 echo " Checking license count in licenses_flutter..."
121149
122150 local actualLicenseCount
123151 actualLicenseCount=" $( tail -n 1 flutter/ci/licenses_golden/licenses_flutter | tr -dc ' 0-9' ) "
124- local expectedLicenseCount=19 # When changing this number: Update the error message below as well describing all expected license types.
152+ local expectedLicenseCount=20 # When changing this number: Update the error message below as well describing the newly expected license types.
125153
126154 if [[ $actualLicenseCount -ne $expectedLicenseCount ]]; then
127155 echo " =============================== ERROR ==============================="
@@ -145,4 +173,5 @@ function verify_licenses() (
145173 return $exitStatus
146174)
147175
176+ run_tests
148177verify_licenses
0 commit comments