Skip to content
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

test: ExportableFixture for JSON tests exporting #821

Merged
merged 4 commits into from
Feb 21, 2024
Merged

Conversation

chfast
Copy link
Member

@chfast chfast commented Feb 19, 2024

Extract utils for JSON tests exporting to abstract ExportableFixture.

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (34c0169) 97.98% compared to head (5de76a6) 97.98%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #821   +/-   ##
=======================================
  Coverage   97.98%   97.98%           
=======================================
  Files         113      114    +1     
  Lines       11155    11158    +3     
=======================================
+ Hits        10930    10933    +3     
  Misses        225      225           
Flag Coverage Δ
blockchaintests 59.70% <ø> (ø)
statetests 62.18% <ø> (ø)
statetests-silkpre 24.47% <0.00%> (-0.02%) ⬇️
unittests 96.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
test/unittests/eof_validation_stack_test.cpp 100.00% <ø> (ø)
test/unittests/exportable_fixture.cpp 100.00% <100.00%> (ø)
test/unittests/state_transition.cpp 97.80% <100.00%> (-0.28%) ⬇️
test/unittests/state_transition.hpp 0.00% <ø> (ø)

class ExportableFixture : public testing::Test
{
protected:
std::unique_ptr<std::ostream> export_out;
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work, it has to be std::unique_ptr<std::ofstream> otherwise proper file stream destructor is not called and file is not written to disk.

Copy link
Member Author

Choose a reason for hiding this comment

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

What a hell? Am I doing something wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

Still not sure why it doesn't work. But this is fixed differently now because we also want to avoid creating empty files. So the file creation is left up to the concrete test suite.

I also added a cmake test that verifies an example file was created during export.

Copy link
Member

Choose a reason for hiding this comment

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

Still not sure why it doesn't work

I'm also not sure anymore, becaue apparently destructor is indeed virtual 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to reproduce the same issue.

@chfast chfast merged commit 5492627 into master Feb 21, 2024
25 checks passed
@chfast chfast deleted the test/exportable branch February 21, 2024 13:37
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.

2 participants