Catch's ApprovalTests test fail if build directory was reached via a symbolic link
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
When building/testing Catch2 in a directory that was reached via a symbolic link, the `ApprovalTests xml.sw` test fails.
Here's an example failure line from `build/Testing/Temporary/LastTest.log` which illustrates the gist of the problem:
```
+
-
```
Notice that the directory path has not been correctly sanitized, i.e., it still contains the `/home/dj/tmp/Catch2-2.9.1` prefix.
In this case, `/home/dj/tmp` is a symbolic link to the fully resolved directory name, `/data/macabretmp/dj/`. The `scripts/approvalTests.py` program, which is responsible for this test, uses this code in `scripts/scriptCommon.py` to determine the prefix to strip:
```
catchPath = os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0])))
```
which in my case is equivalent to setting it to `/data/macabretmp/dj`, not to the required value of `/home/dj/tmp`.
One approach to avoiding this would be for `scripts/scriptCommon.py` to parse the directory from one of the CMake artifacts in the build directory.
**Expected behavior**
I expect that the tests work regardless of whether or not the directory is reached via a symbolic link.
**Platform information:**
- OS: **Debian 9**
- Compiler+version: **GCC v6.3.0**
- Catch version: **v2.9.1**
Contributor guide
Research direction
Start with scripts/approvalTests.py and scripts/scriptCommon.py, especially how catchPath is derived. Reproduce the ApprovalTests xml.sw failure from a build directory reached through a symbolic link, then run the related test and confirm that generated paths are sanitized consistently in both direct and symlinked paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100