@@ -50,57 +50,60 @@ public void all() throws Throwable {
50
50
final Iterator <Path > iterator = Files .walk (path , 1 ).iterator ();
51
51
int failure = 0 ;
52
52
final List <Throwable > errors = new ArrayList <>();
53
- while (iterator .hasNext ()) {
54
- final Path file = iterator .next ();
55
- if (!file .toString ().endsWith (".bsk" )) continue ;
56
- final String part = file .toString ().substring (file .toString ().indexOf ("/tests/" ) + 7 );
57
- final String name = part .substring (0 , part .length () - 4 ).replace (File .separatorChar , '.' );
58
- System .out .println (ConsoleColour .RESET + "Running test '" + ConsoleColour .GREEN + name + ConsoleColour .RESET + "':" );
59
- try (final InputStream stream = Files .newInputStream (file )) {
60
- final PostCompileClass [] classes ;
61
- synchronized (this ) {
62
- try {
63
- final long now , then ;
64
- now = System .currentTimeMillis ();
65
- classes = skript .compileComplexScript (stream , "skript." + name );
66
- then = System .currentTimeMillis ();
67
- System .out .println (ConsoleColour .GREEN + "\t ✓ " + ConsoleColour .RESET + "Parsed in " + ConsoleColour .BLUE + (then - now ) + ConsoleColour .RESET + " milliseconds." );
68
- } catch (Throwable ex ) {
69
- System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Failed to parse." );
70
- System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Failed to run." );
71
- errors .add (ex );
72
- failure ++;
73
- continue ;
53
+ synchronized (System .out ) {
54
+ while (iterator .hasNext ()) {
55
+ final Path file = iterator .next ();
56
+ if (!file .toString ().endsWith (".bsk" )) continue ;
57
+ final String part = file .toString ().substring (file .toString ().indexOf ("/tests/" ) + 7 );
58
+ final String name = part .substring (0 , part .length () - 4 ).replace (File .separatorChar , '.' );
59
+ System .out .println (ConsoleColour .RESET + "Running test '" + ConsoleColour .GREEN + name + ConsoleColour .RESET + "':" );
60
+ try (final InputStream stream = Files .newInputStream (file )) {
61
+ final PostCompileClass [] classes ;
62
+ synchronized (this ) {
63
+ try {
64
+ final long now , then ;
65
+ now = System .currentTimeMillis ();
66
+ classes = skript .compileComplexScript (stream , "skript." + name );
67
+ then = System .currentTimeMillis ();
68
+ System .out .println (ConsoleColour .GREEN + "\t ✓ " + ConsoleColour .RESET + "Parsed in " + ConsoleColour .BLUE + (then - now ) + ConsoleColour .RESET + " milliseconds." );
69
+ } catch (Throwable ex ) {
70
+ System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Failed to parse." );
71
+ System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Failed to run." );
72
+ errors .add (ex );
73
+ failure ++;
74
+ continue ;
75
+ }
76
+ try {
77
+ final long now , then ;
78
+ final Script script = skript .loadScripts (classes ).iterator ().next ();
79
+ now = System .currentTimeMillis ();
80
+ final Object object = script .getFunction ("test" ).run (skript ).get ();
81
+ final boolean result = Boolean .TRUE .equals (object );
82
+ then = System .currentTimeMillis ();
83
+ if (result )
84
+ System .out .println (ConsoleColour .GREEN + "\t ✓ " + ConsoleColour .RESET + "Run in " + ConsoleColour .BLUE + (then - now ) + ConsoleColour .RESET + " milliseconds." );
85
+ else
86
+ System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Run in " + ConsoleColour .BLUE + (then - now ) + ConsoleColour .RESET + " milliseconds." );
87
+ } catch (Throwable ex ) {
88
+ System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Failed to run." );
89
+ errors .add (ex );
90
+ failure ++;
91
+ }
74
92
}
75
- try {
76
- final long now , then ;
77
- final Script script = skript .loadScripts (classes ).iterator ().next ();
78
- now = System .currentTimeMillis ();
79
- final Object object = script .getFunction ("test" ).run (skript ).get ();
80
- final boolean result = Boolean .TRUE .equals (object );
81
- then = System .currentTimeMillis ();
82
- if (result )
83
- System .out .println (ConsoleColour .GREEN + "\t ✓ " + ConsoleColour .RESET + "Run in " + ConsoleColour .BLUE + (then - now ) + ConsoleColour .RESET + " milliseconds." );
84
- else
85
- System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Run in " + ConsoleColour .BLUE + (then - now ) + ConsoleColour .RESET + " milliseconds." );
86
- } catch (Throwable ex ) {
87
- System .out .println (ConsoleColour .RED + "\t ✗ " + ConsoleColour .RESET + "Failed to run." );
88
- errors .add (ex );
89
- failure ++;
93
+ final File test = new File ("target/test-scripts/" + classes [0 ].name () + ".class" );
94
+ test .getParentFile ().mkdirs ();
95
+ if (!test .exists ()) test .createNewFile ();
96
+ try (final OutputStream output = new FileOutputStream (test )) {
97
+ output .write (classes [0 ].code ());
90
98
}
99
+ } catch (Throwable ex ) {
100
+ ex .printStackTrace ();
91
101
}
92
- final File test = new File ("target/test-scripts/" + classes [0 ].name () + ".class" );
93
- test .getParentFile ().mkdirs ();
94
- if (!test .exists ()) test .createNewFile ();
95
- try (final OutputStream output = new FileOutputStream (test )) {
96
- output .write (classes [0 ].code ());
97
- }
98
- } catch (Throwable ex ) {
99
- ex .printStackTrace ();
100
102
}
101
- }
102
- for (final Throwable error : errors ) {
103
- error .printStackTrace (System .err );
103
+ for (final Throwable error : errors )
104
+ synchronized (this ) {
105
+ error .printStackTrace (System .out );
106
+ }
104
107
}
105
108
assert failure < 1 : failure + " tests have failed." ;
106
109
}
0 commit comments