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

Fix UnitTestRunResults interface to be compatible with UnitTestRunDeltaResults #434

Merged

Conversation

audricschiltknecht
Copy link
Contributor

The Publisher::publish_comment method calls some properties that were not defined on UnitTestRunResults.

@audricschiltknecht
Copy link
Contributor Author

Using the following configuration:

      - name: Publish Test Results - Expected failures
        uses: EnricoMi/publish-unit-test-result-action@v2
        if: always()
        with:
          check_name: "Expected failures"
          files: '**/testing/unittest.xml'
          fail_on: "nothing"
          comment_mode: "changes in failures"

this was causing the following error:

 2023-03-28 22:47:54 +0000 - publish -  INFO - Created job summary
Traceback (most recent call last):
  File "/action/publish_test_results.py", line 540, in <module>
    main(settings, gha)
  File "/action/publish_test_results.py", line 260, in main
    Publisher(settings, gh, gha).publish(stats, results.case_results, conclusion)
  File "/action/publish/publisher.py", line 203, in publish
    self.publish_comment(self._settings.comment_title, stats, pull, check_run, cases)
  File "/action/publish/publisher.py", line 536, in publish_comment
    if not self.require_comment(stats_with_delta, earlier_stats):
  File "/action/publish/publisher.py", line 595, in require_comment
    stats.has_failure_changes,
AttributeError: 'UnitTestRunResults' object has no attribute 'has_failure_changes'

@EnricoMi
Copy link
Owner

Thanks for reporting this.

The convention is to rather check for stats.is_delta == True before accessing methods that only exist in UnitTestRunDeltaResults. So I think

stats.has_failure_changes

should read

stats.is_delta and stats.has_failure_changes

wherever stats is UnitTestRunResultsOrDeltaResults.

…taResults

The Publisher::publish_comment method calls some properties that were
not defined on UnitTestRunResults.
@audricschiltknecht audricschiltknecht force-pushed the fix-publish-comment-conditions branch from 88fc7cf to 6cd99f8 Compare March 29, 2023 11:45
@audricschiltknecht
Copy link
Contributor Author

Thanks, adapted.

@EnricoMi
Copy link
Owner

Thanks, I have added some tests that would have caught this issue.

@EnricoMi EnricoMi merged commit 52aabbd into EnricoMi:master Mar 29, 2023
@EnricoMi
Copy link
Owner

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.

2 participants