From a06ac6891b70dc849c5630b60b981743584af016 Mon Sep 17 00:00:00 2001 From: Ashley <73482956+ascopes@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:40:20 +0000 Subject: [PATCH] GH-421: Fix failing integration test cases --- .../test.groovy | 2 + .../gh-135-compile-dependencies/test.groovy | 2 + .../test.groovy | 69 ++++++++++++++----- .../test.groovy | 67 +++++++++++++----- .../it/gh-359-modular-jar-plugin/test.groovy | 2 + .../it/test-dependency-resolution/test.groovy | 10 +-- 6 files changed, 114 insertions(+), 38 deletions(-) diff --git a/protobuf-maven-plugin/src/it/gh-134-multiple-artifact-versions/test.groovy b/protobuf-maven-plugin/src/it/gh-134-multiple-artifact-versions/test.groovy index ad1aef53..a4e736c9 100644 --- a/protobuf-maven-plugin/src/it/gh-134-multiple-artifact-versions/test.groovy +++ b/protobuf-maven-plugin/src/it/gh-134-multiple-artifact-versions/test.groovy @@ -26,6 +26,8 @@ Path dependencyDirectory = baseDirectory .resolve("some-project") .resolve("target") .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") .resolve("archives") assertThat(dependencyDirectory).isDirectory() diff --git a/protobuf-maven-plugin/src/it/gh-135-compile-dependencies/test.groovy b/protobuf-maven-plugin/src/it/gh-135-compile-dependencies/test.groovy index 31c5244a..36b906a4 100644 --- a/protobuf-maven-plugin/src/it/gh-135-compile-dependencies/test.groovy +++ b/protobuf-maven-plugin/src/it/gh-135-compile-dependencies/test.groovy @@ -26,6 +26,8 @@ Path dependencyDirectory = baseDirectory .resolve("some-project") .resolve("target") .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") .resolve("archives") assertThat(dependencyDirectory).isDirectory() diff --git a/protobuf-maven-plugin/src/it/gh-302-runtime-scope-direct-resolution/test.groovy b/protobuf-maven-plugin/src/it/gh-302-runtime-scope-direct-resolution/test.groovy index 9a5107f0..9ab6ca99 100644 --- a/protobuf-maven-plugin/src/it/gh-302-runtime-scope-direct-resolution/test.groovy +++ b/protobuf-maven-plugin/src/it/gh-302-runtime-scope-direct-resolution/test.groovy @@ -20,29 +20,45 @@ import java.nio.file.Path import static org.assertj.core.api.Assertions.assertThat -static Path resolve(Path path, String... bits) { - for (String bit : bits) { - path = path.resolve(bit) - } - return path -} - Path baseDirectory = basedir.toPath().toAbsolutePath() -Path runtimeDependencyTargetDir = resolve(baseDirectory,"runtime-dependency", "target") -Path projectTargetDir = resolve(baseDirectory, "project", "target") +Path runtimeDependencyTargetDir = baseDirectory + .resolve("runtime-dependency") + .resolve("target") +Path projectTargetDir = baseDirectory + .resolve("project") + .resolve("target") ///////////////////////////////////////////////////////// -// `transitive-runtime-dependency' output expectations // +// `runtime-dependency' output expectations // ///////////////////////////////////////////////////////// +Path runtimeDependenciesRuntimeClass = runtimeDependencyTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("runtime") + .resolve("Runtime.class") +Path runtimeDependenciesRuntimeProto = runtimeDependencyTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("runtime") + .resolve("runtime.proto") + assertThat(runtimeDependencyTargetDir).isDirectory() -assertThat(resolve(runtimeDependencyTargetDir,"classes", "org", "example", "runtime", "Runtime.class")) +assertThat(runtimeDependenciesRuntimeClass) .isRegularFile() -assertThat(resolve(runtimeDependencyTargetDir,"classes", "org", "example", "runtime", "runtime.proto")) +assertThat(runtimeDependenciesRuntimeProto) .isRegularFile() // Compile dependencies are included in the archives directory. -assertThat(Files.list(resolve(runtimeDependencyTargetDir, "protobuf-maven-plugin", "archives"))) +Path runtimeDependenciesArchivesDir = runtimeDependencyTargetDir + .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") + .resolve("archives") + +assertThat(Files.list(runtimeDependenciesArchivesDir)) .withFailMessage { "Expected protobuf-java-* directory to be present" } .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .hasSize(1) @@ -51,19 +67,38 @@ assertThat(Files.list(resolve(runtimeDependencyTargetDir, "protobuf-maven-plugin // `project' output expectations // /////////////////////////////////// +Path projectTargetCompilerClass = projectTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("compiler") + .resolve("Compiler.class") +Path projectTargetCompilerProto = projectTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("compiler") + .resolve("compiler.proto") + assertThat(projectTargetDir).isDirectory() -assertThat(resolve(projectTargetDir,"classes", "org", "example", "compiler", "Compiler.class")) +assertThat(projectTargetCompilerClass) .isRegularFile() -assertThat(resolve(projectTargetDir,"classes", "org", "example", "compiler", "compiler.proto")) +assertThat(projectTargetCompilerProto) .isRegularFile() // Compile dependencies are included in the archives directory. -assertThat(Files.list(resolve(projectTargetDir,"protobuf-maven-plugin", "archives"))) +Path projectTargetDirArchives = projectTargetDir + .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") + .resolve("archives") + +assertThat(Files.list(projectTargetDirArchives)) .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .isNotEmpty() // Transitive runtime dependencies are not included in the archives directory. -assertThat(Files.list(resolve(projectTargetDir,"protobuf-maven-plugin", "archives"))) +assertThat(Files.list(projectTargetDirArchives)) .withFailMessage { "Expected runtime-dependency-* directory to not be present, this means " + "direct runtime dependencies are being included erroneously!" diff --git a/protobuf-maven-plugin/src/it/gh-302-runtime-scope-transitive-resolution/test.groovy b/protobuf-maven-plugin/src/it/gh-302-runtime-scope-transitive-resolution/test.groovy index bbb6fc54..88a1b580 100644 --- a/protobuf-maven-plugin/src/it/gh-302-runtime-scope-transitive-resolution/test.groovy +++ b/protobuf-maven-plugin/src/it/gh-302-runtime-scope-transitive-resolution/test.groovy @@ -20,29 +20,45 @@ import java.nio.file.Path import static org.assertj.core.api.Assertions.assertThat -static Path resolve(Path path, String... bits) { - for (String bit : bits) { - path = path.resolve(bit) - } - return path -} - Path baseDirectory = basedir.toPath().toAbsolutePath() -Path transitiveRuntimeDependencyTargetDir = resolve(baseDirectory,"transitive-runtime-dependency", "target") -Path projectTargetDir = resolve(baseDirectory, "project", "target") +Path transitiveRuntimeDependencyTargetDir = baseDirectory + .resolve("transitive-runtime-dependency") + .resolve("target") +Path projectTargetDir = baseDirectory + .resolve("project") + .resolve("target") ///////////////////////////////////////////////////////// // `transitive-runtime-dependency' output expectations // ///////////////////////////////////////////////////////// +Path transitiveRuntimeDependenciesRuntimeClass = transitiveRuntimeDependencyTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("runtime") + .resolve("Runtime.class") +Path transitiveRuntimeDependenciesRuntimeProto = transitiveRuntimeDependencyTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("runtime") + .resolve("runtime.proto") + assertThat(transitiveRuntimeDependencyTargetDir).isDirectory() -assertThat(resolve(transitiveRuntimeDependencyTargetDir, "classes", "org", "example", "runtime", "Runtime.class")) +assertThat(transitiveRuntimeDependenciesRuntimeClass) .isRegularFile() -assertThat(resolve(transitiveRuntimeDependencyTargetDir, "classes", "org", "example", "runtime", "runtime.proto")) +assertThat(transitiveRuntimeDependenciesRuntimeProto) .isRegularFile() // Compile dependencies are included in the archives directory. -assertThat(Files.list(resolve(transitiveRuntimeDependencyTargetDir, "protobuf-maven-plugin", "archives"))) +Path transitiveRuntimeDependenciesArchivesDir = transitiveRuntimeDependencyTargetDir + .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") + .resolve("archives") + +assertThat(Files.list(transitiveRuntimeDependenciesArchivesDir)) .withFailMessage { "Expected protobuf-java-* directory to be present" } .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .hasSize(1) @@ -51,19 +67,38 @@ assertThat(Files.list(resolve(transitiveRuntimeDependencyTargetDir, "protobuf-ma // `project' output expectations // /////////////////////////////////// +Path projectTargetCompilerClass = projectTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("compiler") + .resolve("Compiler.class") +Path projectTargetCompilerProto = projectTargetDir + .resolve("classes") + .resolve("org") + .resolve("example") + .resolve("compiler") + .resolve("compiler.proto") + assertThat(projectTargetDir).isDirectory() -assertThat(resolve(projectTargetDir, "classes", "org", "example", "compiler", "Compiler.class")) +assertThat(projectTargetCompilerClass) .isRegularFile() -assertThat(resolve(projectTargetDir, "classes", "org", "example", "compiler", "compiler.proto")) +assertThat(projectTargetCompilerProto) .isRegularFile() // Compile dependencies are included in the archives directory. -assertThat(Files.list(resolve(projectTargetDir, "protobuf-maven-plugin", "archives"))) +Path projectTargetDirArchives = projectTargetDir + .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") + .resolve("archives") + +assertThat(Files.list(projectTargetDirArchives)) .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .isNotEmpty() // Transitive runtime dependencies are not included in the archives directory. -assertThat(Files.list(resolve(projectTargetDir, "protobuf-maven-plugin", "archives"))) +assertThat(Files.list(projectTargetDirArchives)) .withFailMessage { "Expected transitive-runtime-dependency-* directory to not be present, this means " + "transitive runtime dependencies are being included erroneously!" diff --git a/protobuf-maven-plugin/src/it/gh-359-modular-jar-plugin/test.groovy b/protobuf-maven-plugin/src/it/gh-359-modular-jar-plugin/test.groovy index cb1506dd..739368f6 100644 --- a/protobuf-maven-plugin/src/it/gh-359-modular-jar-plugin/test.groovy +++ b/protobuf-maven-plugin/src/it/gh-359-modular-jar-plugin/test.groovy @@ -34,6 +34,8 @@ Path expectedGeneratedFile = baseProjectDir.resolve("some-project") Path expectedScriptsDirectory = baseProjectDir.resolve("some-project") .resolve("target") .resolve("protobuf-maven-plugin") + .resolve("generate") + .resolve("default") .resolve("plugins") .resolve("jvm") diff --git a/protobuf-maven-plugin/src/it/test-dependency-resolution/test.groovy b/protobuf-maven-plugin/src/it/test-dependency-resolution/test.groovy index e2c7a2fe..9fb31867 100644 --- a/protobuf-maven-plugin/src/it/test-dependency-resolution/test.groovy +++ b/protobuf-maven-plugin/src/it/test-dependency-resolution/test.groovy @@ -41,7 +41,7 @@ assertThat(resolve(testDependencyTargetDir, "classes", "org", "example", "test", .isRegularFile() assertThat(resolve(testDependencyTargetDir, "classes", "org", "example", "test", "test.proto")) .isRegularFile() -assertThat(Files.list(resolve(testDependencyTargetDir, "protobuf-maven-plugin", "archives"))) +assertThat(Files.list(resolve(testDependencyTargetDir, "protobuf-maven-plugin", "generate", "default", "archives"))) .withFailMessage { "Expected protobuf-java-* directory to be present" } .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .hasSize(1) @@ -55,12 +55,12 @@ assertThat(resolve(testProjectTargetDir, "test-classes", "org", "example", "comp .isRegularFile() assertThat(resolve(testProjectTargetDir, "test-classes", "org", "example", "compiler", "compiler.proto")) .isRegularFile() -assertThat(Files.list(resolve(testProjectTargetDir, "protobuf-maven-plugin", "archives"))) +assertThat(Files.list(resolve(testProjectTargetDir, "protobuf-maven-plugin", "generate-test", "default", "archives"))) .withFailMessage { "Expected protobuf-java-* directory to be present" } .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .hasSize(1) // We should include test sources in the test goal execution. -assertThat(Files.list(resolve(testProjectTargetDir, "protobuf-maven-plugin", "archives"))) +assertThat(Files.list(resolve(testProjectTargetDir, "protobuf-maven-plugin", "generate-test", "default", "archives"))) .withFailMessage { "Expected test-dependency-* directory to be present" } .filteredOn { it.getFileName().toString().startsWith("test-dependency-") } .hasSize(1) @@ -74,12 +74,12 @@ assertThat(resolve(mainProjectTargetDir,"classes", "org", "example", "compiler", .isRegularFile() assertThat(resolve(mainProjectTargetDir,"classes", "org", "example", "compiler", "compiler.proto")) .isRegularFile() -assertThat(Files.list(resolve(mainProjectTargetDir, "protobuf-maven-plugin", "archives"))) +assertThat(Files.list(resolve(mainProjectTargetDir, "protobuf-maven-plugin", "generate", "default", "archives"))) .withFailMessage { "Expected protobuf-java-* directory to be present" } .filteredOn { it.getFileName().toString().startsWith("protobuf-java-") } .hasSize(1) // We should exclude test sources in the main goal execution. -assertThat(Files.list(resolve(mainProjectTargetDir, "protobuf-maven-plugin", "archives"))) +assertThat(Files.list(resolve(mainProjectTargetDir, "protobuf-maven-plugin", "generate", "default", "archives"))) .withFailMessage { "Expected test-dependency-* directory to not be present" } .filteredOn { it.getFileName().toString().startsWith("test-dependency-") } .isEmpty()