-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a002170
commit c80ad2b
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Author: Jean-Philippe Lapointe | ||
Make sure fastcov's gcov prefix options are processing the file paths as expected | ||
""" | ||
|
||
import pytest | ||
import fastcov | ||
|
||
from dataclasses import dataclass | ||
import os | ||
|
||
@dataclass | ||
class TestSet: | ||
__test__ = False | ||
path: str | ||
prefix: str | ||
prefix_strip: int | ||
expected_result: str | ||
|
||
|
||
def test_simpleStripping(): | ||
testPatterns = [ | ||
# Making the path relative to the root of the git repo | ||
TestSet('/home/user1/work/git/repo/subdir/to/some/file.cpp', '', 5, 'subdir/to/some/file.cpp'), | ||
# Essentially changing user directory from user1 to user2 | ||
TestSet('/home/user1/work/git/repo/subdir/to/some/file.cpp', '/home/user2', 2, '/home/user2/work/git/repo/subdir/to/some/file.cpp'), | ||
# Relative path, shouldn't get modified. | ||
TestSet('subdir/to/some/file.cpp', '/home/user2', 2, 'subdir/to/some/file.cpp'), | ||
# Current file should exist, it won't get messed with | ||
TestSet(os.path.abspath(__file__), '/home/user2', 1, os.path.abspath(__file__)), | ||
# Just prefixing an already absolute path | ||
TestSet('/usr/include/someUnknownHeaderFile.h', '/home/user2/work/git/repo', 0, '/home/user2/work/git/repo/usr/include/someUnknownHeaderFile.h') | ||
] | ||
|
||
for elem in testPatterns: | ||
assert(fastcov.processPrefix(elem.path, elem.prefix, elem.prefix_strip) == elem.expected_result) |