-
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests - update test command to show failures (#7400)
* Tests - even more fun updates * SkriptCommand - close loggers to stop errors * TestResults - make lists look like list and add "none" when empty * TestTracker - add "parsing" * CountingLogHandler - revert * TestingLogHandler - switch to custom log handler * CountingLogHandler - revert more * CountingLogHandler - revert more * Tests - even more fun updates * SkriptCommand - close loggers to stop errors * TestTracker - add "parsing" * CountingLogHandler - revert * TestingLogHandler - switch to custom log handler * CountingLogHandler - revert more * CountingLogHandler - revert more * Tests - even more fun updates * CountingLogHandler - revert changes * Skript - change logger and remove delay in dev mode
- Loading branch information
Showing
7 changed files
with
86 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ch.njol.skript.log; | ||
|
||
import ch.njol.skript.config.Node; | ||
import ch.njol.skript.lang.parser.ParserInstance; | ||
import ch.njol.skript.test.runner.EvtTestCase; | ||
import ch.njol.skript.test.runner.TestTracker; | ||
import org.skriptlang.skript.lang.structure.Structure; | ||
|
||
import java.util.logging.Level; | ||
|
||
/** | ||
* Counts logged messages of a certain type and logs parse errors to {@link TestTracker} | ||
*/ | ||
public class TestingLogHandler extends LogHandler { | ||
|
||
private final int minimum; | ||
private int count; | ||
private final ParserInstance parser; | ||
|
||
public TestingLogHandler(Level minimum) { | ||
this.minimum = minimum.intValue(); | ||
this.parser = ParserInstance.get(); | ||
} | ||
|
||
@Override | ||
public LogResult log(LogEntry entry) { | ||
if (entry.level.intValue() >= minimum) { | ||
count++; | ||
Structure struct = parser.getCurrentStructure(); | ||
Node node = parser.getNode(); | ||
|
||
String name = struct instanceof EvtTestCase test ? test.getTestName() : struct != null ? struct.getSyntaxTypeName() : null; | ||
TestTracker.parsingStarted(name); | ||
|
||
if (node != null) { | ||
TestTracker.testFailed(entry.getMessage(), parser.getCurrentScript(), node.getLine()); | ||
} else { | ||
TestTracker.testFailed(entry.getMessage()); | ||
} | ||
} | ||
return LogResult.LOG; | ||
} | ||
|
||
@Override | ||
public TestingLogHandler start() { | ||
SkriptLogger.startLogHandler(this); | ||
return this; | ||
} | ||
|
||
public int getCount() { | ||
return count; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters