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

Cross compile to Scala Native #337

Closed
wants to merge 6 commits into from
Closed

Conversation

Duhemm
Copy link
Contributor

@Duhemm Duhemm commented Jun 14, 2017

The next release of Scala Native is coming soon, and it will add support for test frameworks using sbt's test interface (scala-native/scala-native#755). While implementing the test interface, I cross compiled scalacheck to Scala Native.

Here are the changes that I did to get it to cross compile and work with Scala Native. Obviously, Scala Native 0.3.0 is not released yet, and you'll need to build Scala Native locally to test it. Here's what it looks like: https://travis-ci.org/Duhemm/scala-native/jobs/242582498#L2665-L2697

How to try it

After your system is set up, you can build Scala Native locally:

$ git clone https://github.com/scala-native/scala-native.git
$ cd scala-native
$ sbt rebuild

Then, build and publishLocally this PR. You can use the published artifact in a Scala Native project as shown here. Write your tests as usual and run them using test in sbt.

It would be great if we could get this PR in soon after Scala Native is released (I'll update it with the correct version numbers). Do you see things that need to be addressed in this PR while we wait for the next release of Scala Native?

@xuwei-k
Copy link
Contributor

xuwei-k commented Jun 16, 2017

rickynils/scalacheck/native/target/scala-2.11/src_managed/nativetest/FrameworksMap.scala:4: identifier expected but 'new' found.
[error]   override val tests = Map("org.scalacheck.PropSpecification" -> _root_.org.scalacheck.PropSpecification, "org.scalacheck.util.PrettySpecification" -> _root_.org.scalacheck.util.PrettySpecification, "org.scalacheck.examples.Examples" -> _root_.org.scalacheck.examples.Examples, "org.scalacheck.ShrinkSpecification" -> _root_.org.scalacheck.ShrinkSpecification, "org.scalacheck.PropsClass" -> _root_.new org.scalacheck.PropsClass, "org.scalacheck.PropsObject" -> _root_.org.scalacheck.PropsObject, "org.scalacheck.examples.MathSpec" -> _root_.org.scalacheck.examples.MathSpec)
[error]                                                                                                                                                                                                                                                                                                                                                                                                                ^

@densh
Copy link
Contributor

densh commented Jun 29, 2017

@Duhemm 0.3.1 with a fix for the issue discovered by @xuwei-k has just been released.

@xuwei-k
Copy link
Contributor

xuwei-k commented Jun 30, 2017

https://github.com/rickynils/scalacheck/blob/b00d40ec6db552545f7687d83e518d90e63424cc/src/test/scala/org/scalacheck/PropSpecification.scala#L146-L149

Segmentation fault in this test

property("throws") = throws(classOf[java.lang.Exception]) {
  val s: String = null
  s.length
}

@densh
Copy link
Contributor

densh commented Jul 3, 2017

@xuwei-k This is expected, dereferencing null is undefined behavior in Scala Native.

A test was deliberately provoking a NullPointerException to make sure
that exceptions are correctly caught. However, in Scala Native, null
dereferencing is undefined behavior, and such an exception cannot be
caught at the moment. The test is changed to call next on an empty
Iterator, as these exceptions can be caught with Scala Native.
@Duhemm Duhemm changed the title [Do not merge yet] Cross compile to Scala Native Cross compile to Scala Native Jul 3, 2017
@Duhemm
Copy link
Contributor Author

Duhemm commented Jul 3, 2017

I was sure I had updated this PR after the release of Scala Native 0.3.1, but I obviously didn't. Sorry about that.

The PR is up to date and the tests have been fixed. I just need to figure out .travis.yml.

Copy link
Contributor

@xuwei-k xuwei-k left a comment

Choose a reason for hiding this comment

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

👍

@Duhemm
Copy link
Contributor Author

Duhemm commented Jul 4, 2017

I added the Travis CI configuration. I think that the failure is unrelated to my changes (it failed on the JVM). Could someone please restart the job?

@ahjohannessen
Copy link

Cool :)

@shadaj
Copy link

shadaj commented Jul 25, 2017

@Duhemm Looks like the issue occurs after Travis merges the PR with master, where JSExportDescendentClasses and JSExportDescendentClasses have been replaced with the single annotation EnableReflectiveInstantiation in #341. So replacing the two types in Platform.scala with type EnableReflectiveInstantiation = String should make the Travis build pass.

@rickynils
Copy link
Contributor

@shadaj @Duhemm This has been superseded by #368, right? Closing this PR in favor of #368 .

@rickynils rickynils closed this Dec 4, 2017
rickynils added a commit that referenced this pull request Dec 20, 2017
Updated version of #337: Cross compile to Scala Native
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.

6 participants