open-source-parsers / open-source-parsers/jsoncpp

Tests write to source tree when invoked via CMake

Open
#1,515 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug build
Dominant language
C++
Stars
8.9k
Forks
2.7k
Avg merge
31m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test/runjsontests.py, especially runAllTests where .process-output is written, and inspect how the CMake test invokes it from the out-of-source build. Reproduce with a read-only source tree and run ctest --rerun-failed --output-on-failure. Done means the tests read source data, write generated files under the build tree, and pass without modifying the source tree.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, python
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.