Skip to content

Add an option to only rerun tests that have failed #16263

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

Merged
merged 1 commit into from
Nov 3, 2022

Conversation

G1ng3r
Copy link

@G1ng3r G1ng3r commented Oct 31, 2022

  • testCompilation supports running only failed tests with --failed argument

fixes #3798

@prolativ prolativ self-requested a review October 31, 2022 15:29
@prolativ prolativ self-assigned this Oct 31, 2022
@G1ng3r G1ng3r force-pushed the wip/rerun-only-failed-tests branch 5 times, most recently from 1d8566c to 8417e17 Compare November 2, 2022 10:50
@prolativ
Copy link
Contributor

prolativ commented Nov 2, 2022

@G1ng3r is this ready for review or are you still making some changes?

@SethTisue SethTisue changed the title Closes #3798 Add an option to only rerun tests that have failed Nov 2, 2022
@G1ng3r
Copy link
Author

G1ng3r commented Nov 2, 2022

Hi @prolativ! I think its ready, but not sure. I need someone to approve the solution or give advise on how to improve it. Thanks

@@ -30,6 +30,9 @@ object Properties {
*/
val testsFilter: List[String] = sys.props.get("dotty.tests.filter").fold(Nil)(_.split(',').toList)

/** Run only failed tests */
Copy link
Contributor

Choose a reason for hiding this comment

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

As this pattern starts to repeat, why don't you define a helper method propIsTrue analogous to propIsNullOrTrue and use it here?

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -144,4 +152,15 @@ object TestReporter {
}
rep
}

def lastRunFailedTests: List[String] =
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we make no distinction between the situation when --failed is not enabled and when this option is on but all the tests passed in the previous run. I think we should split these cases, e.g. by returning None in the former case and Some(Nil) in the latter. In general, if all the tests in the previous run passed, I would expect testCompilation --failed to run no tests and give explicit feedback that no tests were run instead of running all the tests.

Copy link
Author

Choose a reason for hiding this comment

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

done

@prolativ prolativ assigned G1ng3r and unassigned prolativ Nov 2, 2022
@G1ng3r G1ng3r force-pushed the wip/rerun-only-failed-tests branch from 8417e17 to ca92351 Compare November 2, 2022 14:34
Comment on lines 157 to 161
Option.when(Properties.rerunFailed)(
if (failedTestsFile.exists() && failedTestsFile.isFile)
then java.nio.file.Files.readAllLines(failedTestsFile.toPath).asScala.toList
else List.empty
)
Copy link
Contributor

@prolativ prolativ Nov 2, 2022

Choose a reason for hiding this comment

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

Suggested change
Option.when(Properties.rerunFailed)(
if (failedTestsFile.exists() && failedTestsFile.isFile)
then java.nio.file.Files.readAllLines(failedTestsFile.toPath).asScala.toList
else List.empty
)
Option.when(
Properties.rerunFailed &&
failedTestsFile.exists() &&
failedTestsFile.isFile
)(java.nio.file.Files.readAllLines(failedTestsFile.toPath).asScala.toList)

Copy link
Contributor

Choose a reason for hiding this comment

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

The absence of failedTestsFile should also mean that we need to run all the tests

Copy link
Author

Choose a reason for hiding this comment

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

done

- testCompilation supports running only failed tests with --failed argument
@G1ng3r G1ng3r force-pushed the wip/rerun-only-failed-tests branch from ca92351 to 6dfc668 Compare November 2, 2022 16:36
@prolativ prolativ merged commit bf808b3 into scala:main Nov 3, 2022
armanbilge pushed a commit to armanbilge/dotty that referenced this pull request Nov 3, 2022
- testCompilation supports running only failed tests with --failed
argument

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

Successfully merging this pull request may close these issues.

Test infrastructure: add an option to only rerun tests that have failed
3 participants