Skip to content

Conversation

Gnimuc
Copy link
Contributor

@Gnimuc Gnimuc commented Jan 13, 2025

Description

as per #440 (comment)

Fixes # (issue)

Type of change

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Requires documentation updates

Testing

Please describe the test(s) that you added and ran to verify your changes.

Checklist

  • I have read the contribution guide recently

@Gnimuc Gnimuc changed the title Improve the test coverage of the C API -- Take 1 Improve the test coverage of the C API Jan 13, 2025
Copy link
Contributor

@github-actions github-actions bot left a 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

@Gnimuc Gnimuc marked this pull request as ready for review January 13, 2025 10:16
Copy link
Contributor

@github-actions github-actions bot left a 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

Copy link
Contributor

@github-actions github-actions bot left a 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

@Gnimuc Gnimuc force-pushed the c-api-test branch 3 times, most recently from 6f81874 to 11fea7d Compare January 13, 2025 11:57
Copy link
Contributor

@github-actions github-actions bot left a 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

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.31%. Comparing base (f0f59f2) to head (35cbc9c).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #447      +/-   ##
==========================================
+ Coverage   72.71%   75.31%   +2.59%     
==========================================
  Files           9        9              
  Lines        3618     3617       -1     
==========================================
+ Hits         2631     2724      +93     
+ Misses        987      893      -94     
Files with missing lines Coverage Δ
lib/Interpreter/CXCppInterOp.cpp 47.27% <100.00%> (+25.18%) ⬆️
lib/Interpreter/CppInterOp.cpp 83.03% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

Files with missing lines Coverage Δ
lib/Interpreter/CXCppInterOp.cpp 47.27% <100.00%> (+25.18%) ⬆️
lib/Interpreter/CppInterOp.cpp 83.03% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


// C API
auto* I = clang_createInterpreterFromRawPtr(Cpp::GetInterpreter());
EXPECT_TRUE(clang_hasDefaultConstructor(make_scope(Decls[0], I)));
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Gnimuc Gnimuc force-pushed the c-api-test branch 2 times, most recently from 2a1eca2 to 0420a80 Compare January 18, 2025 06:03
Copy link
Contributor

@github-actions github-actions bot left a 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

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Jan 18, 2025

This only improved the coverage from 70% to 74% because as I said before nearly half of the code are from libclang.

Copy link
Contributor

@github-actions github-actions bot left a 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

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 9, 2025

@mcbarton @vgvassilev

I think this is ready to merge.

@vgvassilev
Copy link
Contributor

@mcbarton @vgvassilev

I think this is ready to merge.

Seems so. Please address the clang-tidy suggestions and we should be good to go.

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 9, 2025

done!

@mcbarton
Copy link
Collaborator

@Gnimuc can you rebase? Now that we have automated wasm tests we need to just double check that the new tests pass for an Emscripten build. Once the ci passes after rebase I will approve and merge.

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 15, 2025

@mcbarton any hints on how to investigate those Emscripten build errors?

@mcbarton
Copy link
Collaborator

@Gnimuc My suggestion is to wait for this PR to go in #523 and rebase. This PR will fix the current crashing tests, so hopefully it will fix your tests too (or at least allow to have more useful error messages)

@mcbarton
Copy link
Collaborator

@anutosh491 I had a quick go at trying to fix the errors without success. Do you have any suggestions about what @Gnimuc can try to debug/fix the failing/crashing tests?

@anutosh491
Copy link
Collaborator

Hmmm, can look into it in a while

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 19, 2025

@anutosh491 does Emscripten build need any special setup when creating the interpreter instance? The current interpreter C API is not equivalent to the C++ one(it's just a thin wrapper over clang::Interpreter with no additional setups), so probably we should just skip those C API tests on Emscripten?

@anutosh491
Copy link
Collaborator

anutosh491 commented Mar 19, 2025

so probably we should just skip those C API tests on Emscripten?

Yeah absolutely we can do that for now. Its not suprising atleast to me to see things work natively and not with emscripten right now. I would not stress on getting it to pass through this PR itself. Let's skip it for now.

@mcbarton as you've been monitoring the emscripten tests my suggestion here is to let this one go and we create a todo-list through an issue to keep track and keep addressing one skipped test at a time. I see only two reasons for tests to fail right now

i) some tests are not catered for the emscripten build (for eg the functions for detecting resource dir use system calls that won't (shouldn't) work with emscripten ... so we just update it to returning an empty string cause that's expected)
ii) errors/missing implementation in clang-repl-lite

We have all tools to address i if not ii which will be done slowly.

@anutosh491
Copy link
Collaborator

Hey @Gnimuc

I see two errors here. I would only expect the 1st one be addressed cause that's doable.

  1. The first one says this as shown here
TypeError: resolved is not a function

What this basically means is its trying to call an undefined symbol at runtime. Doing some more debugging shows me this is the exact symbol, I had added some PRs back (reasoning on why it is missing should be mentioned there)
Check #425

So if you export this like I did, the first one would be resolved (and possibly we can close my PR then)

  1. Coming to the 2nd one. I see this being added
  clang_Interpreter_addSearchPath(CXI, "dummy", false, false);
  clang_Interpreter_addIncludePath(CXI, "dummy");
  

Search paths for native cases vs for emscripten cases where a virtual file system is being put to use should work differently. So I would not stress on getting this to pass just yet. Could you please skip this ? I think this should be ready then.

P:S Not sure how important those 2 lines are. Probably just commenting them out or removing should be enough too ?

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 24, 2025

@anutosh491 Thanks for looking into this. I cherry-picked your commit and did a rebase. 🤞🏻

clang_Interpreter_addSearchPath(CXI, "dummy", false, false);
clang_Interpreter_addIncludePath(CXI, "dummy");

That's my ugly trick for improving the coverage.😅 Let’s remove them until we figure out a way to do a proper test.

@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 24, 2025

Oops! Should not just cherry-pick that commit. I manually applied the changes.

@anutosh491
Copy link
Collaborator

Let’s remove them until we figure out a way to do a proper test.

Perfect. Nothing wrong with that I think

Copy link
Collaborator

@anutosh491 anutosh491 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the emscripten tests pass now.

If these are all the tests that were meant to be addressed through this PR (someone can let me know if this is all) then this should be ready I think !

PRIVATE "SHELL: -s WASM_BIGINT"
PRIVATE "SHELL: -s SIDE_MODULE=1"
PRIVATE "SHELL: ${SYMBOLS_LIST}"
PUBLIC "SHELL: -Wl,--export=__clang_Interpreter_SetValueNoAlloc"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be added to the exports.ld file we already have. e.g. here https://github.com/Gnimuc/CppInterOp/blob/c-api-test/lib/Interpreter/exports.ld

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done too through a subsequent PR.

@vgvassilev vgvassilev merged commit 6dc5278 into compiler-research:main Mar 24, 2025
73 checks passed
@Gnimuc Gnimuc mentioned this pull request Mar 24, 2025
4 tasks
@Gnimuc Gnimuc deleted the c-api-test branch March 24, 2025 11:19
@Gnimuc
Copy link
Contributor Author

Gnimuc commented Mar 24, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants