hiker / fab

Flexible build system for scientific software
https://metomi.github.io/fab/
Other
1 stars 0 forks source link

hiker#5 Fix test warnings #10

Closed jasonjunweilyu closed 7 months ago

jasonjunweilyu commented 7 months ago

Summary:

This PR is to fix test warnings, either by changing them to report errors when warnings are not issued if they are designed in fab with intentions through pytest.warns() or by filtering them out if they are related to deprecation warnings in dependent packages with @pytest.mark.filterwarnings(). The motivation of this PR is explained in Issue hiker#5. The fix for test errors is in another PR.

Warning Details:

In details, the warnings seen are:

Unit tests:

================================ warnings summary =============================== tests/unit_tests/test_build_config.py::TestBuildConfig::test_add_cleanup /apps/python3/3.12.1/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC). EPOCH = datetime.datetime.utcfromtimestamp(0)

tests/unit_tests/test_tools.py::Test_remove_managed_flags::test_gfortran tests/unit_tests/steps/test_compile_fortran.py::Test_constructor::test_gfortran_managed_flags source/fab/tools.py:62: UserWarning: removing managed flag -J for compiler gfortran warnings.warn(f'removing managed flag {flag} for compiler {compiler}')

tests/unit_tests/test_tools.py::Test_remove_managed_flags::test_ifort tests/unit_tests/steps/test_compile_fortran.py::Test_constructor::test_ifort_managed_flags source/fab/tools.py:62: UserWarning: removing managed flag -module for compiler ifort warnings.warn(f'removing managed flag {flag} for compiler {compiler}')

tests/unit_tests/steps/test_analyse.py::Test_parse_files::test_exceptions source/fab/steps/analyse.py:267: UserWarning: deprecated 'DEPENDS ON:' comment found in fortran code warnings.warn("deprecated 'DEPENDS ON:' comment found in fortran code")

tests/unit_tests/steps/test_analyse.py::Test_add_manual_results::test_vanilla source/fab/steps/analyse.py:301: UserWarning: SPECIAL MEASURE: injecting user-defined analysis results warnings.warn("SPECIAL MEASURE: injecting user-defined analysis results")

tests/unit_tests/steps/test_archive_objects.py: 2 warnings tests/unit_tests/steps/test_cleanup_prebuilds.py: 1 warning tests/unit_tests/steps/test_compile_c.py: 1 warning tests/unit_tests/steps/test_compile_fortran.py: 9 warnings tests/unit_tests/steps/test_grab.py: 4 warnings tests/unit_tests/steps/test_link.py: 1 warning tests/unit_tests/steps/test_root_inc_files.py: 2 warnings source/fab/metrics.py:140: UserWarning: _metric_send_conn not set, cannot send metrics warnings.warn('_metric_send_conn not set, cannot send metrics')

tests/unit_tests/steps/test_compile_c.py::Test_CompileC::test_vanilla source/fab/steps/compile_c.py:79: UserWarning: Adding '-c' to C compiler flags warnings.warn("Adding '-c' to C compiler flags")

tests/unit_tests/steps/test_compile_fortran.py::Test_constructor::test_gfortran_managed_flags source/fab/tools.py:62: UserWarning: removing managed flag -c for compiler gfortran warnings.warn(f'removing managed flag {flag} for compiler {compiler}')

tests/unit_tests/steps/test_compile_fortran.py::Test_constructor::test_ifort_managed_flags source/fab/tools.py:62: UserWarning: removing managed flag -c for compiler ifort warnings.warn(f'removing managed flag {flag} for compiler {compiler}')

tests/unit_tests/steps/test_root_inc_files.py::TestRootIncFiles::test_vanilla tests/unit_tests/steps/test_root_inc_files.py::TestRootIncFiles::test_skip_output_folder tests/unit_tests/steps/test_root_inc_files.py::TestRootIncFiles::test_name_clash source/fab/steps/root_inc_files.py:46: DeprecationWarning: RootIncFiles is deprecated as .inc files are due to be removed. warnings.warn("RootIncFiles is deprecated as .inc files are due to be removed.", DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ======================= 172 passed, 33 warnings in 6.28s =======================

System tests:

===================== warnings summary ========================== tests/system_tests/CFortranInterop/test_CFortranInterop.py::test_CFortranInterop tests/system_tests/FortranDependencies/test_FortranDependencies.py::test_FortranDependencies tests/system_tests/FortranPreProcess/test_FortranPreProcess.py::test_FortranPreProcess tests/system_tests/FortranPreProcess/test_FortranPreProcess.py::test_FortranPreProcess tests/system_tests/MinimalFortran/test_MinimalFortran.py::test_MinimalFortran source/fab/tools.py:62: UserWarning: removing managed flag -c for compiler gfortran warnings.warn(f'removing managed flag {flag} for compiler {compiler}')

tests/system_tests/git/test_git.py: 7 warnings tests/system_tests/grab_archive/test_grab_archive.py: 1 warning tests/system_tests/svn_fcm/test_svn_fcm.py: 11 warnings source/fab/metrics.py:140: UserWarning: _metric_send_conn not set, cannot send metrics warnings.warn('_metric_send_conn not set, cannot send metrics')

tests/system_tests/git/test_git.py: 1 warning tests/system_tests/grab_archive/test_grab_archive.py: 1 warning tests/system_tests/svn_fcm/test_svn_fcm.py: 9 warnings /apps/python3/3.12.1/lib/python3.12/tarfile.py:2220: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior. warnings.warn(

tests/system_tests/psyclone/test_psyclone.py::TestPsyclone::test_run tests/system_tests/psyclone/test_psyclone.py::TestPsyclone::test_prebuild source/fab/steps/psyclone.py:236: UserWarning: no transformation script specified warnings.warn('no transformation script specified')

tests/system_tests/zero_config/test_zero_config.py::TestZeroConfig::test_fortran_dependencies tests/system_tests/zero_config/test_zero_config.py::TestZeroConfig::test_c_fortran_interop tests/system_tests/zero_config/test_zero_config.py::TestZeroConfig::test_fortran_explicit_gfortran source/fab/steps/root_inc_files.py:46: DeprecationWarning: RootIncFiles is deprecated as .inc files are due to be removed. warnings.warn("RootIncFiles is deprecated as .inc files are due to be removed.", DeprecationWarning)

tests/system_tests/zero_config/test_zero_config.py::TestZeroConfig::test_fortran_explicit_gfortran source/fab/steps/compile_c.py:79: UserWarning: Adding '-c' to C compiler flags warnings.warn("Adding '-c' to C compiler flags")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Categorization of the warnings:

I. Intended warnings:

  1. UserWarning: removing managed flag for for compiler
  2. UserWarning: deprecated 'DEPENDS ON:' comment found in fortran code
  3. UserWarning: SPECIAL MEASURE: injecting user-defined analysis results
  4. UserWarning: _metric_send_conn not set, cannot send metrics
  5. DeprecationWarning: RootIncFiles is deprecated as .inc files are due to be removed.
  6. UserWarning: no transformation script specified
  7. UserWarning: Adding '-c' to C compiler flags

II. Dependent package warnings:

  1. DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated: This can be solved by upgrading the dateutil package from 2.8.2 to 2.9.0.post0.
  2. DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.: This is related to tar, which is used by git and svn. This warning has been filtered out as upgrading to newer version of git and svn later should remove this warning.
hiker commented 7 months ago

Additionally, the PR must be brought up to bom_master which has a minor conflict.

jasonjunweilyu commented 7 months ago

Thanks for checking the styling. I have fixed the flake8 warnings and solved the conflict with bom-master by merging the fix_test_error branch in. I double checked the tests. Now all the warnings and errors should be gone with this branch.

jasonjunweilyu commented 7 months ago

Although the CI pipeline passed with success, when I look at the results in detail, I found that there are still some warnings specific to the Python versions on the pipeline, which did not show up when I use my local Python 3.12. @hiker Should I just filter them out, or turn them into Python-version-specific errors with conditions added if the warnings are not shown?

jasonjunweilyu commented 7 months ago

Massive work here, thanks a lot.

I believe (from looking at the "Files changed" tab and the comments, that you kind of re-applied the fixes from the fix_test_error branch, since I see them as change here (and I assume git is smart enough to figure out that there is no conflict). I think it would have been better if you had merged bom_master into this branch, then we shouldn't see those old changes (unless they were conflicts). All good otherwise, CI is green, flake8 is happy - progressing to merge

Thanks for the review. Now I understand why it has the merge-rebase request. Next time I will merge bom-master instead of another feature branch. I chose fix_test_error branch to avoid the changes brought to bom-master by absolute-path branch. But it turned out this also has its own problems.