Skip to content

Commit 489e3d6

Browse files
committed
Tests: Properly handle temp directories
This required a fix for `__mkdir` in NetLogo, as well as properly cleaning up the `tmp/` directory used by the language tests.
1 parent 9fee42d commit 489e3d6

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ version := "1.1.1"
1010
isSnapshot := true
1111

1212
netLogoClassManager := "org.nlogo.extensions.array.ArrayExtension"
13-
netLogoVersion := "6.2.2"
13+
netLogoVersion := "6.2.2-2f9fab6"
1414

1515
javaSource in Compile := baseDirectory.value / "src" / "main"
1616
scalaSource in Test := baseDirectory.value / "src" / "test"

src/test/Tests.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// (C) Uri Wilensky. https://github.com/NetLogo/Python-Extension
22

3-
package org.nlogo.extensions.py
3+
package org.nlogo.extensions.array
4+
5+
import org.scalatest.BeforeAndAfterAll
46

57
import java.io.File
68
import org.nlogo.headless.TestLanguage
@@ -10,6 +12,17 @@ object Tests {
1012
val testFiles = testFileNames.map( (f) => (new File(f)).getCanonicalFile )
1113
}
1214

13-
class Tests extends TestLanguage(Tests.testFiles) {
15+
class Tests extends TestLanguage(Tests.testFiles) with BeforeAndAfterAll {
1416
System.setProperty("org.nlogo.preferHeadless", "true")
17+
18+
override def afterAll() {
19+
val file = new File("tmp/array")
20+
def deleteRec(f: File) {
21+
if (f.isDirectory) {
22+
f.listFiles().foreach(deleteRec)
23+
}
24+
f.delete()
25+
}
26+
deleteRec(file)
27+
}
1528
}

tests.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ArraysBug716a
22
extensions [array]
33
globals [glob1 glob2]
4-
O> __mkdir "tmp/ImportWorld"
4+
O> __mkdir "tmp/array"
55
O> set glob1 array:from-list [1 2]
6-
O> set glob2 (word "tmp/ImportWorld/test-file-" __nano-time ".csv")
6+
O> set glob2 (word "tmp/array/test-file-" __nano-time ".csv")
77
O> export-world glob2
88
O> set glob1 0
99
O> import-world glob2
@@ -13,9 +13,9 @@ ArraysBug716a
1313
ArraysBug716b
1414
extensions [array]
1515
globals [glob1 glob2]
16-
O> __mkdir "tmp/ImportWorld"
16+
O> __mkdir "tmp/array"
1717
O> set glob1 (list array:from-list [1 2] array:from-list [3 4])
18-
O> set glob2 (word "tmp/ImportWorld/test-file-" __nano-time ".csv")
18+
O> set glob2 (word "tmp/array/test-file-" __nano-time ".csv")
1919
O> export-world glob2
2020
O> set glob1 0
2121
O> import-world glob2

0 commit comments

Comments
 (0)