Skip to content

Commit 84b1972

Browse files
authored
Merge pull request #305 from Philippus/undelete-scripted-tests
Undelete scripted tests
2 parents c32ac73 + 140ceeb commit 84b1972

29 files changed

Lines changed: 224 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
java-version: 17
1616
- uses: sbt/setup-sbt@v1
1717
- name: Run tests
18-
run: sbt clean +test +scripted
18+
run: sbt clean +test 'scripted sbt1only/*' '+scripted sbt-dotenv/*'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version := "0.1"
2+
3+
ThisBuild / envFileName := "dotenv"
4+
5+
TaskKey[Unit]("check") := {
6+
val lastLog: File = BuiltinCommands.lastLogFile(state.value).get
7+
val last: String = IO.read(lastLog)
8+
val contains = last.contains("Configured .env environment")
9+
if (!contains)
10+
sys.error("expected log message")
11+
if (sys.env.get("LINE_ONE").isEmpty || sys.env.get("LINE_TWO").isEmpty)
12+
sys.error("environment variables not set")
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LINE_ONE=abc
2+
LINE_TWO=xyz
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sys.props.get("plugin.version") match {
2+
case Some(x) => addSbtPlugin("nl.gn0s1s" %% "sbt-dotenv" % x)
3+
case _ =>
4+
sys.error(
5+
"""|The system property 'plugin.version' is not defined.
6+
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
7+
)
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> check
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LINE_ONE=abc
2+
LINE_TWO=xyz
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version := "0.1"
2+
3+
TaskKey[Unit]("check") := {
4+
val lastLog: File = BuiltinCommands.lastLogFile(state.value).get
5+
val last: String = IO.read(lastLog)
6+
val contains = last.contains("Configured .env environment")
7+
if (!contains)
8+
sys.error("expected log message")
9+
if (sys.env.get("LINE_ONE").isEmpty || sys.env.get("LINE_TWO").isEmpty)
10+
sys.error("environment variables not set")
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sys.props.get("plugin.version") match {
2+
case Some(x) => addSbtPlugin("nl.gn0s1s" %% "sbt-dotenv" % x)
3+
case _ =>
4+
sys.error(
5+
"""|The system property 'plugin.version' is not defined.
6+
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
7+
)
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> check
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
lazy val root = (project in file("."))
2+
.settings(
3+
version := "0.1",
4+
ThisBuild / envFileName := "build.env",
5+
Test / envFileName := "test.env",
6+
test / fork := true
7+
)
8+
9+
TaskKey[Unit]("checkGlobal") := {
10+
val lastLog: File = BuiltinCommands.lastLogFile(state.value).get
11+
val last: String = IO.read(lastLog)
12+
val contains = last.contains(
13+
".env file not found (fileName=build.env), no .env environment configured."
14+
)
15+
if (!contains)
16+
sys.error("expected log message")
17+
}
18+
19+
TaskKey[Unit]("checkTest") := {
20+
val lastLog: File = BuiltinCommands.lastLogFile(state.value).get
21+
val last: String = IO.read(lastLog)
22+
val contains = last.contains(".env detected (fileName=test.env)")
23+
if (!contains)
24+
sys.error("expected log message")
25+
}

0 commit comments

Comments
 (0)