Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Issue/55 timedout #85

Closed
wants to merge 4 commits into from
Closed

Conversation

som-snytt
Copy link
Contributor

Let a timeout fail the build.

Runner.run determines the test state instead of throwing.

@@ -759,7 +759,7 @@ class SuiteRunner(
// |Java Classpath: ${sys.props("java.class.path")}
}

def onFinishTest(testFile: File, result: TestState): TestState = result
def onFinishTest(@deprecated("unused","") testFile: File, result: TestState): TestState = result
Copy link
Member

Choose a reason for hiding this comment

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

this is fighting a symptom..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the disease called "object-orientation"?

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it only warn on effectively final methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dwijnand I think that weakens the warning. Maybe two modes? strict vs non-strict? By the time you've written final, you're less likely to have made a careless mistake such as this is designed to catch. So strict mode would mean "I think I was careful."

Copy link
Member

Choose a reason for hiding this comment

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

Sure, it weakens it, but I think I prefer a warning that you don't have to workaround.

(As a complete aside, IMO things should be final by default and you should have to annotate it open, or something, rather than have to declare things final).

comment(passFailString(passed.size, failed.size, 0) + " in " + kind)
if (limping) comment(s"suite already in failure, skipping") else {
val results = suiteRunner.runTestsForFiles(paths.map(_.jfile.getAbsoluteFile)) match {
case Left((e, states)) => limping = true ; states
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't the unused e warn? maybe that was one of the todo's noted in the tests for warnings.

Copy link
Contributor Author

@som-snytt som-snytt Apr 14, 2017

Choose a reason for hiding this comment

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

No, it's not built with the latest warnings yet. But for some reason it warns twice.

The result `TestState` is determined when the test is run
(rather than throwing exceptions to enclosing infrastructure).
Tests which haven't completed are deemed pending.

Previously, tests that hadn't completed were deemed skipped.
But skipping tests doesn't fail the build.

Sample output with very short partest.timeout:

```
Selected 1815 tests drawn from 1 named test categories

ok    1 - run/Course-2002-01.scala
Thread pool timeout elapsed before all tests were complete!
!!    2 - run/Course-2002-03.scala                  [non-zero exit code]
!!    4 - run/Course-2002-02.scala                  [non-zero exit code]
!!    3 - run/Course-2002-04.scala                  [non-zero exit code]
!!    5 - run/Course-2002-05.scala                  [non-zero exit code]
!!    6 - run/Course-2002-06.scala                  [non-zero exit code]
!!    7 - run/Course-2002-08.scala                  [non-zero exit code]

partest --update-check \
  /home/apm/projects/snytt/test/files/run/Course-2002-02.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-03.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-04.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-05.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-06.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-07.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-08.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-09.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-10.scala \
  /home/apm/projects/snytt/test/files/run/Course-2002-13.scala \
  /home/apm/projects/snytt/test/files/run/Meter.scala \
  /home/apm/projects/snytt/test/files/run/MeterCaseClass.scala \
  /home/apm/projects/snytt/test/files/run/MutableListTest.scala \
  /home/apm/projects/snytt/test/files/run/NestedClasses.scala \
  /home/apm/projects/snytt/test/files/run/OrderingTest.scala \
  /home/apm/projects/snytt/test/files/run/Predef.readLine.scala \
  [etc]
```

Incomplete tests (in the category running when interrupted) are
reported as pending:
```
ok   38 - pos/cls1.scala
Thread pool timeout elapsed before all tests were complete!
ok   39 - pos/cls.scala
!!   40 - pos/collectGenericCC.scala                [compilation failed]
!!   41 - pos/chang                                 [timed out]

ok   42 - pos/clsrefine.scala
[error] Failed: Total 41, Failed 2, Errors 0, Passed 39, Pending 1371
[error] Failed tests:
[error]     partest
[error] (test/it:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 14 s, completed Apr 12, 2017 10:37:58 AM

```
@@ -759,7 +761,7 @@ class SuiteRunner(
// |Java Classpath: ${sys.props("java.class.path")}
}

def onFinishTest(testFile: File, result: TestState): TestState = result
def onFinishTest(testFile: File, result: TestState): TestState = { unused(testFile) ; result }
Copy link
Member

Choose a reason for hiding this comment

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

This is also wrong, imho..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dwijnand do you prefer pre or post syntax? an annotation to ignore or a reporter that knows to ignore it? This is a middle solution.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer the pre-syntax. IMO the unused param checker shouldn't warn on non-effectively final methods.

(Sorry I'm a little salty atm as I really want to use "warn unused"/Xlint in sbt/sbt but I've been dealing with lots and lots of these..)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finding the sweet spot for usability is hard, so input is appreciated. Warning on params was always assumed to be dicey. It sounds like: warn on final, unless asking for non-strict. Then, let me disable it with an annotation if I want.

I proposed this solution here because there's no extra machinery.

Copy link
Member

Choose a reason for hiding this comment

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

Btw another false positive (ish) is enriching objects, e.g implicit def enrichFoo(f: Foo.type).

@SethTisue
Copy link
Member

@som-snytt feel free to resubmit in scala/scala after https://github.com/scala/scala/pull/6566/files lands

I'm sorry this was neglected :-/

in the new sbt-runner-only, in-sourced-partest world, I think we'll all be a lot more willing to review — and make — partest improvements.

@SethTisue SethTisue closed this May 3, 2018
@som-snytt
Copy link
Contributor Author

Somehow I didn't miss this feature. But all those beautiful whitespace improvements!

Also thanks @dwijnand @lrytz for feedback on unused usability. I may have forgotten to say that -Xlint enables the uncontroversial checks, -Ywarn-unused is hard core.

@SethTisue
Copy link
Member

-Ywarn-unused once told me I had a jar of capers in the fridge that were going to expire soon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants