Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade spock to 2.3 and groovy to 3.0.19 #1263

Merged
merged 8 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 8 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def eclipseVersionAgnosticDependencies = [
'org.slf4j.simple' : '1.7.30',
'com.google.guava' : "$guavaVersion",
'com.google.gson' : '2.7.0',
'org.eclipse.swtbot.eclipse.finder' : '2.2.1',
'org.eclipse.swtbot.junit4_x' : '2.2.1',
'org.eclipse.swtbot.eclipse.finder' : "$swtBotVersion",
'org.eclipse.swtbot.junit5_x' : "$swtBotVersion",
'org.jetbrains.kotlin.bundled-compiler': '0.8.7',
'org.jetbrains.kotlin.core' : '0.8.7'
]
Expand Down Expand Up @@ -150,7 +150,9 @@ subprojects {
implementation "org.codehaus.groovy:groovy-all:$groovyLibVersion"
bundled "org.codehaus.groovy:groovy-all:$groovyLibVersion"
bundled "org.objenesis:objenesis:$objenesisLibVersion"
bundled "org.spockframework:spock-core:$spockLibVersion"
bundled("org.spockframework:spock-core:$spockLibVersion") {
exclude group:"org.hamcrest", module: "hamcrest"
}
bundled "cglib:cglib-nodep:$cglibLibVersion"
bundled "org.slf4j:slf4j-simple:$slf4jLibVersion"
}
Expand Down Expand Up @@ -180,10 +182,9 @@ subprojects {
jvmArgs "-Djdk8.location=${java8.get().metadata.installationPath.asFile}"
jvmArgs "-Djdk11.location=${java11.get().metadata.installationPath.asFile}"

// TODO re-enable html test reporting on Windows
if (org.gradle.internal.os.OperatingSystem.current().windows) {
reports.html.enabled = false
}
// TODO re-enable html test reporting
reports.html.enabled = false
reports.junitXml.enabled = false
}

// configure the repositories where the external dependencies can be found
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repositories {
}
}

tasks.named('test') { Test task ->
task.useJUnitPlatform()
}

dependencies {
implementation gradleApi()
implementation localGroovy()
Expand All @@ -20,5 +24,7 @@ dependencies {
implementation "com.google.guava:guava:$guavaVersion-jre"
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.commons:commons-compress:1.22'
testImplementation 'org.spockframework:spock-core:2.3-groovy-3.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
}

Empty file added buildSrc/settings.gradle
Empty file.
12 changes: 4 additions & 8 deletions buildSrc/src/main/groovy/eclipsebuild/BundlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@

package eclipsebuild

import org.gradle.api.GradleException
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.jvm.tasks.Jar;
import org.osgi.framework.VersionRange;

import org.eclipse.osgi.framework.util.Headers
import org.eclipse.osgi.internal.resolver.StateObjectFactoryImpl
import org.eclipse.osgi.internal.resolver.UserState
import org.eclipse.osgi.service.resolver.BundleSpecification

import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.tasks.Copy
import org.gradle.jvm.tasks.Jar
import org.osgi.framework.Version
import org.osgi.framework.VersionRange

/**
* Gradle plug-in for building Eclipse bundles.
Expand Down Expand Up @@ -177,7 +174,6 @@ class BundlePlugin implements Plugin<Project> {
// copy the dependencies to the 'libs' folder
into libDir
from project.configurations.bundled
from project.configurations.bundledSource
}
}

Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/groovy/eclipsebuild/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package eclipsebuild
import eclipsebuild.BuildDefinitionPlugin.TargetPlatform
import org.gradle.api.Project
import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Provider
import org.gradle.internal.os.OperatingSystem

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

package eclipsebuild

import org.gradle.api.logging.Logger
import org.gradle.api.logging.LogLevel
import org.gradle.api.logging.Logger

/**
* Output stream forwarding the content of the stream to Gradle logging.
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/groovy/eclipsebuild/PluginUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package eclipsebuild

import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.api.Project

import java.nio.file.Paths

/**
Expand Down
6 changes: 1 addition & 5 deletions buildSrc/src/main/groovy/eclipsebuild/UnPack.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package eclipsebuild

import com.google.common.hash.HashingOutputStream
import org.gradle.api.artifacts.transform.CacheableTransform
import org.gradle.api.artifacts.transform.InputArtifact
import org.gradle.api.artifacts.transform.TransformAction
import org.gradle.api.artifacts.transform.TransformOutputs
import org.gradle.api.artifacts.transform.TransformParameters
import org.gradle.api.artifacts.transform.*
import org.gradle.api.file.FileSystemLocation
import org.gradle.api.provider.Provider
import org.gradle.internal.io.NullOutputStream
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/groovy/eclipsebuild/UnTarGz.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package eclipsebuild

import org.apache.commons.io.IOUtils
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import org.apache.commons.io.IOUtils

import java.util.zip.GZIPInputStream

abstract class UnTarGz extends UnPack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.*

abstract class ConvertOsgiBundleTask extends DefaultTask {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

package eclipsebuild.mavenize

import org.osgi.framework.Constants

import java.util.jar.JarFile
import java.util.jar.Manifest
import org.osgi.framework.Constants

/**
* Converts bundle manifest to POM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

package eclipsebuild.testing;

import java.io.File;

import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.JavaClass;
import org.gradle.api.file.EmptyFileVisitor;
Expand All @@ -22,6 +20,8 @@
import org.gradle.api.internal.tasks.testing.TestClassProcessor;
import org.gradle.api.internal.tasks.testing.TestClassRunInfo;

import java.io.File;

public final class EclipsePluginTestClassScanner implements Runnable {

private final FileTree candidateClassFiles;
Expand Down
123 changes: 92 additions & 31 deletions buildSrc/src/main/groovy/eclipsebuild/testing/EclipseTestEvent.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,131 @@
package eclipsebuild.testing;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
interface EclipseTestEvent {

class TestTreeEntry extends TestLifecycleCommon {

// 2,GradleImportTaskTest,true,5,false,1,GradleImportTaskTest,,[engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]
// 3,Imports project into workspace,false,1,false,2,Imports project into workspace,,[engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]/[feature:$spock_feature_2_0]
// 4,Manual trigger causes synchronization,false,1,false,2,Manual trigger causes synchronization,,[engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]/[feature:$spock_feature_2_1]
// 5,Startup trigger does not synchronize existing projects,false,1,false,2,Startup trigger does not synchronize existing projects,,[engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]/[feature:$spock_feature_2_2]
// 6,Startup trigger imports projects that are not already in the workspace,false,1,false,2,Startup trigger imports projects that are not already in the workspace,,[engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]/[feature:$spock_feature_2_3]
// 7,new build configuration can override workspace settings,false,1,false,2,new build configuration can override workspace settings,,[engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]/[feature:$spock_feature_2_4]
// 11,
// new build configuration can override workspace settings [distribution: GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(/Users/reinholddegenfellner/.gradle/wrapper/dists/gradle-5.4.1-bin/e75iq110yv9r9wt1a6619x2xm/gradle-5.4.1))\, distributionType: LOCAL_INSTALLATION\, offlineMode: false\, buildScansEnabled: true\, autoSync: false\, showConsole: true\, showExecutions: false\, customGradleHome: true\, #3],
// false,1,true,7,
// new build configuration can override workspace settings [distribution: GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(/Users/reinholddegenfellner/.gradle/wrapper/dists/gradle-5.4.1-bin/e75iq110yv9r9wt1a6619x2xm/gradle-5.4.1))\, distributionType: LOCAL_INSTALLATION\, offlineMode: false\, buildScansEnabled: true\, autoSync: false\, showConsole: true\, showExecutions: false\, customGradleHome: true\, #3],,
// [engine:spock]/[spec:org.eclipse.buildship.oomph.internal.test.GradleImportTaskTest]/[feature:$spock_feature_2_4]/[iteration:3]

private static final Pattern ENGINE_SPOCK = Pattern.compile(".*\\[engine:spock\\]\\/\\[spec:([^\\]]+)\\](\\/\\[feature:([^\\]]+)\\])?\\/?(\\[iteration:([0-9]+)\\])?");
private static final Pattern TREE_ENTRY = Pattern.compile("(\\w+),(.*[^\\\\]),(true|false),([0-9]+).*");
private final boolean isSpock;
private String spockSpec;
private String spockFeature;
private int testCount;
private boolean isSuite = false;
private String spockIteration = null;

public TestTreeEntry(String description){
super(null, null);
Matcher spockMatcher = ENGINE_SPOCK.matcher(description);
this.isSpock = spockMatcher.matches();
if(isSpock()){
this.spockIteration = spockMatcher.group(5);
this.spockFeature = spockMatcher.group(3);
this.spockSpec = spockMatcher.group(1);
}
Matcher treeEntryMatch = TREE_ENTRY.matcher(description);
if (treeEntryMatch.matches()) {
this.testId = treeEntryMatch.group(1);
this.testName = treeEntryMatch.group(2);
this.isSuite = Boolean.parseBoolean(treeEntryMatch.group(3));
this.testCount = Integer.parseInt(treeEntryMatch.group(4));
}
}

public boolean isSpock() {
return isSpock;
}

public String getSpockIteration() {
return spockIteration;
}

public String getSpockSpec() {
return spockSpec;
}

public String getSpockFeature() {
return spockFeature;
}

public String getFullFeatureQualifier(){
return spockSpec + "/" + spockFeature;
}
}

class TestRunStarted implements EclipseTestEvent {
final int count;

TestRunStarted(int count){
this.count = count;
}

public String toString() {
return count + " " + super.toString();
}
}

class TestRunEnded implements EclipseTestEvent {
}

class TestStarted implements EclipseTestEvent {
abstract class TestLifecycleCommon implements EclipseTestEvent {

private final String testId;
private final String testName;
protected String testId;
protected String testName;

public TestStarted(String testId, String testName) {
public TestLifecycleCommon(String testId, String testName) {
this.testId = testId;
this.testName = testName;
}

public String getTestId() {
return testId;
return testId;// + " " + testName.hashCode();
}

public String getTestName() {
return testName;
}
}

class TestEnded implements EclipseTestEvent {

private final String testId;
private final String testName;

public TestEnded(String testId, String testName) {
this.testId = testId;
this.testName = testName;
public String toString() {
return testId + ":" + testName;
}
}

public String getTestId() {
return testId;
class TestStarted extends TestLifecycleCommon {

public TestStarted(String testId, String testName) {
super(testId, testName);
}
}

public String getTestName() {
return testName;
class TestEnded extends TestLifecycleCommon {
public TestEnded(String testId, String testName) {
super(testId, testName);
}
}

class TestFailed implements EclipseTestEvent {
class TestFailed extends TestLifecycleCommon {
private final int status;
private final String testId;
private final String testName;
private final String trace;
private final String expected;
private final String actual;

public TestFailed(int status, String testId, String testName, String trace, String expected, String actual) {
super(testId, testName);
this.status = status;
this.testId = testId;
this.testName = testName;
this.trace = trace;
this.expected = expected;
this.actual = actual;
Expand All @@ -66,14 +135,6 @@ public int getStatus() {
return status;
}

public String getTestId() {
return testId;
}

public String getTestName() {
return testName;
}

public String getTrace() {
return trace;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ private void runPDETestsInEclipse(final TestExecutionSpec testSpec, final TestRe
programArgs.add(optionsFile.getAbsolutePath());
}
programArgs.add("-version");
programArgs.add("4");
programArgs.add("5");
programArgs.add("-port");
programArgs.add(Integer.toString(pdeTestPort));
programArgs.add("-testLoaderClass");
programArgs.add("org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader");
programArgs.add("org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader");
programArgs.add("-loaderpluginname");
programArgs.add("org.eclipse.jdt.junit4.runtime");
programArgs.add("org.eclipse.jdt.junit5.runtime");
programArgs.add("-classNames");

List<String> testNames = new ArrayList(collectTestNames(testTask, testTaskOperationId, workerLeaseService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec;
import org.gradle.api.tasks.testing.Test;

import java.util.List;
import java.util.Set;

public class EclipseTestExecutionSpec extends JvmTestExecutionSpec {
Expand Down
Loading