Skip to content

Commit

Permalink
Add JDK 14 to the test matrix, #686
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Sep 8, 2020
2 parents 6c9e069 + d8e1364 commit 1a6ff6f
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 225 deletions.
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@ jobs:
<<: *env_gradle_large
<<: *test_nomaven
test_nomaven_11:
# latest LTS version
<<: *env_gradle_large
docker:
- image: cimg/openjdk:11.0
environment: # java 11 does play nice with containers, doesn't need special settings
_JAVA_OPTIONS: ""
<<: *test_nomaven
test_nomaven_14:
# latest JDK, replace with 15 when it comes out
<<: *env_gradle_large
docker:
- image: cimg/openjdk:14.0
environment: # java 14 does play nice with containers, doesn't need special settings
_JAVA_OPTIONS: ""
<<: *test_nomaven
test_justmaven_8:
<< : *env_gradle
steps:
Expand Down Expand Up @@ -209,6 +218,9 @@ workflows:
- test_nomaven_11:
requires:
- assemble_testClasses
- test_nomaven_14:
requires:
- assemble_testClasses
- test_npm_8:
requires:
- assemble_testClasses
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

## [Unreleased]
### Fixed
* We now run all tests against JDK 8, JDK 11, and also JDK 14 ([#684](https://github.com/diffplug/spotless/pull/684)).
* We had test files in `testlib/src/main/resources` named `module-info.java` and `package-info.java`. They cause problems for the Eclipse IDE trying to interpret them literally. Added `.test` suffix to the filenames so that eclipse doesn't barf on them anymore ([#683](https://github.com/diffplug/spotless/pull/683)).

## [2.4.0] - 2020-08-29
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 DiffPlug
* Copyright 2016-2020 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,8 +64,12 @@ public abstract class EclipseCommonTests extends ResourceHarness {
/** Create formatter step for a specific version */
protected abstract FormatterStep createStep(String version);

/** Called before the test, so that clients may call {@link org.junit.Assume}. */
protected void makeAssumptions() {}

@Test
public void testSupportedVersions() throws Exception {
makeAssumptions();
String[] versions = getSupportedVersions();
for (String version : versions) {
String input = getTestInput(version);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 DiffPlug
* Copyright 2016-2020 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@
package com.diffplug.spotless.extra.groovy;

import com.diffplug.spotless.FormatterStep;
import com.diffplug.spotless.JreVersion;
import com.diffplug.spotless.TestProvisioner;
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
import com.diffplug.spotless.extra.eclipse.EclipseCommonTests;
Expand All @@ -36,6 +37,30 @@ protected String getTestExpectation(String version) {
return "class F{\n\tdef m(){}\n}";
}

@Override
protected void makeAssumptions() {
// JRE 11 warns like this:
// WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
// WARNING: All illegal access operations will be denied in a future release
// And after that it fails like this:
// Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
// at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:39)
// at org.codehaus.groovy.ast.ClassHelper.makeCached(ClassHelper.java:133)
// at org.codehaus.groovy.ast.ClassHelper.<clinit>(ClassHelper.java:67)
// at org.codehaus.groovy.classgen.Verifier.<clinit>(Verifier.java:113)
// at org.codehaus.groovy.control.CompilationUnit.<init>(CompilationUnit.java:158)
// at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyParser.makeCompilationUnit(GroovyParser.java:467)
// at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyParser.<init>(GroovyParser.java:247)
// at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyParser.<init>(GroovyParser.java:216)
// at org.codehaus.groovy.eclipse.core.compiler.GroovySnippetParser.dietParse(GroovySnippetParser.java:105)
// at org.codehaus.groovy.eclipse.core.compiler.GroovySnippetParser.parse(GroovySnippetParser.java:69)
// at org.codehaus.groovy.eclipse.refactoring.core.utils.ASTTools.getASTNodeFromSource(ASTTools.java:204)
// at org.codehaus.groovy.eclipse.refactoring.formatter.DefaultGroovyFormatter.initCodebase(DefaultGroovyFormatter.java:109)
// at org.codehaus.groovy.eclipse.refactoring.formatter.DefaultGroovyFormatter.format(DefaultGroovyFormatter.java:121)
// at com.diffplug.spotless.extra.eclipse.groovy.GrEclipseFormatterStepImpl.format(GrEclipseFormatterStepImpl.java:81)
JreVersion.assume11OrLess();
}

@Override
protected FormatterStep createStep(String version) {
EclipseBasedStepBuilder builder = GrEclipseFormatterStep.createBuilder(TestProvisioner.mavenCentral());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
import com.diffplug.common.base.CharMatcher;
import com.diffplug.common.base.Splitter;
import com.diffplug.common.base.StringPrinter;
import com.diffplug.spotless.JreVersion;
import com.diffplug.spotless.LineEnding;

/** Tests the desired behavior from https://github.com/diffplug/spotless/issues/46. */
public class ErrorShouldRethrowJre11Test extends GradleIntegrationHarness {
public class ErrorShouldRethrowTest extends GradleIntegrationHarness {
private void writeBuild(String... toInsert) throws IOException {
List<String> lines = new ArrayList<>();
lines.add("plugins {");
Expand Down Expand Up @@ -121,17 +120,11 @@ public void failsIfNeitherStepNorFileExempted() throws Exception {
}

private void runWithSuccess(String... messages) throws Exception {
if (JreVersion.thisVm() != JreVersion._11) {
return;
}
BuildResult result = gradleRunner().withArguments("check").build();
assertResultAndMessages(result, TaskOutcome.SUCCESS, messages);
}

private void runWithFailure(String... messages) throws Exception {
if (JreVersion.thisVm() != JreVersion._11) {
return;
}
BuildResult result = gradleRunner().withArguments("check").buildAndFail();
assertResultAndMessages(result, TaskOutcome.FAILED, messages);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.diffplug.common.tree.TreeDef;
import com.diffplug.common.tree.TreeStream;
import com.diffplug.spotless.FileSignature;
import com.diffplug.spotless.JreVersion;
import com.diffplug.spotless.ResourceHarness;

public class GradleIntegrationHarness extends ResourceHarness {
Expand All @@ -43,7 +44,12 @@ public enum GradleVersionSupport {
final String version;

GradleVersionSupport(String version) {
this.version = version;
if (JreVersion.thisVm() >= 14) {
// the first version with support for Java 14+
this.version = "6.3";
} else {
this.version = version;
}
}
}

Expand Down
Loading

0 comments on commit 1a6ff6f

Please sign in to comment.