Skip to content

Tests write to source tree when invoked via CMake #1515

Description

@iskunk

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbuildBuild/compilation related

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions