Better error message for script failure
This commit is contained in:
parent
f9f8ea2b5a
commit
ea366220eb
|
@ -19,10 +19,13 @@ public class ScriptTests
|
||||||
[TestCaseSource(nameof(DatcTestCases))]
|
[TestCaseSource(nameof(DatcTestCases))]
|
||||||
public void Test_DATC(string testScriptPath)
|
public void Test_DATC(string testScriptPath)
|
||||||
{
|
{
|
||||||
|
string filename = Path.GetFileName(testScriptPath);
|
||||||
|
int line = 0;
|
||||||
IScriptHandler? handler = new SetupScriptHandler(World.WithStandardMap(), strict: true);
|
IScriptHandler? handler = new SetupScriptHandler(World.WithStandardMap(), strict: true);
|
||||||
foreach (string input in File.ReadAllLines(testScriptPath)) {
|
foreach (string input in File.ReadAllLines(testScriptPath)) {
|
||||||
|
line++;
|
||||||
handler = handler?.HandleInput(input);
|
handler = handler?.HandleInput(input);
|
||||||
Assert.That(handler, Is.Not.Null, $"Script quit unexpectedly at \"{input}\"");
|
if (handler is null) Assert.Fail($"Script {filename} quit unexpectedly at line {line}: \"{input}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue