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

Handling forked VM timeout in a similar way to junit ant task #197

Closed
wants to merge 1 commit into from

Conversation

tkowalcz
Copy link
Contributor

@tkowalcz tkowalcz commented Jan 4, 2023

so that settings like haltonfailure have effect. This strives to make junitlauncher task behave similar to junit (4) task.

@tkowalcz tkowalcz changed the title Handling forked VM timeout in a similar way as failed test Handling forked VM timeout in a similar way to junit ant task Jan 4, 2023
// test has failure(s)
try {
if (test.getFailureProperty() != null) {
// if there are test failures and the test is configured to set a property in case
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit - I think this comment should say "if a test timed out ...."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are correct.

if (test.isHaltOnFailure()) {
throw new BuildException(new TimeoutException("Forked test(s) timed out"));
} else {
log("Timeout occurred. Please note the time in the report does not reflect the time until the timeout.");
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps remove the report part from this log message and instead just say log("Some test(s) timed out")?

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 copied the message as it appears in junit4. I don't have opinion one way or the other.

@jaikiran
Copy link
Member

Thank you Tomasz for this PR. I think this change looks fine. Could you add a test case to verify this change works as expected. We have a junitlauncher test class at src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java which uses the src/etc/testcases/taskdefs/optional/junitlauncher.xml as the build file to test. Perhaps you could add a new test method to it to try a test which times out intentionally after a few seconds?

@tkowalcz
Copy link
Contributor Author

Thanks for review. I will make changes as you suggested and of course write a test.

@jaikiran
Copy link
Member

jaikiran commented Feb 6, 2023

Hello Tomasz, I don't want to rush you, but if writing a test is proving to be time consuming or complicated, do let me know and I'll merge this fix (which looks good to me) and I'll add a test myself.

@tkowalcz
Copy link
Contributor Author

tkowalcz commented Feb 6, 2023

Hi, actually I had problems running the tests in the first place. When I build the project the tests do not seem to be executed (build pass even when I introduce failing assertion). I can later today copy exactly which steps I made.

@jaikiran
Copy link
Member

jaikiran commented Feb 6, 2023

When I build the project the tests do not seem to be executed

Some of the tasks in Ant, including the junitlauncher aren't part of the "core". You will have to first fetch the dependencies of these tasks as follows:

ant -f fetch.xml -Ddest=optional

and then run:

./build.sh clean test

@tkowalcz
Copy link
Contributor Author

tkowalcz commented Feb 6, 2023

Thanks. I will give it a try and let you know.

@tkowalcz
Copy link
Contributor Author

@jaikiran I'm sorry but I was unable to run the tests. After implementing your instructions the LegacyXmlResultFormatterTest was run but there was no mention of JUnitLauncherTaskTest being run. I tried investigating this on multiple fronts but still have no idea how to run it as part of the suite.

@jaikiran
Copy link
Member

The change in this PR looks fine to me. A test can be added separately - I haven't found the time to try and help you get the test implemented/run. I'll go ahead and merge this now and will add the test later.

@asfgit asfgit closed this in 8fb5487 Apr 18, 2023
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