Skip to content

Commit 2554d9e

Browse files
committed
Use normal tests instead of sbt scripted tests
1 parent fd6d092 commit 2554d9e

File tree

13 files changed

+28
-148
lines changed

13 files changed

+28
-148
lines changed

.github/workflows/ci.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ jobs:
2727
uses: actions/setup-python@v2
2828
with:
2929
python-version: ${{ matrix.python }}
30-
- name: Integration tests against latest ScalaPy stable
31-
run: scripts/integration_test.sh python3 0.5.2
30+
- name: Test
31+
run: sbtn +test
3232
shell: bash
33-
- name: Test virtualenv
34-
run: scripts/virtualenv_test.sh 0.5.2
3533
publish:
3634
runs-on: ubuntu-20.04
3735
needs: [test]

build.sbt

+10-36
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,22 @@ lazy val scala212 = "2.12.15"
2020
lazy val scala213 = "2.13.6"
2121
lazy val scala3 = "3.0.2"
2222

23-
lazy val scalapyVersion = getProp("plugin.scalapy.version").getOrElse("0.5.2")
24-
2523
ThisBuild / scalaVersion := scala213
26-
2724
ThisBuild / scalafixDependencies += organizeImports
2825

29-
def getProp(p: String) = Option(sys.props(p)).map(_.trim).filter(_.nonEmpty)
30-
31-
def getProps(prop: String*) =
32-
prop
33-
.map(p => p -> getProp(p))
34-
.collect { case (k, Some(v)) => s"""-D$k=$v""" }
35-
36-
lazy val publishSettings = Seq(
37-
sonatypeCredentialHost := "s01.oss.sonatype.org",
38-
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
39-
)
40-
41-
lazy val noPublishSettings = Seq(
42-
publishArtifact := false,
43-
packagedArtifacts := Map.empty,
44-
publish := {},
45-
publishLocal := {}
46-
)
47-
4826
lazy val root = project
4927
.in(file("."))
5028
.settings(
5129
name := "Python Native Libs",
5230
crossScalaVersions := Seq(scala212, scala213, scala3),
53-
libraryDependencies += scalaCollectionCompat,
31+
libraryDependencies ++= Seq(
32+
scalaCollectionCompat,
33+
scalapy % Test,
34+
scalaTest % Test
35+
),
36+
Test / fork := true
37+
)
38+
.settings(
5439
semanticdbEnabled := true,
5540
semanticdbVersion := scalafixSemanticdb.revision,
5641
scalacOptions += {
@@ -61,21 +46,10 @@ lazy val root = project
6146
}
6247
}
6348
)
64-
.settings(publishSettings)
65-
66-
lazy val tests = project
67-
.in(file("tests"))
68-
.enablePlugins(ScriptedPlugin)
6949
.settings(
70-
scalaVersion := scala212,
71-
scriptedLaunchOpts ++= {
72-
Seq(s"-Dplugin.scalapy.version=$scalapyVersion") ++
73-
getProps("plugin.python.executable", "plugin.virtualenv") ++
74-
Seq("-Xmx1024M", "-Dplugin.version=" + (root / version).value)
75-
},
76-
scriptedBufferLog := false
50+
sonatypeCredentialHost := "s01.oss.sonatype.org",
51+
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
7752
)
78-
.settings(noPublishSettings)
7953

8054
lazy val docs = project
8155
.in(file("python-docs"))

project/Dependencies.scala

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ import sbt._
33
object Dependencies {
44
lazy val scalaCollectionCompat =
55
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0"
6+
lazy val scalapy = "me.shadaj" %% "scalapy-core" % "0.5.2"
7+
lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.11"
68
lazy val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.6.0"
79
}

scripts/integration_test.sh

-4
This file was deleted.

scripts/virtualenv_test.sh

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ai.kien.python
2+
3+
import me.shadaj.scalapy.py
4+
import me.shadaj.scalapy.py.{PyQuote, SeqConverters}
5+
import org.scalatest.funsuite.AnyFunSuite
6+
7+
class PythonTest extends AnyFunSuite {
8+
Python().scalapyProperties.get.foreach { case (k, v) => System.setProperty(k, v) }
9+
10+
test("ScalaPy runs successfully") {
11+
py.Dynamic.global.list(Seq(1, 2, 3).toPythonCopy)
12+
py"'Hello from ScalaPy!'"
13+
}
14+
}

tests/src/sbt-test/integration/scalapy/build.sbt

-46
This file was deleted.

tests/src/sbt-test/integration/scalapy/jvm/src/main/scala/project/Module.scala

-12
This file was deleted.

tests/src/sbt-test/integration/scalapy/project/.gitignore

-1
This file was deleted.

tests/src/sbt-test/integration/scalapy/project/build.properties

-1
This file was deleted.

tests/src/sbt-test/integration/scalapy/project/plugins.sbt

-11
This file was deleted.

tests/src/sbt-test/integration/scalapy/shared/src/main/scala/project/Main.scala

-11
This file was deleted.

tests/src/sbt-test/integration/scalapy/test

-3
This file was deleted.

0 commit comments

Comments
 (0)