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

simplify ScalaTest usage #597

Merged
merged 6 commits into from
Jun 24, 2021
Merged

Conversation

SethTisue
Copy link
Member

@SethTisue SethTisue commented Apr 15, 2021

ScalaTest was not fully published for RC1 (Scala.js artifacts were missing), so that's the reason to drop RC1. it's fine, we'd have dropped it soon anyway when adding RC3 dropped in #602

@SethTisue SethTisue mentioned this pull request Apr 15, 2021
6 tasks
@SethTisue SethTisue changed the title drop RC1 from crossbuild and simplify ScalaTest usage simplify ScalaTest usage (and drop RC1 from crossbuild) Apr 15, 2021
@SethTisue SethTisue force-pushed the eliminate-illtyped branch 2 times, most recently from 1f1a819 to 59db8aa Compare April 15, 2021 00:55
and drop RC1 from crossbuild, since ScalaTest wasn't
fully published

Co-authored by: Seth Tisue <[email protected]>
@SethTisue SethTisue force-pushed the eliminate-illtyped branch from 59db8aa to 998a662 Compare April 15, 2021 00:59
@SethTisue
Copy link
Member Author

the Scala 2 jobs are now green

but presumably there's no way to make this PR mergeable until there's an upstream fix (in the ScalaTest repo) for this, as seen in the Scala-3-only failure:

[error] -- Error: /home/travis/build/playframework/play-json/play-json/shared/src/test/scala/play/api/libs/json/JsonSharedSpec.scala:137:32 
276[error] 137 |      "js.toJsObject(1)".mustNot(typeCheck)
277[error]     |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
278[error]     |      The 'mustNot typeCheck' syntax only works with String literals.
279[error]     | This location contains code that was inlined from JsonSharedSpec.scala:137

over at #594, @griggt said he'd look into it

@griggt
Copy link
Contributor

griggt commented Apr 15, 2021

In short, the ScalaTest typeCheck matcher is currently broken in Scala 3.

This appears to be known to the maintainers, because the entire test suite for this feature has been excluded in the Dotty build.

The immediate issue causing the confusing only works with String literals error seen above is that one of the macros contains obsolete/unmaintained code matching on the wrong tree shape: it is expecting an Apply node when what we have is a Literal(StringConstant(_)).

That is an easy fix, and making that change would allow the tests here to pass. However, the remainder of the current ScalaTest implementation does not conform to the documented semantics for the typeCheck matcher, namely that mustNot(typeCheck) should enforce that the code is free of syntax errors but fails type checking. Instead it would behave identically to mustNot(compile), where either parser or typer errors result in the test succeeding. There are some additional issues (with multiline string literals and stripMargin, etc.) that I will omit here for brevity.

Incidentally, the Scala 3 implementation of illTyped here has the same issue. Both implementations use the scala.compiletime.testing.typeChecks API, which returns false on any parser or typer errors.

Some options for this PR

  1. Keep illTyped as-is (at least for now) but proceed with other changes
  2. Wait for an upstream fix in ScalaTest
  3. Use mustNot(compile) instead of mustNot(typeCheck)

Regardless of the decision taken here, I plan to work on a PR for ScalaTest to fix mustNot(typeCheck) in Scala 3.

@griggt
Copy link
Contributor

griggt commented Apr 21, 2021

Upstream PR: scalatest/scalatest#2008

@SethTisue SethTisue changed the title simplify ScalaTest usage (and drop RC1 from crossbuild) simplify ScalaTest usage Apr 29, 2021
@SethTisue
Copy link
Member Author

current status: that PR is now merged, but there is no 3.2.9 yet; perhaps they're waiting for the next Scala 3 release (3.0.0-RC4 or 3.0.0 final)

@SethTisue SethTisue marked this pull request as ready for review June 23, 2021 23:51
@SethTisue SethTisue self-assigned this Jun 23, 2021
@SethTisue SethTisue merged commit 0bdf535 into playframework:main Jun 24, 2021
@SethTisue SethTisue deleted the eliminate-illtyped branch June 24, 2021 06:06
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