Add test for evaluating all event scripts
This commit is contained in:
@@ -21,22 +21,34 @@ public class ScriptEvaluationTest {
|
|||||||
System.setProperty("polyglot.engine.WarnInterpreterOnly", "false");
|
System.setProperty("polyglot.engine.WarnInterpreterOnly", "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> npcScriptFiles() throws IOException {
|
private static List<String> npcScriptFilePaths() throws IOException {
|
||||||
Path npcScriptDirectory = Path.of("scripts", "npc");
|
return getScriptFilePaths("npc");
|
||||||
try (Stream<Path> pathStream = Files.walk(npcScriptDirectory)) {
|
}
|
||||||
|
|
||||||
|
private static List<String> eventScriptFilePaths() throws IOException {
|
||||||
|
return getScriptFilePaths("event");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getScriptFilePaths(final String scriptsSubdirectory) throws IOException {
|
||||||
|
Path scriptDirectory = Path.of("scripts", scriptsSubdirectory);
|
||||||
|
try (Stream<Path> pathStream = Files.walk(scriptDirectory)) {
|
||||||
return pathStream
|
return pathStream
|
||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
.map(ScriptEvaluationTest::mapToNpcScriptPath)
|
.map(path -> "%s/%s".formatted(scriptsSubdirectory, path.getFileName().toString()))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String mapToNpcScriptPath(Path path) {
|
@ParameterizedTest
|
||||||
return "npc/%s".formatted(path.getFileName().toString());
|
@MethodSource("eventScriptFilePaths")
|
||||||
|
void eventScriptShouldEvaluate(String eventScriptPath) {
|
||||||
|
ScriptEngine scriptEngine = scriptManager.getInvocableScriptEngine(eventScriptPath);
|
||||||
|
|
||||||
|
assertNotNull(scriptEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("npcScriptFiles")
|
@MethodSource("npcScriptFilePaths")
|
||||||
void npcScriptShouldEvaluate(String npcScriptPath) {
|
void npcScriptShouldEvaluate(String npcScriptPath) {
|
||||||
ScriptEngine scriptEngine = scriptManager.getInvocableScriptEngine(npcScriptPath);
|
ScriptEngine scriptEngine = scriptManager.getInvocableScriptEngine(npcScriptPath);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user