-
Notifications
You must be signed in to change notification settings - Fork 27
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
Improve the test coverage of the C API #447
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
6f81874
to
11fea7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
EXPECT_TRUE(Cpp::Process("") == 0); | ||
EXPECT_TRUE(Cpp::Process("int a = 12;") == 0); | ||
EXPECT_FALSE(Cpp::Process("error_here;") == 0); | ||
// Linker/JIT error. | ||
EXPECT_FALSE(Cpp::Process("int f(); int res = f();") == 0); | ||
|
||
// C API | ||
auto CXI = clang_createInterpreterFromRawPtr(I); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'auto CXI' can be declared as 'auto *CXI' [llvm-qualified-auto]
auto CXI = clang_createInterpreterFromRawPtr(I); | |
auto *CXI = clang_createInterpreterFromRawPtr(I); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a good suggestion.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #447 +/- ##
==========================================
+ Coverage 71.15% 74.92% +3.76%
==========================================
Files 9 9
Lines 3550 3549 -1
==========================================
+ Hits 2526 2659 +133
+ Misses 1024 890 -134
... and 2 files with indirect coverage changes
|
|
||
// C API | ||
auto* I = clang_createInterpreterFromRawPtr(Cpp::GetInterpreter()); | ||
EXPECT_TRUE(clang_hasDefaultConstructor(make_scope(Decls[0], I))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should put the tests for the c layer in a separate file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's practical at the moment because of the low API coverage. We need to use a lot C++ API to set up the environment and do the test.
2a1eca2
to
0420a80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
output = testing::internal::GetCapturedStdout(); | ||
EXPECT_EQ(output, "Constructor Executed"); | ||
output.clear(); | ||
auto dummy = clang_allocate(8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'auto dummy' can be declared as 'auto *dummy' [llvm-qualified-auto]
auto dummy = clang_allocate(8); | |
auto *dummy = clang_allocate(8); |
This only improved the coverage from 70% to 74% because as I said before nearly half of the code are from libclang. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@@ -15,6 +15,8 @@ | |||
|
|||
#include "llvm/Support/Valgrind.h" | |||
|
|||
#include "clang-c/CXCppInterOp.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: duplicate include [readability-duplicate-include]
unittests/CppInterOp/ScopeReflectionTest.cpp:16:
-
- #include "clang-c/CXCppInterOp.h"
Description
as per #440 (comment)
Fixes # (issue)
Type of change
Please tick all options which are relevant.
Testing
Please describe the test(s) that you added and ran to verify your changes.
Checklist