Skip to content

Commit

Permalink
Tests for asset include / exclude filters
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Sep 2, 2023
1 parent 2ada751 commit 2bd186c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ object IndigoBuild {
def copyOne(p: Path): java.nio.file.Path = {
val target = to / p.relativeTo(from)

os.makeDir.all(target)

java.nio.file.Files.copy(
p.wrapped,
target.wrapped,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AcceptanceTests extends munit.FunSuite {

override def beforeAll(): Unit = {
if (os.exists(targetDir)) {
os.remove(target = targetDir, checkExists = true)
os.remove.all(target = targetDir)
}

os.makeDir.all(targetDir)
Expand All @@ -19,16 +19,37 @@ class AcceptanceTests extends munit.FunSuite {
val indigoAssets =
IndigoAssets(
gameAssetsDirectory = sourceDir,
include = { case _ => false },
exclude = { case _ => false }
include = {
case p if p.endsWith(os.RelPath("taken.txt")) => true
case p if p.toString.matches("(.*)also-taken.txt") => true
case _ => false
},
exclude = {
case p if p.startsWith(os.RelPath("ignored-folder")) => true
case p if p.startsWith(os.RelPath("mixed")) => true
case _ => false
}
)

test("Copy assets and assert expected output files") {

IndigoBuild.copyAssets(indigoAssets, targetDir)

// Basics
assert(os.exists(targetDir))
assert(os.exists(targetDir / "foo.txt"))
assert(os.exists(targetDir / "data" / "stats.csv"))

// Ignored folder
assert(!os.exists(targetDir / "ignored-folder"))
assert(!os.exists(targetDir / "ignored-folder" / "ignored-file.txt"))

// Generally excluded, but some taken.
assert(os.exists(targetDir / "mixed"))
assert(!os.exists(targetDir / "mixed" / "ignored-file.txt"))
assert(os.exists(targetDir / "mixed" / "taken.txt"))
assert(os.exists(targetDir / "mixed" / "also-taken.txt"))

}

}
5 changes: 5 additions & 0 deletions indigo-plugin/test-assets/data/stats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name,level,bonus
intelligence,2,4
strength,10,0
fortitude,4,1

1 change: 1 addition & 0 deletions indigo-plugin/test-assets/ignored-folder/ignored-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file should not be copied over.
1 change: 1 addition & 0 deletions indigo-plugin/test-assets/mixed/also-taken.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file should be copied over.
1 change: 1 addition & 0 deletions indigo-plugin/test-assets/mixed/ignored-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file should not be copied over.
1 change: 1 addition & 0 deletions indigo-plugin/test-assets/mixed/taken.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file should be copied over.

0 comments on commit 2bd186c

Please sign in to comment.