3838from test .libregrtest import utils
3939from test .libregrtest .filter import get_match_tests , match_test
4040from test .libregrtest .result import TestStats
41+ from test .libregrtest .save_env import saved_test_environment
4142from test .libregrtest .utils import normalize_test_name
4243
4344if not support .has_subprocess_support :
@@ -1782,7 +1783,7 @@ def path(name):
17821783 'parallel' : ['-j2' , '-W' ],
17831784 # iOS and WASI run tests in the main process: a crash kills it
17841785 'single-process' : ['--fast-ci' , '--single-process' ],
1785- # Profile task of PGO and BOLT builds: no annotations
1786+ # Profile task of PGO and BOLT builds: failures stop the build
17861787 'pgo' : ['--pgo' ],
17871788 }
17881789 for name , args in command_lines .items ():
@@ -1793,14 +1794,11 @@ def path(name):
17931794 output , summary = self .run_tests_github (
17941795 * args , * tests , exitcode = EXITCODE_BAD_TEST )
17951796
1796- annotations = []
1797- if '--pgo' not in args :
1798- annotations += test_cases
1799- if '--fast-ci' in args :
1800- annotations .append ((env_changed , path (env_changed ),
1801- None ))
1802- if crash in tests :
1803- annotations .append ((crash , path (crash ), None ))
1797+ annotations = list (test_cases )
1798+ if '--fast-ci' in args :
1799+ annotations .append ((env_changed , path (env_changed ), None ))
1800+ if crash in tests :
1801+ annotations .append ((crash , path (crash ), None ))
18041802 self .assertCountEqual (self .parse_github_annotations (output ),
18051803 annotations , output )
18061804 # Each test case is annotated right after its failure report
@@ -1810,6 +1808,13 @@ def path(name):
18101808 output ,
18111809 rf'(?m)^(?:ERROR|FAIL): { title } \n'
18121810 rf'(?:(?!={{70}}$).*\n)*?::error .*title={ title } ::' )
1811+ # The env changed annotation comes right after the warnings
1812+ if '--fast-ci' in args :
1813+ self .assertRegex (
1814+ output ,
1815+ rf'(?m)^Warning -- os\.environ was modified by '
1816+ rf'{ env_changed } \n(?:Warning -- .*\n)*'
1817+ rf'::error .*title={ env_changed } ::' )
18131818
18141819 # The job summary lists the failed tests in completion order
18151820 summary_lines = summary .splitlines ()
@@ -1820,7 +1825,9 @@ def path(name):
18201825 [line for line in summary_lines
18211826 if line .startswith ('### ' )],
18221827 [test_files [name ] for name in tests ])
1823- self .assertIn ('- os.environ was modified' , summary_lines )
1828+ self .assertIn ('- os.environ was modified: '
1829+ 'added REGRTEST_GITHUB_ENV_CHANGED' ,
1830+ summary_lines )
18241831 self .assertCountEqual (
18251832 re .findall (r'<summary>(.*)</summary>' , summary ),
18261833 [title for title , _ , _ in test_cases ])
@@ -2950,6 +2957,14 @@ def worker():
29502957
29512958
29522959class TestUtils (unittest .TestCase ):
2960+ def test_describe_os_environ (self ):
2961+ describe = saved_test_environment .describe_os_environ
2962+ before = {'A' : '1' , 'B' : '2' , 'C' : '3' }
2963+ after = {'A' : '1' , 'B' : 'secret' , 'D' : '4' }
2964+ self .assertEqual (describe ((0 , None , before ), (0 , None , after )),
2965+ 'added D; removed C; changed B' )
2966+ self .assertEqual (describe ((0 , None , before ), (1 , None , before )), '' )
2967+
29532968 def test_format_duration (self ):
29542969 self .assertEqual (utils .format_duration (0 ),
29552970 '0 ms' )
0 commit comments