-
Notifications
You must be signed in to change notification settings - Fork 55
[tests] Add edge case coverage for CopyIncludePaths in Paths.cpp #862
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
Open
voyager-jhk
wants to merge
14
commits into
compiler-research:main
Choose a base branch
from
voyager-jhk:add-paths-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dbf5d49
Make DispatchInitializer thread-safe using function-local static
voyager-jhk 68e4ba3
Address clang-tidy warnings
voyager-jhk d406e0c
Move DispatchInitializer to function static for thread safety
voyager-jhk 860daa4
Fix global initialization to satisfy clang-tidy
voyager-jhk 45d4e9e
[tests] Add edge case coverage for CopyIncludePaths in Paths.cpp
voyager-jhk 6ded7c3
chore: revert accidental changes to unittests Utils.cpp
voyager-jhk 673ed62
sort #includes properly
voyager-jhk cad8558
fix: export CopyIncludePaths with CPPINTEROP_API
voyager-jhk 6d21c14
Apply suggestion from @github-actions[bot]
voyager-jhk 26d173c
style: clean up duplicated includes from bot suggestions
voyager-jhk 9525d86
fix: include CppInterOp.h for CPPINTEROP_API macro definition
voyager-jhk d4655bb
test: rewrite PathsTest to use public CppInterOp API
voyager-jhk afbcec7
chore: remove extra space
voyager-jhk 81f0002
test: fix Clang arguments in PathsTest to test edge cases safely
voyager-jhk 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #include "gtest/gtest.h" | ||
| #include "clang/Lex/HeaderSearchOptions.h" | ||
| #include "llvm/ADT/SmallVector.h" | ||
| #include <string> | ||
| #include <algorithm> | ||
| #include <string> | ||
voyager-jhk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| #include "../../lib/CppInterOp/Paths.h" | ||
|
|
||
| namespace { | ||
|
|
||
| TEST(PathsTest, CopyIncludePathsEdgeCases) { | ||
| clang::HeaderSearchOptions Opts; | ||
|
|
||
| // Set up edge-case flags to trigger uncovered branches | ||
| Opts.ModuleCachePath = "/tmp/fake_cache"; // Triggers -fmodule-cache-path | ||
| Opts.UseStandardSystemIncludes = false; // Triggers -nostdinc | ||
| Opts.UseStandardCXXIncludes = false; // Triggers -nostdinc++ | ||
| Opts.UseLibcxx = true; // Triggers -stdlib=libc++ | ||
| Opts.Verbose = true; // Triggers -v | ||
|
|
||
| llvm::SmallVector<std::string, 16> IncPaths; | ||
|
|
||
| CppInternal::utils::CopyIncludePaths(Opts, IncPaths, true, true); | ||
|
|
||
| auto Contains = [&](const std::string& flag) { | ||
| return std::find(IncPaths.begin(), IncPaths.end(), flag) != IncPaths.end(); | ||
| }; | ||
|
|
||
| // Verify the results | ||
| EXPECT_TRUE(Contains("-fmodule-cache-path")); | ||
| EXPECT_TRUE(Contains("/tmp/fake_cache")); | ||
| EXPECT_TRUE(Contains("-nostdinc")); | ||
| EXPECT_TRUE(Contains("-nostdinc++")); | ||
| EXPECT_TRUE(Contains("-stdlib=libc++")); | ||
| EXPECT_TRUE(Contains("-v")); | ||
| } | ||
|
|
||
| } // end anonymous namespace | ||
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.