8240970: Some tests fail when run with JCov

Reviewed-by: jjg
This commit is contained in:
Vicente Romero 2020-03-18 14:33:05 -04:00
parent 700f50f287
commit bf54c47471
7 changed files with 83 additions and 61 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -48,6 +48,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.sun.tools.javac.launcher.Main;
@ -537,13 +538,13 @@ public class SourceLauncherTest extends TestRunner {
" }\n" +
"}");
String log = new JavaTask(tb)
List<String> log = new JavaTask(tb)
.vmOptions("--enable-preview")
.className(base.resolve("HelloWorld.java").toString())
.run(Task.Expect.FAIL)
.getOutput(Task.OutputKind.STDERR);
checkEqual("stderr", log.trim(),
"error: --enable-preview must be used with --source");
.getOutputLines(Task.OutputKind.STDERR);
log = log.stream().filter(s->!s.matches("^Picked up .*JAVA.*OPTIONS:.*")).collect(Collectors.toList());
checkEqual("stderr", log, List.of("error: --enable-preview must be used with --source"));
}
@Test
@ -663,6 +664,11 @@ public class SourceLauncherTest extends TestRunner {
}
}
void checkEqual(String name, List<String> found, List<String> expect) {
out.println(name + ": " + found);
tb.checkEqual(expect, found);
}
void checkMatch(String name, String found, Pattern expect) {
out.println(name + ": " + found);
if (!expect.matcher(found).matches()) {