@@ -21,7 +21,8 @@ import spock.lang.TempDir
2121import spock.util.environment.Jvm
2222
2323class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
24-
24+ // CodeNarc incorrectly thinks ".class" is unnecessary in getLogger
25+ @SuppressWarnings (' UnnecessaryDotClass' )
2526 private static final Logger LOGGER = LoggerFactory . getLogger(JUnitConsoleSmokeTest . class)
2627
2728 private static final String TEST_SERVICE_NAME = " test-headless-service"
@@ -53,8 +54,10 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
5354
5455 def exitCode = whenRunningJUnitConsole([
5556 " ${ Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_FLAKY_RETRY_COUNT)} =2" as String ,
56- " ${ Strings.propertyNameToSystemPropertyName(GeneralConfig.AGENTLESS_LOG_SUBMISSION_URL)} =${ mockBackend.intakeUrl} " as String ],
57- [:])
57+ " ${ Strings.propertyNameToSystemPropertyName(GeneralConfig.AGENTLESS_LOG_SUBMISSION_URL)} =${ mockBackend.intakeUrl} " as String
58+ ],
59+ [:])
60+ assert exitCode == 1
5861
5962 def additionalDynamicTags = [" content.meta.['_dd.debug.error.6.snapshot_id']" , " content.meta.['_dd.debug.error.exception_id']" ]
6063 verifyEventsAndCoverages(projectName, " junit-console" , " headless" , mockBackend. waitForEvents(5 ), mockBackend. waitForCoverages(0 ), additionalDynamicTags)
@@ -73,20 +76,20 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
7376
7477 private void copyFolder (Path src , Path dest ) throws IOException {
7578 Files . walkFileTree(src, new SimpleFileVisitor<Path > () {
76- @Override
77- FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs )
79+ @Override
80+ FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs )
7881 throws IOException {
79- Files . createDirectories(dest. resolve(src. relativize(dir)))
80- return FileVisitResult . CONTINUE
81- }
82+ Files . createDirectories(dest. resolve(src. relativize(dir)))
83+ return FileVisitResult . CONTINUE
84+ }
8285
83- @Override
84- FileVisitResult visitFile (Path file , BasicFileAttributes attrs )
86+ @Override
87+ FileVisitResult visitFile (Path file , BasicFileAttributes attrs )
8588 throws IOException {
86- Files . copy(file, dest. resolve(src. relativize(file)))
87- return FileVisitResult . CONTINUE
88- }
89- })
89+ Files . copy(file, dest. resolve(src. relativize(file)))
90+ return FileVisitResult . CONTINUE
91+ }
92+ })
9093
9194 // creating empty .git directory so that the tracer could detect projectFolder as repo root
9295 Files . createDirectory(projectHome. resolve(" .git" ))
@@ -153,14 +156,14 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
153156
154157 List<String > javaFiles = []
155158 Files . walkFileTree(directory, new SimpleFileVisitor<Path > () {
156- @Override
157- FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) throws IOException {
158- if (file. toString(). endsWith(" .java" )) {
159- javaFiles. add(file. toString())
159+ @Override
160+ FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) throws IOException {
161+ if (file. toString(). endsWith(" .java" )) {
162+ javaFiles. add(file. toString())
163+ }
164+ return FileVisitResult . CONTINUE
160165 }
161- return FileVisitResult . CONTINUE
162- }
163- })
166+ })
164167
165168 return javaFiles
166169 }
@@ -173,15 +176,15 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
173176 return runProcess(processBuilder. start())
174177 }
175178
176- private static runProcess (Process p , int timeout_secs = PROCESS_TIMEOUT_SECS ) {
179+ private static runProcess (Process p , int timeoutSecs = PROCESS_TIMEOUT_SECS ) {
177180 StreamConsumer errorGobbler = new StreamConsumer (p. getErrorStream(), " ERROR" )
178181 StreamConsumer outputGobbler = new StreamConsumer (p. getInputStream(), " OUTPUT" )
179182 outputGobbler. start()
180183 errorGobbler. start()
181184
182- if (! p. waitFor(timeout_secs , TimeUnit . SECONDS )) {
185+ if (! p. waitFor(timeoutSecs , TimeUnit . SECONDS )) {
183186 p. destroyForcibly()
184- throw new TimeoutException (" Instrumented process failed to exit within $t imeout_secs seconds" )
187+ throw new TimeoutException (" Instrumented process failed to exit within $t imeoutSecs seconds" )
185188 }
186189
187190 return p. exitValue()
@@ -194,7 +197,10 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
194197 command. add(javaPath())
195198 command. addAll((String []) [" -jar" , JUNIT_CONSOLE_JAR_PATH ])
196199 command. addAll(consoleCommand)
197- command. addAll([" --class-path" , [projectHome. resolve(" target/classes" ). toString(), projectHome. resolve(" target/test-classes" )]. join(" :" )])
200+ command. addAll([
201+ " --class-path" ,
202+ [projectHome. resolve(" target/classes" ). toString(), projectHome. resolve(" target/test-classes" )]. join(" :" )
203+ ])
198204 command. add(" --scan-class-path" )
199205
200206 ProcessBuilder processBuilder = new ProcessBuilder (command)
@@ -255,9 +261,8 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
255261 private static String buildJavaHome () {
256262 if (Jvm . current. isJava8()) {
257263 return System . getenv(" JAVA_8_HOME" )
258- } else {
259- return System . getenv(" JAVA_" + Jvm . current. getJavaSpecificationVersion() + " _HOME" )
260264 }
265+ return System . getenv(" JAVA_" + Jvm . current. getJavaSpecificationVersion() + " _HOME" )
261266 }
262267
263268 private static class StreamConsumer extends Thread {
0 commit comments