Skip to content

Commit 952d3b0

Browse files
committed
Use tools project for tests
1 parent 4d27770 commit 952d3b0

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ inThisBuild(
1818

1919
val tests = project
2020
.in(file("tests"))
21+
.dependsOn(tools)
2122
.aggregate(samples)
2223
.settings(
2324
fork in Test := true,

tests/src/test/scala/org/scalanative/bindgen/BindgenSpec.scala

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package org.scalanative.bindgen
22

3-
import java.io.{File, PrintWriter}
3+
import java.io.{File}
44
import org.scalatest.FunSpec
55
import scala.io.Source
6-
import scala.sys.process._
76

87
class BindgenSpec extends FunSpec {
98
describe("Bindgen") {
@@ -19,24 +18,15 @@ class BindgenSpec extends FunSpec {
1918
}
2019

2120
def bindgen(inputFile: File, name: String, outputFile: File): Unit = {
22-
val cmd = Seq(
23-
bindgenPath,
24-
inputFile.getAbsolutePath,
25-
"--name",
26-
name,
27-
"--link",
28-
"bindgentests",
29-
"--package",
30-
"org.scalanative.bindgen.samples",
31-
"--exclude-prefix=__",
32-
"--"
33-
)
34-
val output = Process(cmd).lineStream.mkString("\n")
35-
36-
new PrintWriter(outputFile) {
37-
write(output)
38-
close()
39-
}
21+
Bindgen()
22+
.bindgenExecutable(new File(bindgenPath))
23+
.header(inputFile)
24+
.scalaObjectName(name)
25+
.link("bindgentests")
26+
.packageName("org.scalanative.bindgen.samples")
27+
.excludePrefix("__")
28+
.generate()
29+
.writeToFile(outputFile)
4030
}
4131

4232
def contentOf(file: File) =

tools/src/main/scala/org/scalanative/bindgen/Bindgen.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ object Bindgen {
148148
}
149149

150150
if (excludePrefix != null) {
151-
cmd :+= excludePrefix
151+
cmd ++= Seq("--exclude-prefix", excludePrefix)
152152
}
153153

154-
cmd :+= "--"
154+
for (arg <- extraArg) cmd ++= Seq("--extra-arg", arg)
155+
for (arg <- extraArgBefore) cmd ++= Seq("--extra-arg-before", arg)
155156

156-
// TODO: extra args
157+
cmd :+= "--"
157158

158159
val output = Process(cmd).lineStream.mkString("\n")
159160

0 commit comments

Comments
 (0)