diff --git a/src/psyclone/generator.py b/src/psyclone/generator.py index 8c29bb1b4b..f647a6673a 100644 --- a/src/psyclone/generator.py +++ b/src/psyclone/generator.py @@ -749,5 +749,5 @@ def code_transformation_mode(input_file, recipe_file, output_file, if output_file: shutil.copyfile(input_file, output_file) else: - print(f"File '{input_file}' in FILES_TO_SKIP list.", - file=sys.stdout) + print(f"File '{input_file}' skiped because it is listed in " + "FILES_TO_SKIP.", file=sys.stdout) diff --git a/src/psyclone/psyir/transformations/omp_target_trans.py b/src/psyclone/psyir/transformations/omp_target_trans.py index cf737022c8..7e814f893f 100644 --- a/src/psyclone/psyir/transformations/omp_target_trans.py +++ b/src/psyclone/psyir/transformations/omp_target_trans.py @@ -115,11 +115,11 @@ def validate(self, node, options=None): routine = node.ancestor(Routine) if routine and routine.return_symbol: # if it is a function, the target must not include its return sym - for node in node_list: - for ref in node.walk(Reference): + for check_node in node_list: + for ref in check_node.walk(Reference): if ref.symbol is routine.return_symbol: raise TransformationError( - f"OpenMP Target cannot enclose a region that has" + f"OpenMP Target cannot enclose a region that has " f"a function return value symbol, but found one in" f" '{routine.return_symbol.name}'.") diff --git a/src/psyclone/tests/generator_test.py b/src/psyclone/tests/generator_test.py index fd8558c54c..a500bdd370 100644 --- a/src/psyclone/tests/generator_test.py +++ b/src/psyclone/tests/generator_test.py @@ -788,7 +788,7 @@ def test_main_expected_fatal_error(capsys): assert output == expected_output -def test_code_transformation_skip_files_error(tmpdir): +def test_code_transformation_skip_files_error(tmpdir, capsys): ''' Test that applying recipes in the code-transformation mode skips the files marked as FILES_TO_SKIP ''' code = ''' @@ -819,6 +819,14 @@ def trans(psyir): new_code = my_file.read() assert new_code == code + # When doing the same but without a '-o' (output file), we just print + # in stdout that the file was skipped. + outputfile = str(tmpdir.join("output.f90")) + main([inputfile, "-s", recipefile]) + output, _ = capsys.readouterr() + assert ("funny_syntax.f90' skiped because it is listed in FILES_TO_SKIP." + in output) + def test_code_transformation_trans(tmpdir): ''' Test that applying recipes that have a trans, and are not listed diff --git a/src/psyclone/tests/psyir/transformations/omp_target_trans_test.py b/src/psyclone/tests/psyir/transformations/omp_target_trans_test.py index 1c8ece7f1b..b4b689cbe8 100644 --- a/src/psyclone/tests/psyir/transformations/omp_target_trans_test.py +++ b/src/psyclone/tests/psyir/transformations/omp_target_trans_test.py @@ -111,6 +111,9 @@ def test_omptargettrans_validate(fortran_reader): function myfunc(a) integer :: a integer :: myfunc + do i = 1, 1 + myfunc = a + enddo end function subroutine my_subroutine() integer, dimension(10, 10) :: A @@ -133,11 +136,17 @@ def test_omptargettrans_validate(fortran_reader): with pytest.raises(TransformationError) as err: omptargettrans.validate(loops[0]) + assert ("OpenMP Target cannot enclose a region that has a function " + "return value symbol, but found one in 'myfunc'." + in str(err.value)) + + with pytest.raises(TransformationError) as err: + omptargettrans.validate(loops[1]) assert ("'myfunc' is not available on the accelerator device, and " "therefore it cannot be called from within an OMP Target region." in str(err.value)) with pytest.raises(TransformationError) as err: - omptargettrans.validate(loops[1]) + omptargettrans.validate(loops[2]) assert ("Nodes of type 'CodeBlock' cannot be enclosed by a OMPTarget" "Trans transformation" in str(err.value))