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

Fail tests marked with .only if running in CI #598

Merged
merged 2 commits into from
Nov 15, 2022

Conversation

callado4
Copy link
Contributor

@callado4 callado4 commented Nov 1, 2022

Implements #590

@callado4
Copy link
Contributor Author

callado4 commented Nov 1, 2022

Something seems wrong since github believes my fork's master is in sync based on commit 44c2ba but master currently should be much later. I need to do some git-fu and update my PR (I want it to be based off the master in this repo)

It seems the default branch changed to main after I did a fork so I just had to update the main branch on my fork to be main too.

@callado4 callado4 force-pushed the issue-590-fail-only-on-ci branch from fba05e4 to 7b1c57d Compare November 1, 2022 16:15
Comment on lines +129 to +141
private[this] def onlyNotOnCiFailure(test: TestName): TestOutcome = {
val result = Result.Failure(
msg = "'Only' tag is not allowed when `isCI=true`",
source = None,
location = List(test.location)
)
TestOutcome(
name = test.name,
duration = FiniteDuration(0, "ns"),
result = result,
log = Chain.empty
)
}
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 think this makes sense for making a failing test outcome, but if there is a better way, please let me know.

A few things that I wanted to clarify

  • msg in the result is the same message used in Munit
  • source in result is None, this was't caused by an exception so no need to provide an exception (right?)
  • location in result, using the location of the test definition itself as a single entry, is this what is expected here?
  • duration is TestOutcome set to 0 since this test didn't actually run - is this fine?
  • I provided an empty chain for TestOutcome.log, but do we want something here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, this all looks good to me :)

Comment on lines 114 to 119
else if (testsTaggedOnly.nonEmpty && isCI) {
val failureOutcomes = testsTaggedOnly
.map(_._1)
.map(onlyNotOnCiFailure)
Stream.emits(failureOutcomes).lift[F](effectCompat.effect)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want the tests to fail if there would end up being no tests to run, but there was something tagged .only? For example, a suite with just one test that has both .only and .ignore would be caught in the first if condition here and so we would return a Stream.empty, i.e., no tests would be run at all (and the .only is ignored).

On the other hand, if there are any tests to be run, and any of the other tests are marked as .only and .ignore we will fail (we will report all tests marked with .only)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd swap both conditions so that the isCI flag would be checked first, and result in a failure if enabled and in the presence of any .only. The reason is that the behaviour would be surprising in a later PR when tests are added and there might be a cognitive disconnect between the suite failing and the addition of .only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@callado4 callado4 requested a review from Baccata November 7, 2022 14:29
@Baccata Baccata merged commit fd7153f into disneystreaming:main Nov 15, 2022
@Baccata
Copy link
Contributor

Baccata commented Nov 15, 2022

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