@@ -14,55 +14,73 @@ function test_result_cache_autoloaded_constant() {
1414 # The same sequence on a project file that is neither analysed nor scanned - it is only
1515 # reachable through the Composer autoloader, so it is tracked through the dependency graph
1616 # alone.
17- OUTPUT=$( ../../bin/phpstan analyse -vv - -error-format raw 2>&1 ) && CODE=0 || CODE=$?
17+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
1818 assert_same " 1" " $CODE "
1919 echo " $OUTPUT "
2020 assert_contains ' Foo.php:10:Dumped type: 1' " $OUTPUT "
2121 # The constant is renamed to one the class already declares. The file is invalid PHP, but
2222 # the class still reflects, so the file using the constant is re-analysed through its
2323 # dependency edge.
2424 patch -b other/Dep.php < duplicate.patch
25- OUTPUT=$( ../../bin/phpstan analyse -vv --error-format raw 2>&1 ) && CODE=0 || CODE=$?
25+ INFO=$( ../../bin/phpstan result-cache-info --json)
26+ echo " $INFO "
27+ assert_equals ' true' " $( echo " $INFO " | jq --raw-output ' .resultCacheUsed' ) "
28+ assert_equals ' 1' " $( echo " $INFO " | jq --raw-output ' .filesToAnalyseCount' ) "
29+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
2630 assert_same " 1" " $CODE "
2731 echo " $OUTPUT "
28- assert_contains ' Result cache restored. 1 file will be reanalysed.' " $OUTPUT "
2932 assert_contains ' Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' " $OUTPUT "
3033 # Renamed to something else instead.
3134 mv other/Dep.php.orig other/Dep.php
3235 patch -b other/Dep.php < renamed.patch
33- OUTPUT=$( ../../bin/phpstan analyse -vv --error-format raw 2>&1 ) && CODE=0 || CODE=$?
36+ INFO=$( ../../bin/phpstan result-cache-info --json)
37+ echo " $INFO "
38+ assert_equals ' true' " $( echo " $INFO " | jq --raw-output ' .resultCacheUsed' ) "
39+ assert_equals ' 1' " $( echo " $INFO " | jq --raw-output ' .filesToAnalyseCount' ) "
40+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
3441 assert_same " 1" " $CODE "
3542 echo " $OUTPUT "
36- assert_contains ' Result cache restored. 1 file will be reanalysed.' " $OUTPUT "
3743 assert_contains ' Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' " $OUTPUT "
3844 # Broken the same way again.
3945 mv other/Dep.php.orig other/Dep.php
4046 patch -b other/Dep.php < duplicate.patch
41- OUTPUT=$( ../../bin/phpstan analyse -vv --error-format raw 2>&1 ) && CODE=0 || CODE=$?
47+ INFO=$( ../../bin/phpstan result-cache-info --json)
48+ echo " $INFO "
49+ assert_equals ' true' " $( echo " $INFO " | jq --raw-output ' .resultCacheUsed' ) "
50+ assert_equals ' 1' " $( echo " $INFO " | jq --raw-output ' .filesToAnalyseCount' ) "
51+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
4252 assert_same " 1" " $CODE "
4353 echo " $OUTPUT "
44- assert_contains ' Result cache restored. 1 file will be reanalysed.' " $OUTPUT "
4554 assert_contains ' Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' " $OUTPUT "
4655 # And put back the way it was.
4756 mv other/Dep.php.orig other/Dep.php
48- OUTPUT=$( ../../bin/phpstan analyse -vv --error-format raw 2>&1 ) && CODE=0 || CODE=$?
57+ INFO=$( ../../bin/phpstan result-cache-info --json)
58+ echo " $INFO "
59+ assert_equals ' true' " $( echo " $INFO " | jq --raw-output ' .resultCacheUsed' ) "
60+ assert_equals ' 1' " $( echo " $INFO " | jq --raw-output ' .filesToAnalyseCount' ) "
61+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
4962 assert_same " 1" " $CODE "
5063 echo " $OUTPUT "
51- assert_contains ' Result cache restored. 1 file will be reanalysed.' " $OUTPUT "
5264 assert_contains ' Foo.php:10:Dumped type: 1' " $OUTPUT "
5365 # A syntax error makes the class disappear altogether: the file using it reports an unknown
5466 # class and records no dependency edge to the file, so nothing but the file being fixed can
5567 # bring the file using it back - it must be re-analysed once the class is there again.
5668 patch -b other/Dep.php < broken.patch
57- OUTPUT=$( ../../bin/phpstan analyse -vv --error-format raw 2>&1 ) && CODE=0 || CODE=$?
69+ INFO=$( ../../bin/phpstan result-cache-info --json)
70+ echo " $INFO "
71+ assert_equals ' true' " $( echo " $INFO " | jq --raw-output ' .resultCacheUsed' ) "
72+ assert_equals ' 1' " $( echo " $INFO " | jq --raw-output ' .filesToAnalyseCount' ) "
73+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
5874 assert_same " 1" " $CODE "
5975 echo " $OUTPUT "
60- assert_contains ' Result cache restored. 1 file will be reanalysed.' " $OUTPUT "
6176 assert_contains ' Foo.php:10:Access to constant CON on an unknown class ResultCacheE2EAutoloadedConstant\Dep.' " $OUTPUT "
6277 mv other/Dep.php.orig other/Dep.php
63- OUTPUT=$( ../../bin/phpstan analyse -vv --error-format raw 2>&1 ) && CODE=0 || CODE=$?
78+ INFO=$( ../../bin/phpstan result-cache-info --json)
79+ echo " $INFO "
80+ assert_equals ' true' " $( echo " $INFO " | jq --raw-output ' .resultCacheUsed' ) "
81+ assert_equals ' 1' " $( echo " $INFO " | jq --raw-output ' .filesToAnalyseCount' ) "
82+ OUTPUT=$( ../../bin/phpstan analyse --error-format raw 2>&1 ) && CODE=0 || CODE=$?
6483 assert_same " 1" " $CODE "
6584 echo " $OUTPUT "
66- assert_contains ' Result cache restored. 1 file will be reanalysed.' " $OUTPUT "
6785 assert_contains ' Foo.php:10:Dumped type: 1' " $OUTPUT "
6886}
0 commit comments