-
Notifications
You must be signed in to change notification settings - Fork 99
fix: use both absolute and relative header paths in header matching #362
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
907c443
fix: always use absolute (and simplified) header path whenever possible
Tal500 4e02592
Merge branch 'master' into absolute-path-header
Tal500 17d74df
respect relative paths, but check both absolute and relative path id …
f156111
simplify path usage functions to be just strings
28cdb8a
tidy fix
2893b68
add integration tests
196a498
run integraion tests on CI-unixish.yml
Tal500 52c77b9
Use `pip --user` to avoid macos14 permission issues in CI-unixish.yml
Tal500 ef7837a
Move the flag `--user` in the pip install row CI-unixish.yml
Tal500 c2e9b67
Try the flag `--break-system-packages` instead of `--user` in CI-unix…
Tal500 26ee4d9
Set in a more poratable way break-system-packages to be true CI-unixi…
Tal500 3b6fc9c
Pytest for Windows in CI-windows.yml
Tal500 9db5d60
Update testutils.py: allow custom SIMPLECPP_EXE_PATH for integration …
Tal500 47853fb
Update CI-windows.yml: pass SIMPLECPP_EXE_PATH env var
Tal500 c026219
Update CI-windows.yml: fix the set command
Tal500 a402c79
use parametrized tests and improve coverage in integration_test.py
Tal500 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -32,3 +32,6 @@ testrunner | |
| # CLion | ||
| /.idea | ||
| /cmake-build-* | ||
|
|
||
| # python | ||
| __pycache__/ | ||
This file contains hidden or 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,131 @@ | ||
| ## test with python -m pytest integration_test.py | ||
|
|
||
| import os | ||
| from testutils import simplecpp, format_include_path_arg, format_include | ||
|
|
||
| def __test_relative_header_create_header(dir, with_pragma_once=True): | ||
| header_file = os.path.join(dir, 'test.h') | ||
| with open(header_file, 'wt') as f: | ||
| f.write(f""" | ||
| {"#pragma once" if with_pragma_once else ""} | ||
| #ifndef TEST_H_INCLUDED | ||
| #define TEST_H_INCLUDED | ||
| #else | ||
| #error header_was_already_included | ||
| #endif | ||
| """) | ||
| return header_file, "error: #error header_was_already_included" | ||
|
|
||
| def __test_relative_header_create_source(dir, include1, include2, is_include1_sys=False, is_include2_sys=False): | ||
| src_file = os.path.join(dir, 'test.c') | ||
| with open(src_file, 'wt') as f: | ||
| f.write(f""" | ||
| #undef TEST_H_INCLUDED | ||
| #include {format_include(include1, is_include1_sys)} | ||
| #include {format_include(include2, is_include2_sys)} | ||
| """) | ||
| return src_file | ||
|
|
||
|
|
||
| def test_relative_header_0_rel(tmpdir): | ||
| _, double_include_error = __test_relative_header_create_header(tmpdir, with_pragma_once=False) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", "test.h") | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert double_include_error in stderr | ||
|
|
||
| def test_relative_header_0_sys(tmpdir): | ||
| _, double_include_error = __test_relative_header_create_header(tmpdir, with_pragma_once=False) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", "test.h", is_include1_sys=True, is_include2_sys=True) | ||
|
|
||
| args = [format_include_path_arg(tmpdir), test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args) | ||
| assert double_include_error in stderr | ||
|
|
||
| def test_relative_header_1_rel(tmpdir): | ||
| __test_relative_header_create_header(tmpdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", "test.h") | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
|
|
||
| def test_relative_header_1_sys(tmpdir): | ||
| __test_relative_header_create_header(tmpdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", "test.h", is_include1_sys=True, is_include2_sys=True) | ||
|
|
||
| args = [format_include_path_arg(tmpdir), test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args) | ||
| assert stderr == '' | ||
|
|
||
| ## TODO: the following tests should pass after applying simplecpp#362 | ||
|
|
||
| def test_relative_header_2(tmpdir): | ||
| header_file, _ = __test_relative_header_create_header(tmpdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", header_file) | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
|
|
||
| def test_relative_header_3(tmpdir): | ||
| test_subdir = os.path.join(tmpdir, "test_subdir") | ||
| os.mkdir(test_subdir) | ||
| header_file, _ = __test_relative_header_create_header(test_subdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test_subdir/test.h", header_file) | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
|
|
||
| def test_relative_header_3_inv(tmpdir): | ||
| test_subdir = os.path.join(tmpdir, "test_subdir") | ||
| os.mkdir(test_subdir) | ||
| header_file, _ = __test_relative_header_create_header(test_subdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, header_file, "test_subdir/test.h") | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
|
|
||
|
|
||
| def test_relative_header_4(tmpdir): | ||
| test_subdir = os.path.join(tmpdir, "test_subdir") | ||
| os.mkdir(test_subdir) | ||
| header_file, _ = __test_relative_header_create_header(test_subdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, header_file, "test.h", is_include2_sys=True) | ||
|
|
||
| args = [format_include_path_arg(test_subdir), test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
|
|
||
|
|
||
|
|
||
| def test_relative_header_5(tmpdir): | ||
| test_subdir = os.path.join(tmpdir, "test_subdir") | ||
| os.mkdir(test_subdir) | ||
| __test_relative_header_create_header(test_subdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", "test_subdir/test.h", is_include1_sys=True) | ||
|
|
||
| args = [format_include_path_arg(test_subdir), test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.