-
Notifications
You must be signed in to change notification settings - Fork 101
Fix relative paths, again #418
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
danmar
merged 17 commits into
cppcheck-opensource:master
from
Tal500:fix-relative-paths2
May 9, 2025
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c912799
Revert "Revert "fix: use both absolute and relative header paths in h…
702e6af
fix: omit duplicated startsWith() definition
654a64b
fix: convert windows TCHAR* to char* correctly
0303122
fix: add missing windows string conversion header
4b19818
fix: use CW2A instead of the obsolete CT2CA for windows string conver…
1b6d1a8
fix: include atlconv.h before windows.h
1ff90af
fix: windows string conversion again
1dc8c77
fix: use #ifdef _UNICODE in windows
e0efd63
typo fix
ea0627d
call `simplecpp::simplifyPath()` before returning the result in `toAb…
Tal500 477705f
join the _ trick party
b1c32a9
Merge branch 'fix-relative-paths2' of https://github.com/Tal500/simpl…
6167676
Merge branch 'danmar:master' into fix-relative-paths2
Tal500 b90d5c5
fix OS calc of current directory and fix windows headers inclusion
26fe250
Merge branch 'master' into fix-relative-paths2
danmar 51d1e6f
Update CI-unixish.yml: trying to not upgrade pip
Tal500 6797a29
Update CI-windows.yml: returning Python installation
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,94 @@ | ||
| ## test with python -m pytest integration_test.py | ||
|
|
||
| import os | ||
| import pytest | ||
| 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, inv=False): | ||
| if inv: | ||
| return __test_relative_header_create_source(dir, include1=include2, include2=include1, is_include1_sys=is_include2_sys, is_include2_sys=is_include1_sys) | ||
| ## otherwise | ||
|
|
||
| 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 | ||
|
|
||
| @pytest.mark.parametrize("with_pragma_once", (False, True)) | ||
| @pytest.mark.parametrize("is_sys", (False, True)) | ||
| def test_relative_header_1(tmpdir, with_pragma_once, is_sys): | ||
| _, double_include_error = __test_relative_header_create_header(tmpdir, with_pragma_once=with_pragma_once) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", "test.h", is_include1_sys=is_sys, is_include2_sys=is_sys) | ||
|
|
||
| args = ([format_include_path_arg(tmpdir)] if is_sys else []) + [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
|
|
||
| if with_pragma_once: | ||
| assert stderr == '' | ||
| else: | ||
| assert double_include_error in stderr | ||
|
|
||
| @pytest.mark.parametrize("inv", (False, True)) | ||
| def test_relative_header_2(tmpdir, inv): | ||
| header_file, _ = __test_relative_header_create_header(tmpdir) | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, "test.h", header_file, inv=inv) | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' | ||
|
|
||
| @pytest.mark.parametrize("is_sys", (False, True)) | ||
| @pytest.mark.parametrize("inv", (False, True)) | ||
| def test_relative_header_3(tmpdir, is_sys, inv): | ||
| 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, is_include1_sys=is_sys, inv=inv) | ||
|
|
||
| args = [test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
|
|
||
| if is_sys: | ||
| assert "missing header: Header not found" in stderr | ||
| else: | ||
| assert stderr == '' | ||
|
|
||
| @pytest.mark.parametrize("use_short_path", (False, True)) | ||
| @pytest.mark.parametrize("is_sys", (False, True)) | ||
| @pytest.mark.parametrize("inv", (False, True)) | ||
| def test_relative_header_4(tmpdir, use_short_path, is_sys, inv): | ||
| test_subdir = os.path.join(tmpdir, "test_subdir") | ||
| os.mkdir(test_subdir) | ||
| header_file, _ = __test_relative_header_create_header(test_subdir) | ||
| if use_short_path: | ||
| header_file = "test_subdir/test.h" | ||
|
|
||
| test_file = __test_relative_header_create_source(tmpdir, header_file, "test.h", is_include2_sys=is_sys, inv=inv) | ||
|
|
||
| args = [format_include_path_arg(test_subdir), test_file] | ||
|
|
||
| _, _, stderr = simplecpp(args, cwd=tmpdir) | ||
| assert stderr == '' |
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
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.