Skip to content

Commit eb2ca09

Browse files
committed
Move impl init/deinit to implementation test base class
Move `Implementation.setServerType(Implementation.Type.TEST);` and `StaticTest.InstallFakeServerFrontend();` from many test classes to `AbstractImplementationTest` and use that as parent class of those classes. Fixes individual tests failing in the IDE and occasional test failures in the automated Linux build.
1 parent d799f3f commit eb2ca09

38 files changed

+115
-179
lines changed

src/test/java/com/laytonsmith/PureUtilities/ReflectionUtilsTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,19 @@
22

33
import com.laytonsmith.PureUtilities.ClassLoading.ClassDiscovery;
44
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
5-
import com.laytonsmith.testing.StaticTest;
5+
import com.laytonsmith.testing.AbstractIntegrationTest;
66
import static org.junit.Assert.assertEquals;
7-
import org.junit.Before;
87
import org.junit.Test;
98

109
/**
1110
*
1211
*
1312
*/
14-
public class ReflectionUtilsTest {
13+
public class ReflectionUtilsTest extends AbstractIntegrationTest {
1514

1615
public ReflectionUtilsTest() {
1716
}
1817

19-
@Before
20-
public void setUp() {
21-
StaticTest.InstallFakeServerFrontend();
22-
}
23-
2418
class A {
2519

2620
B bObj = new B();

src/test/java/com/laytonsmith/core/CodeTargetTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.laytonsmith.core.constructs.Target;
66
import com.laytonsmith.core.environments.Environment;
77
import com.laytonsmith.core.functions.StringHandling;
8-
import com.laytonsmith.testing.StaticTest;
8+
import com.laytonsmith.testing.AbstractIntegrationTest;
99
import java.io.File;
1010
import java.util.List;
1111
import static org.junit.Assert.fail;
@@ -14,12 +14,11 @@
1414
/**
1515
* This class tests various scripts that have historically been shown to have incorrect code targets.
1616
*/
17-
public class CodeTargetTest {
17+
public class CodeTargetTest extends AbstractIntegrationTest {
1818

1919
private static final File TEST_FILE = new File("test.ms");
2020

2121
private List<ParseTree> compile(String script) throws Exception {
22-
StaticTest.InstallFakeServerFrontend();
2322
Environment env = Static.GenerateStandaloneEnvironment();
2423
File file = TEST_FILE;
2524
TokenStream stream = MethodScriptCompiler.lex(script, env, file, true);

src/test/java/com/laytonsmith/core/MethodScriptCompilerTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
import com.laytonsmith.core.exceptions.ConfigCompileException;
2424
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
2525
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
26+
import com.laytonsmith.testing.AbstractIntegrationTest;
2627
import com.laytonsmith.testing.StaticTest;
2728
import org.junit.After;
2829
import org.junit.AfterClass;
2930
import org.junit.Before;
30-
import org.junit.BeforeClass;
3131
import org.junit.Ignore;
3232
import org.junit.Test;
3333

@@ -61,7 +61,7 @@
6161
//@RunWith(PowerMockRunner.class)
6262
//@PrepareForTest(CommandHelperPlugin.class)
6363
//@PowerMockIgnore({"javax.xml.parsers.*", "com.sun.org.apache.xerces.internal.jaxp.*"})
64-
public class MethodScriptCompilerTest {
64+
public class MethodScriptCompilerTest extends AbstractIntegrationTest {
6565

6666
MCServer fakeServer;
6767
MCPlayer fakePlayer;
@@ -72,11 +72,6 @@ public MethodScriptCompilerTest() {
7272
//StaticTest.InstallFakeServerFrontend();
7373
}
7474

75-
@BeforeClass
76-
public static void setUpClass() throws Exception {
77-
StaticTest.InstallFakeServerFrontend();
78-
}
79-
8075
@AfterClass
8176
public static void tearDownClass() throws Exception {
8277
new File("profiler.config").deleteOnExit();

src/test/java/com/laytonsmith/core/NewExceptionHandlingTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import com.laytonsmith.core.exceptions.AbstractCompileException;
88
import com.laytonsmith.core.exceptions.CRE.CRECastException;
99
import com.laytonsmith.core.functions.Exceptions;
10+
import com.laytonsmith.testing.AbstractIntegrationTest;
1011
import com.laytonsmith.testing.StaticTest;
1112
import org.junit.Before;
12-
import org.junit.BeforeClass;
1313
import org.junit.Ignore;
1414
import org.junit.Test;
1515

@@ -28,15 +28,10 @@
2828
/**
2929
*
3030
*/
31-
public class NewExceptionHandlingTest {
31+
public class NewExceptionHandlingTest extends AbstractIntegrationTest {
3232

3333
static Set<Class<? extends Environment.EnvironmentImpl>> envs = Environment.getDefaultEnvClasses();
3434

35-
@BeforeClass
36-
public static void setUpClass() {
37-
StaticTest.InstallFakeServerFrontend();
38-
}
39-
4035
public String optimize(String script) throws Exception {
4136
return OptimizationUtilities.optimize(script, null, envs, null, true, true);
4237
}

src/test/java/com/laytonsmith/core/OptimizationTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.laytonsmith.core.environments.Environment;
99
import com.laytonsmith.core.exceptions.ConfigCompileException;
1010
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
11-
import com.laytonsmith.testing.StaticTest;
11+
import com.laytonsmith.testing.AbstractIntegrationTest;
1212
import java.io.File;
1313
import java.util.ArrayList;
1414
import java.util.Arrays;
@@ -17,24 +17,18 @@
1717
import org.junit.Assert;
1818
import static org.junit.Assert.assertEquals;
1919
import static org.junit.Assert.fail;
20-
import org.junit.BeforeClass;
2120
import org.junit.Test;
2221

2322
/**
2423
* This class tests optimizations by looking at the tree after optimization occurs to see if it matches expectation.
2524
*
2625
* This is also used to test the lexer/compiler at a low level
2726
*/
28-
public class OptimizationTest {
27+
public class OptimizationTest extends AbstractIntegrationTest {
2928

3029
static Set<Class<? extends Environment.EnvironmentImpl>> envs = Environment.getDefaultEnvClasses();
3130
static Environment env;
3231

33-
@BeforeClass
34-
public static void setUpClass() {
35-
StaticTest.InstallFakeServerFrontend();
36-
}
37-
3832
public static String optimize(String script, boolean pureMethodScript, Environment env) throws Exception {
3933
try {
4034
try {

src/test/java/com/laytonsmith/core/StaticAnalysisTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@
99
import com.laytonsmith.core.environments.RuntimeMode;
1010
import com.laytonsmith.core.exceptions.ConfigCompileException;
1111
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
12-
import com.laytonsmith.testing.StaticTest;
12+
import com.laytonsmith.testing.AbstractIntegrationTest;
13+
1314
import java.io.File;
1415
import java.util.Arrays;
1516
import java.util.EnumSet;
1617
import java.util.HashSet;
1718
import static org.junit.Assert.*;
18-
import org.junit.BeforeClass;
1919
import org.junit.Ignore;
2020
import org.junit.Test;
2121

2222
/**
2323
*
2424
*/
25-
public class StaticAnalysisTest {
26-
@BeforeClass
27-
public static void beforeClass() {
28-
StaticTest.InstallFakeServerFrontend();
29-
}
25+
public class StaticAnalysisTest extends AbstractIntegrationTest {
3026

3127
public void runScript(String script) throws Exception {
3228
runScript(script, null);

src/test/java/com/laytonsmith/core/TestStatic.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.laytonsmith.core.constructs.CString;
99
import com.laytonsmith.core.constructs.Target;
1010
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
11+
import com.laytonsmith.testing.AbstractIntegrationTest;
1112
import com.laytonsmith.testing.C;
1213
import org.junit.AfterClass;
1314
import static org.junit.Assert.assertEquals;
@@ -23,7 +24,7 @@
2324
*
2425
*
2526
*/
26-
public class TestStatic {
27+
public class TestStatic extends AbstractIntegrationTest {
2728

2829
Target t = Target.UNKNOWN;
2930

src/test/java/com/laytonsmith/core/VarargTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.laytonsmith.abstraction.MCPlayer;
44
import com.laytonsmith.core.environments.Environment;
55
import com.laytonsmith.core.exceptions.CRE.CRECastException;
6+
import com.laytonsmith.testing.AbstractIntegrationTest;
67
import com.laytonsmith.core.exceptions.ConfigCompileException;
78
import static com.laytonsmith.testing.StaticTest.*;
89
import org.junit.Before;
@@ -12,14 +13,13 @@
1213
/**
1314
*
1415
*/
15-
public class VarargTest {
16+
public class VarargTest extends AbstractIntegrationTest {
1617

1718
Environment env;
1819
MCPlayer fakePlayer;
1920

2021
@Before
2122
public void setup() throws Exception {
22-
InstallFakeServerFrontend();
2323
env = Static.GenerateStandaloneEnvironment();
2424
fakePlayer = GetOnlinePlayer();
2525
}

src/test/java/com/laytonsmith/core/asm/IRMetadataTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.laytonsmith.core.Static;
55
import com.laytonsmith.core.asm.metadata.IRMetadata.PrototypeBuilder;
66
import com.laytonsmith.core.environments.CommandHelperEnvironment;
7-
import com.laytonsmith.testing.StaticTest;
7+
import com.laytonsmith.testing.AbstractIntegrationTest;
88
import org.junit.Test;
99

1010
import static org.junit.Assert.assertEquals;
@@ -14,12 +14,11 @@
1414
*
1515
* @author Cailin
1616
*/
17-
public class IRMetadataTest {
17+
public class IRMetadataTest extends AbstractIntegrationTest {
1818

1919
com.laytonsmith.core.environments.Environment env;
2020

2121
public IRMetadataTest() throws Exception {
22-
StaticTest.InstallFakeServerFrontend();
2322
env = Static.GenerateStandaloneEnvironment();
2423
env = env.cloneAndAdd(new CommandHelperEnvironment(), new LLVMEnvironment());
2524
}

src/test/java/com/laytonsmith/core/compiler/signatures/FunctionSignaturesTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.Set;
1010

1111
import org.junit.Before;
12-
import org.junit.BeforeClass;
1312
import org.junit.Test;
1413

1514
import com.laytonsmith.core.Static;
@@ -27,17 +26,12 @@
2726
import com.laytonsmith.core.exceptions.ConfigCompileException;
2827
import com.laytonsmith.core.exceptions.CRE.CRECastException;
2928
import com.laytonsmith.core.exceptions.CRE.CREIndexOverflowException;
30-
import com.laytonsmith.testing.StaticTest;
29+
import com.laytonsmith.testing.AbstractIntegrationTest;
3130

32-
public class FunctionSignaturesTest {
31+
public class FunctionSignaturesTest extends AbstractIntegrationTest {
3332

3433
private Environment env;
3534

36-
@BeforeClass
37-
public static void setUpClass() throws Exception {
38-
StaticTest.InstallFakeServerFrontend();
39-
}
40-
4135
@Before
4236
public void setUp() throws Exception {
4337
this.env = Static.GenerateStandaloneEnvironment(false);

0 commit comments

Comments
 (0)