Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests write to source tree when invoked via CMake #1515

Open
iskunk opened this issue Sep 28, 2023 · 0 comments
Open

Tests write to source tree when invoked via CMake #1515

iskunk opened this issue Sep 28, 2023 · 0 comments

Comments

@iskunk
Copy link

iskunk commented Sep 28, 2023

Describe the bug
When the test suite is invoked via CMake in a regular out-of-source build configuration, and the source tree is read-only, the tests fail with

$ ctest --rerun-failed --output-on-failure
Test project /tmp/build/linux_jsoncpp_1.9.5/build
    Start 1: jsoncpp_readerwriter
1/2 Test #1: jsoncpp_readerwriter ................***Failed    0.09 sec
/tmp/build/linux_jsoncpp_1.9.5/build/bin/jsontestrunner_exe  --json-writer StyledWriter "/tmp/src/jsoncpp/1.9.5/test/data/legacy_test_string_unicode_04.json"
Failed to create 'input' actual file.
TESTING: /tmp/src/jsoncpp/1.9.5/test/data/legacy_test_string_unicode_04.json Traceback (most recent call last):
  File "/tmp/src/jsoncpp/1.9.5/src/jsontestrunner/../../test/runjsontests.py", line 189, in <module>
    main()
  File "/tmp/src/jsoncpp/1.9.5/src/jsontestrunner/../../test/runjsontests.py", line 174, in main
    runAllTests(jsontest_executable_path, input_path,
  File "/tmp/src/jsoncpp/1.9.5/src/jsontestrunner/../../test/runjsontests.py", line 125, in runAllTests
    open(base_path + '.process-output', 'wt', encoding = 'utf-8').write(process_output)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/tmp/src/jsoncpp/1.9.5/test/data/legacy_test_string_unicode_04.process-output'

    Start 2: jsoncpp_readerwriter_json_checker
2/2 Test #2: jsoncpp_readerwriter_json_checker ...***Failed    0.09 sec
/tmp/build/linux_jsoncpp_1.9.5/build/bin/jsontestrunner_exe  --json-writer StyledWriter "/tmp/src/jsoncpp/1.9.5/test/data/legacy_test_string_unicode_04.json"
Failed to create 'input' actual file.
TESTING: /tmp/src/jsoncpp/1.9.5/test/data/legacy_test_string_unicode_04.json Traceback (most recent call last):
  File "/tmp/src/jsoncpp/1.9.5/src/jsontestrunner/../../test/runjsontests.py", line 189, in <module>
    main()
  File "/tmp/src/jsoncpp/1.9.5/src/jsontestrunner/../../test/runjsontests.py", line 174, in main
    runAllTests(jsontest_executable_path, input_path,
  File "/tmp/src/jsoncpp/1.9.5/src/jsontestrunner/../../test/runjsontests.py", line 125, in runAllTests
    open(base_path + '.process-output', 'wt', encoding = 'utf-8').write(process_output)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/tmp/src/jsoncpp/1.9.5/test/data/legacy_test_string_unicode_04.process-output'


0% tests passed, 2 tests failed out of 2

Total Test time (real) =   0.18 sec

The following tests FAILED:
	  1 - jsoncpp_readerwriter (Failed)
	  2 - jsoncpp_readerwriter_json_checker (Failed)
Errors while running CTest

To Reproduce
Mount the source tree read-only, configure and build via CMake, and then attempt to run the test suite (e.g. make test).

Expected behavior
The test suite should read from the source tree, write to the build tree, and pass successfully.

(The tests already pass if they are allowed to write to the source tree.)

Desktop (please complete the following information):

  • OS: Linux
  • Meson version: N/A
  • Ninja version: N/A

Additional context
It is critical that the normal build and test process not require writing to the source tree. Not only is mounting the source tree read-only a standard approach in production workflows, reproducible builds often rely on file timestamps in the source tree to set SOURCE_DATE_EPOCH to an appropriate value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant