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

Bump sbt-doctest to 0.6.0 #306

Closed
wants to merge 2 commits into from
Closed

Bump sbt-doctest to 0.6.0 #306

wants to merge 2 commits into from

Conversation

frgomes
Copy link
Contributor

@frgomes frgomes commented Jul 10, 2017

Please advise if tkawachi/sbt-doctest#52 can be closed.
/cc @tkawachi

@codecov-io
Copy link

codecov-io commented Jul 10, 2017

Codecov Report

Merging #306 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #306   +/-   ##
=======================================
  Coverage   99.26%   99.26%           
=======================================
  Files          37       37           
  Lines         407      407           
  Branches        4        3    -1     
=======================================
  Hits          404      404           
  Misses          3        3

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b659a1...219e178. Read the comment docs.

@fthomas
Copy link
Owner

fthomas commented Jul 10, 2017

Thanks! If this is supposed to run the doctests in JS, then this line needs to be removed too:

doctestGenTests := Seq.empty
:-)

@frgomes
Copy link
Contributor Author

frgomes commented Jul 10, 2017

@fthomas I've removed the configuration you pointed out and it gives me:

[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/api/RefTypeDoctest.scala:15: You may not export a local class
[error]   include(new org.scalacheck.Properties("refine") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/api/RefTypeDoctest.scala:27: You may not export a local class
[error]   include(new org.scalacheck.Properties("refineM") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/api/RefTypeDoctest.scala:39: You may not export a local class
[error]   include(new org.scalacheck.Properties("refineMF") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/api/RefTypeDoctest.scala:51: You may not export a local class
[error]   include(new org.scalacheck.Properties("applyRef") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/api/RefTypeDoctest.scala:65: You may not export a local class
[error]   include(new org.scalacheck.Properties("applyRefM") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/autoDoctest.scala:15: You may not export a local class
[error]   include(new org.scalacheck.Properties("autoInfer") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/autoDoctest.scala:30: You may not export a local class
[error]   include(new org.scalacheck.Properties("autoUnwrap") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/numericDoctest.scala:15: You may not export a local class
[error]   include(new org.scalacheck.Properties("numeric") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/packageDoctest.scala:15: You may not export a local class
[error]   include(new org.scalacheck.Properties("W") {
[error]               ^
[error] /home/rgomes/workspace/refined/modules/core/js/target/scala-2.12/src_managed/test/eu/timepit/refined/util/stringDoctest.scala:15: You may not export a local class
[error]   include(new org.scalacheck.Properties("regex") {
[error]               ^
[error] 10 errors found

I'm not the best person to tell what would be the root cause of these errors.

  1. I don't use ScalaJS on a regular basis;
  2. I only use uTest, without any other test framework.
  3. In regards to sbt-doctest, I don't use property checks since they are dependent on ScalaCheck and... as I said, I avoid anything that could imply pulling any other dependencies.

@fthomas
Copy link
Owner

fthomas commented Jul 10, 2017

The errors indicate that sbt-doctest's ScalaCheckGen produces code that is not compatible with Scala.js. I would say this is what tkawachi/sbt-doctest#52 is about.

refined doesn't use property tests in doctests, so it could be possible to run them on JS with a different test framework. Probably by setting doctestTestFramework := DoctestTestFramework.MicroTest in moduleJsSettings.
But I'm not sure if running the doctests on JS is worth a new test dependency. In refined's case the doctests do not test code that is not already covered by the ordinary ScalaCheck tests. So I'm okay with merging this with your last commit reverted.

@frgomes
Copy link
Contributor Author

frgomes commented Jul 11, 2017

I've employed uTest in this tentative.
I had to disable fatal warnings in order to make the compilation pass.

/cc @tkawachi

I've raised tkawachi/sbt-doctest#95

Below we can see a snippet of one of the offending files generated by sbt-doctest.
The root cause of compilation warnings is that a import a.b.c is being generated when we are already in the context of package a.b.c.

package eu.timepit.refined.api

import utest._

object RefTypeDoctest extends TestSuite {

    val tests = this {

  def sbtDoctestTypeEquals[A](a1: => A)(a2: => A): Unit = ()
  def sbtDoctestReplString(any: Any): String = {
    val s = scala.runtime.ScalaRunTime.replStringOf(any, 1000).init
    if (s.headOption == Some('\n')) s.tail else s
  }

  "RefType.scala:34: refine"-{
    import eu.timepit.refined.api.{ Refined, RefType }
    import eu.timepit.refined.numeric.Positive

    "example at line 43: RefType[Refined].refine[Positive](10)"-{
                  val _actual_   = sbtDoctestReplString(RefType[Refined].refine[Positive](10))
                  val _expected_ = "Right(10)"
      assert( _expected_ == _actual_ ) // 
      sbtDoctestTypeEquals(RefType[Refined].refine[Positive](10))((RefType[Refined].refine[Positive](10)): Either[String, Refined[Int, Positive]])
    }
  }
...
}

@frgomes
Copy link
Contributor Author

frgomes commented Jul 11, 2017

BEWARE: The build pass, but I had to disable fatal warnings, which is not what we want.
I've raised tkawachi/sbt-doctest#95

@fthomas
Copy link
Owner

fthomas commented Jul 12, 2017

I've been looking for the string example at line 43 in the Travis build log but could only find it in the JVM tests. Are they µTests really executed? I'm also sceptical about the usage of scala.runtime.ScalaRunTime.replStringOf in the above RefTypeDoctest. In tkawachi/sbt-doctest#52 (comment) @tkawachi notes that this is not available on the JS side.

@fthomas
Copy link
Owner

fthomas commented Aug 14, 2017

I added the first commit of this PR to #315 so that we can have a sbt-doctest that is also available for sbt 1.0.0.

@fthomas
Copy link
Owner

fthomas commented Dec 14, 2017

Closing since refined is already updated to sbt-doctest 0.7.1 and I'm okay with not running doctest in the JS build.

@fthomas fthomas closed this Dec 14, 2017
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.

3 participants