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

Use require for loading OpenQA::Test::Database #5756

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

perlpunk
Copy link
Contributor

It does a

plan skip_all ...

in its main code, which is effectively an exit.
Since that happens in a BEGIN block currently during a 'use', it won't execute any INIT blocks any more in perl version >= 5.38. But the -c compile check is running in an INIT block.

Issue: https://progress.opensuse.org/issues/162866

It does a

    plan skip_all ...

in its main code, which is effectively an exit.
Since that happens in a BEGIN block currently during a 'use', it won't execute
any INIT blocks any more in perl version >= 5.38. But the -c compile
check is running in an INIT block.

Issue: https://progress.opensuse.org/issues/162866
Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

Please rephrase the git commit message subject line to state the "Why", not the "What".

Now seeing the code I remember that already in many other cases we applied the best practice to not use any Test::More calls in test helper libraries so maybe we can do that instead? So replace the "plan skip_all" in OpenQA::Test::Database with a "warn" and empty return maybe? As we check for warnings in tests that would still prevent that tests are not executed unnoticed.

@@ -10,7 +10,7 @@ use Test::MockModule;
use Test::Mojo;
use Test::Output 'combined_like';
use Test::Warnings;
use OpenQA::Test::Database;
require OpenQA::Test::Database;
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to add a comment in each line to explain why we use require as exception, e.g.

Suggested change
require OpenQA::Test::Database;
require OpenQA::Test::Database; # "require" is needed due to "plan skip_all" in BEGIN

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also that's a bit inaccurate. It's to avoid happening plan skip_all in BEGIN

@perlpunk
Copy link
Contributor Author

Feel free to take over the ticket

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.43%. Comparing base (63bc4d0) to head (d0bc501).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5756      +/-   ##
==========================================
- Coverage   98.43%   98.43%   -0.01%     
==========================================
  Files         393      393              
  Lines       38594    38593       -1     
==========================================
- Hits        37991    37990       -1     
  Misses        603      603              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Martchus
Copy link
Contributor

But yes, the commit message should be something like "Fix compile checks ..." to state the why.

I don't think adding a comment on every require is necessary, though. Maybe we can enforce this via a style check or make our even add tests for this.

@mergify mergify bot merged commit 8c0805d into os-autoinst:master Jul 16, 2024
42 checks passed
@perlpunk perlpunk deleted the require-instead-of-use branch July 16, 2024 13:16
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.

3 participants