@@ -17,77 +17,83 @@ package io.github.ascopes.jct.acceptancetests.errorprone
1717
1818import io.github.ascopes.jct.compilers.JctCompiler
1919import io.github.ascopes.jct.junit.JavacCompilerTest
20- import io.github.ascopes.jct.workspaces.Workspaces
20+ import io.github.ascopes.jct.junit.JctExtension
21+ import io.github.ascopes.jct.junit.Managed
22+ import io.github.ascopes.jct.workspaces.PathStrategy
23+ import io.github.ascopes.jct.workspaces.Workspace
2124import org.junit.jupiter.api.BeforeAll
2225import org.junit.jupiter.api.DisplayName
26+ import org.junit.jupiter.api.extension.ExtendWith
2327
2428import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation
2529import static org.assertj.core.api.Assumptions.assumeThat
2630
2731@DisplayName (" Error-prone acceptance tests" )
32+ @ExtendWith (JctExtension .class)
2833class ErrorProneTest {
2934
35+ // Use tempdirectories as ErrorProne isn't compatible with the URLs memoryfilesystem emits. This
36+ // is due to the path being left null in the implementation.
37+ @Managed (pathStrategy = PathStrategy .TEMP_DIRECTORIES )
38+ Workspace workspace;
39+
3040 @BeforeAll
3141 static void workAroundIdea317391 () {
3242 // Workaround for https://youtrack.jetbrains.com/issue/IDEA-317391
3343 assumeThat(System . getProperty(" mvnArgLinePropagated" , " false" ))
34- .withFailMessage(" Your IDE has not propagated the <argLine/> in the pom.xml" )
35- .isEqualTo(" true" );
44+ .withFailMessage(" Your IDE has not propagated the <argLine/> in the pom.xml" )
45+ .isEqualTo(" true" );
3646 }
3747
3848 @DisplayName (" Happy paths work as expected" )
3949 @JavacCompilerTest
4050 void happyPathsWorkAsExpected (JctCompiler compiler ) {
41- try (def workspace = Workspaces . newWorkspace()) {
42- // Given
43- workspace
44- .createSourcePathPackage()
45- .createDirectory(" org" , " example" )
46- .copyContentsFrom(" src" , " test" , " resources" , " code" , " nullness" , " happy" )
51+ // Given
52+ workspace
53+ .createSourcePathPackage()
54+ .createDirectory(" org" , " example" )
55+ .copyContentsFrom(" src" , " test" , " resources" , " code" , " nullness" , " happy" )
4756
48- // When
49- def compilation = compiler
50- .addCompilerOptions(
51- " -Xplugin:ErrorProne" ,
52- " -XDcompilePolicy=simple" ,
53- )
54- .compile(workspace)
57+ // When
58+ def compilation = compiler
59+ .addCompilerOptions(
60+ " -Xplugin:ErrorProne" ,
61+ " -XDcompilePolicy=simple" ,
62+ )
63+ .compile(workspace)
5564
56- // Then
57- assertThatCompilation(compilation)
58- .isSuccessfulWithoutWarnings()
59- }
65+ // Then
66+ assertThatCompilation(compilation)
67+ .isSuccessfulWithoutWarnings()
6068 }
6169
6270 @DisplayName (" Sad paths fail as expected" )
6371 @JavacCompilerTest
6472 void sadPathsFailAsExpected (JctCompiler compiler ) {
65- try (def workspace = Workspaces . newWorkspace()) {
66- // Given
67- workspace
68- .createSourcePathPackage()
69- .createDirectory(" org" , " example" )
70- .copyContentsFrom(" src" , " test" , " resources" , " code" , " nullness" , " sad" )
73+ // Given
74+ workspace
75+ .createSourcePathPackage()
76+ .createDirectory(" org" , " example" )
77+ .copyContentsFrom(" src" , " test" , " resources" , " code" , " nullness" , " sad" )
7178
72- // When
73- def compilation = compiler
74- .addCompilerOptions(
75- " -Xplugin:ErrorProne" ,
76- " -XDcompilePolicy=simple" ,
77- )
78- .compile(workspace)
79+ // When
80+ def compilation = compiler
81+ .addCompilerOptions(
82+ " -Xplugin:ErrorProne" ,
83+ " -XDcompilePolicy=simple" ,
84+ )
85+ .compile(workspace)
7986
80- // Then
81- assertThatCompilation(compilation)
82- .isFailure()
83- .diagnostics()
84- .errors()
85- .singleElement()
86- .message()
87- .startsWith(
88- " [MustBeClosedChecker] This method returns a resource which must be managed "
89- + " carefully, not just left for garbage collection."
90- )
91- }
87+ // Then
88+ assertThatCompilation(compilation)
89+ .isFailure()
90+ .diagnostics()
91+ .errors()
92+ .singleElement()
93+ .message()
94+ .startsWith(
95+ " [MustBeClosedChecker] This method returns a resource which must be managed "
96+ + " carefully, not just left for garbage collection."
97+ )
9298 }
9399}
0 commit comments