1414sys .path .append (ROOT_DIR )
1515
1616from polyphony .compiler .__main__ import compile_main , logging_setting
17- from polyphony .compiler .env import env
17+ from polyphony .compiler .common . env import env
1818
1919
2020def parse_options ():
@@ -26,13 +26,20 @@ def parse_options():
2626 parser .add_argument ('-d' , '--enable_debug' , dest = 'debug_mode' ,
2727 action = 'store_true' , help = 'enable debug mode' )
2828 parser .add_argument ('-w' , dest = 'warn_test' , action = 'store_true' )
29+ parser .add_argument ('-p' , dest = 'with_path_name' , action = 'store_true' )
2930 parser .add_argument ('source' , help = 'Python source file' )
3031 return parser .parse_args ()
3132
3233
33- def make_compile_options (casename , err_options , quiet_level ):
34+ def make_compile_options (casename , casefile_path , err_options , quiet_level ):
3435 options = types .SimpleNamespace ()
3536 options .config = err_options .config
37+ if err_options .with_path_name :
38+ p , _ = os .path .splitext (casefile_path )
39+ options .output_prefix = p .replace ('.' , '' ).replace (os .path .sep , '_' )
40+ casename = f'{ options .output_prefix } _{ casename } '
41+ else :
42+ options .output_prefix = ''
3643 options .output_name = casename
3744 options .output_dir = TMP_DIR
3845 options .verbose_level = 0
@@ -52,7 +59,7 @@ def error_test(casefile_path, err_options):
5259 print ('The file is not error test file' )
5360 sys .exit (0 )
5461 expected_msg = first_line .split ('#' )[1 ].rstrip ('\n ' )
55- options = make_compile_options (casename , err_options , env .QUIET_ERROR )
62+ options = make_compile_options (casename , casefile_path , err_options , env .QUIET_ERROR )
5663 try :
5764 compile_main (casefile_path , options )
5865 except AssertionError :
@@ -81,13 +88,17 @@ def warn_test(casefile_path, err_options):
8188 expected_msg = first_line .split ('#' )[1 ].rstrip ('\n ' )
8289 f = io .StringIO ()
8390 err_options .debug_mode = False
84- options = make_compile_options (casename , err_options , 0 )
91+ options = make_compile_options (casename , casefile_path , err_options , 0 )
92+ stopped = False
8593 with redirect_stdout (f ):
8694 try :
8795 compile_main (casefile_path , options )
8896 except Exception as e :
89- print (casefile_path )
90- print ('[WARNING TEST] FAILED' )
97+ stopped = True
98+ if stopped :
99+ print (casefile_path )
100+ print ('[WARNING TEST] FAILED: Compilation has stopped' )
101+ return False
91102 msg = f .getvalue ()
92103 #print(msg)
93104 header = 'Warning: '
0 commit comments