Skip to content

Commit 44ae487

Browse files
committed
Move tests into a separate project
for more comprehensive testing later
1 parent 9260957 commit 44ae487

File tree

14 files changed

+43
-33
lines changed

14 files changed

+43
-33
lines changed

build.sbt

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,67 @@ lazy val scalapyVersion = getProp("plugin.scalapy.version").getOrElse("0.5.2")
2424

2525
lazy val enableScripted = getProp("plugin.ci").isDefined
2626

27-
ThisBuild / scalaVersion := (if (enableScripted) scala212 else scala213)
27+
ThisBuild / scalaVersion := scala213
2828

2929
ThisBuild / scalafixDependencies += organizeImports
3030

31-
def warnUnusedImports(scalaVersion: String) =
32-
CrossVersion.partialVersion(scalaVersion) match {
33-
case Some((2, _)) => Seq("-Xlint:unused")
34-
case _ => Nil
35-
}
36-
3731
def getProp(p: String) = Option(sys.props(p)).map(_.trim).filter(_.nonEmpty)
3832

3933
def getProps(prop: String*) =
4034
prop
4135
.map(p => p -> getProp(p))
4236
.collect { case (k, Some(v)) => s"""-D$k=$v""" }
4337

44-
def scriptedPlugin = if (enableScripted) Seq(ScriptedPlugin) else Nil
38+
lazy val publishSettings = Seq(
39+
sonatypeCredentialHost := "s01.oss.sonatype.org",
40+
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
41+
)
4542

46-
def scriptedSettings = if (enableScripted) {
47-
Seq(
48-
scriptedLaunchOpts := {
49-
scriptedLaunchOpts.value ++ {
50-
Seq(s"-Dplugin.scalapy.version=$scalapyVersion") ++
51-
getProps("plugin.python.executable", "plugin.virtualenv") ++
52-
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
53-
}
54-
},
55-
scriptedBufferLog := false
56-
)
57-
} else Nil
43+
lazy val noPublishSettings = Seq(
44+
publishArtifact := false,
45+
packagedArtifacts := Map.empty,
46+
publish := {},
47+
publishLocal := {}
48+
)
5849

59-
lazy val root = (project in file("."))
60-
.enablePlugins(scriptedPlugin: _*)
50+
lazy val `python-native-libs` = project
51+
.in(file("python-native-libs"))
6152
.settings(
6253
name := "Python Native Libs",
6354
crossScalaVersions := Seq(scala212, scala213, scala3),
6455
libraryDependencies += scalaCollectionCompat,
65-
sonatypeCredentialHost := "s01.oss.sonatype.org",
66-
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
67-
semanticdbEnabled := true,
68-
semanticdbVersion := scalafixSemanticdb.revision,
69-
scalacOptions ++= warnUnusedImports(scalaVersion.value)
56+
semanticdbEnabled := true,
57+
semanticdbVersion := scalafixSemanticdb.revision,
58+
scalacOptions += {
59+
CrossVersion.partialVersion(scalaVersion.value) match {
60+
case Some((2, 13)) => "-Wunused:imports"
61+
case Some((2, 12)) => "-Ywarn-unused-import"
62+
case _ => ""
63+
}
64+
}
7065
)
71-
.settings(scriptedSettings)
66+
.settings(publishSettings)
67+
68+
lazy val tests = project
69+
.in(file("tests"))
70+
.enablePlugins(ScriptedPlugin)
71+
.settings(
72+
scalaVersion := scala212,
73+
scriptedLaunchOpts ++= {
74+
Seq(s"-Dplugin.scalapy.version=$scalapyVersion") ++
75+
getProps("plugin.python.executable", "plugin.virtualenv") ++
76+
Seq("-Xmx1024M", "-Dplugin.version=" + (`python-native-libs` / version).value)
77+
},
78+
scriptedBufferLog := false
79+
)
80+
.settings(noPublishSettings)
7281

7382
lazy val docs = project
7483
.in(file("python-docs"))
84+
.enablePlugins(MdocPlugin)
7585
.settings(
7686
mdocVariables := Map(
7787
"PYTHON" -> "/usr/bin/python3"
7888
)
7989
)
80-
.dependsOn(root)
81-
.enablePlugins(MdocPlugin)
90+
.dependsOn(`python-native-libs`)

project/Dependencies.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ import sbt._
33
object Dependencies {
44
lazy val scalaCollectionCompat =
55
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0"
6-
lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.11"
7-
lazy val jimfs = "com.google.jimfs" % "jimfs" % "1.2"
8-
lazy val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.5.0"
6+
lazy val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.6.0"
97
}

src/main/scala/ai/kien/python/Defaults.scala renamed to python-native-libs/src/main/scala/ai/kien/python/Defaults.scala

File renamed without changes.
File renamed without changes.

src/main/scala/ai/kien/python/PythonConfig.scala renamed to python-native-libs/src/main/scala/ai/kien/python/PythonConfig.scala

File renamed without changes.

scripts/integration_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22

3+
sbt +publishLocal
34
sbt -Dplugin.ci=true -Dplugin.python.executable="$1" -Dplugin.scalapy.version="$2" scripted

scripts/virtualenv_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ echo "Virtualenv created at ${VENV_DIR}"
77
python3 -m venv "${VENV_DIR}"
88
"${VENV_DIR}"/bin/python -m pip install examples/python-package
99

10+
sbt +publishLocal
11+
1012
sbt \
1113
-Dplugin.ci=true \
1214
-Dplugin.virtualenv=true \
File renamed without changes.

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

File renamed without changes.

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

File renamed without changes.

0 commit comments

Comments
 (0)