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

Improve test BSP service #1769

Merged
merged 7 commits into from
Sep 29, 2022
Merged

Conversation

oyvindberg
Copy link
Contributor

  • add TestRun and TestRuns structures to aggregate all produced TestSuiteEvent.Results.
  • propagate all test results back up to service
  • use test results to return bsp.StatusCode.Error on failed tests (Fixing Respond with adequate test reports to BSP test #960)
  • ensure that the compilation before test finished with StatusCode.Ok

Copy link
Collaborator

@kpodsiad kpodsiad left a comment

Choose a reason for hiding this comment

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

Solid job @oyvindberg. I think we should add a testcase for fixed scenario (something near e.g. BspMetalsClientSpec?)

frontend/src/main/scala/bloop/bsp/BloopBspServices.scala Outdated Show resolved Hide resolved
Comment on lines +164 to +169
runAll(testTasks).map { testRuns =>
// When the test execution is over report no matter what the result is
testEventHandler.report()
logger.debug(s"Test suites failed: $failure")
val isOk = !failure && exitCodes.forall(_ == 0)
if (isOk) state.mergeStatus(ExitStatus.Ok)
else state.copy(status = ExitStatus.TestExecutionError)
TestRuns(testRuns)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if testEventHandler is suitable for handling parallel execution of task, I see mutable collections there and plain Ints :/ but ofc this isn't concern of this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the test code seems a bit half baked, so I wouldn't be surprised if some fixes are necessary. A related issue I came across is that clients are not (AFAIU) able to request parallel execution at all for now. Perhaps that could be a bloop specific field inside the request data strucure again.

frontend/src/main/scala/bloop/bsp/BloopBspServices.scala Outdated Show resolved Hide resolved
@oyvindberg
Copy link
Contributor Author

I agree there should be tests. I'm thinking to duplicate the structure for the compile tests and adapt the structure for test end point. or something like that. It'll be a day or two before I get to it

@oyvindberg
Copy link
Contributor Author

added a test now

@oyvindberg
Copy link
Contributor Author

Just an update.

I've had an hour here and there over the last week, and numerous times I've jumped in to fix this test. I'll probably get there, but it's incredibly slow and difficult work.

@tgodzik
Copy link
Contributor

tgodzik commented Aug 16, 2022

Just an update.

I've had an hour here and there over the last week, and numerous times I've jumped in to fix this test. I'll probably get there, but it's incredibly slow and difficult work.

Do you need help with that? What is slowing you down most?

@oyvindberg
Copy link
Contributor Author

oyvindberg commented Aug 16, 2022

It would help a lot. I'm working towards an MVP of bleep and really need this feature, but I have much less time than I would have wanted.

It's a deep call stack, and some state handling I haven't had time to understand.

  • I'm currently stuck debugging why my tests within the test harness are not run because compileAnalysis is empty (see TestTask.scala:83)
  • I commented out that check, and then it's very puzzling that I don't see all the test events this PR needs when running the tests. I hope that is not an junit vs scalatest issue. if it is, the main code in this PR needs to adapt to whatever cues sbt uses to determine failed tests

@oyvindberg
Copy link
Contributor Author

Re slow, it's a combination of many things. I'm unable to run sbt in arm64 mode (is there even an issue for that?), so everything with the build is just incredibly slow. roundtrip for compiling frontend plus tests and then testOnly the test I want to run is like half a minute. I needed to change the default timeout value for the tests from 5 to 10 seconds for things to work at all. I know much of this responsibility lies outside of bloop, and I know the build itself is beeing looked at, just wanted to air some frustration :)

@tgodzik
Copy link
Contributor

tgodzik commented Aug 16, 2022

I will try and take a look, but that might be next week unfortunately.

@oyvindberg
Copy link
Contributor Author

That would be perfect. Gives me some time to try to figure it out myself first :)

Copy link
Collaborator

@dos65 dos65 left a comment

Choose a reason for hiding this comment

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

@oyvindberg Thanks for contribution!
Overall looks good. The only issue is that BspTestSpec.bsp test fails`` test case doesn't pass. No idea why. Could you look at it?

@@ -1094,7 +1102,7 @@ final class BloopBspServices(
def matchesGlobs(document: Path, project: Project): Boolean =
project.sourcesGlobs.exists(glob => glob.matches(document))
val document = AbsolutePath(request.textDocument.uri.toPath).underlying
ifInitialized(None) { (state: State, _: BspServerLogger) =>
ifInitialized(None) { (state: State, _: BspServerLogger) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be reverted

oyvindberg and others added 7 commits September 29, 2022 18:01
- add `TestRun` and `TestRuns` structures to aggregate all produced `TestSuiteEvent.Results`.
- propagate all test results back up to service
- use test results to return `bsp.StatusCode.Error` on failed tests (Fixing scalacenter#960)
- ensure that the compilation before test finished with `StatusCode.Ok`
- not much for now, assert that we get correct exit codes
@tgodzik tgodzik merged commit 378b48a into scalacenter:main Sep 29, 2022
@oyvindberg
Copy link
Contributor Author

thanks @tgodzik !

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.

4 participants