From 5612f46bdc92e62d67a639fe4b3b9e1b18f7be4a Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 13 Aug 2026 23:43:42 +0200 Subject: [PATCH] Revert "Skip the JavaScript RPC tests when their npm package is unavailable" This reverts commit e2e55fef56ec6373bd678472463691e0f5ad5a12. --- build.gradle.kts | 15 +------ .../AllBranchesIdenticalTest.java | 1 - .../AnnotateNullableMethodsTest.java | 1 - .../CollapsibleIfStatementsTest.java | 1 - .../staticanalysis/DefaultComesLastTest.java | 1 - .../MergeIdenticalBranchesTest.java | 1 - .../RemoveDuplicateConditionsTest.java | 1 - .../RemoveSelfAssignmentTest.java | 1 - ...RemoveUnconditionalValueOverwriteTest.java | 1 - .../RemoveUnusedLocalVariablesTest.java | 1 - .../staticanalysis/RequiresJavaScriptRpc.java | 40 ------------------- ...implifyRedundantLogicalExpressionTest.java | 1 - 12 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 src/test/java/org/openrewrite/staticanalysis/RequiresJavaScriptRpc.java diff --git a/build.gradle.kts b/build.gradle.kts index 68e9117f3..75c319e6a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,6 @@ @file:Suppress("UnstableApiUsage") import java.io.InputStream -import org.gradle.process.CommandLineArgumentProvider import org.gradle.process.ExecOperations import org.gradle.kotlin.dsl.support.serviceOf @@ -58,16 +57,11 @@ dependencies { // into the same `~/.npm/_npx` directory, and the resulting overlap leaves the package half-written, so // the tests fail with "RPC process shut down early". Installing once up front keeps every spawn a // cache hit. -// -// The marker is present once that install succeeded and the tests can spawn the package, and absent -// when it did not happen, whether for a missing npx or a version npm does not have. -val javaScriptRpcMarker = layout.buildDirectory.file("tmp/warmJavaScriptRpcCache/version.txt") - val warmJavaScriptRpcCache by tasks.registering { description = "Installs the npm package that the JavaScript RPC tests spawn, so they never race on a cold npx cache." val rewriteJavaScriptJars = configurations.named("testRuntimeClasspath") .map { classpath -> classpath.filter { it.name.startsWith("rewrite-javascript-") } } - val marker = javaScriptRpcMarker + val marker = layout.buildDirectory.file("tmp/warmJavaScriptRpcCache/version.txt") val npx = if (System.getProperty("os.name").lowercase().contains("windows")) "npx.cmd" else "npx" val execOperations = serviceOf() @@ -115,13 +109,6 @@ val warmJavaScriptRpcCache by tasks.registering { tasks.withType { jvmArgs("-Xmx1g", "-Xms512m") dependsOn(warmJavaScriptRpcCache) - // A published rewrite-javascript snapshot pins an exact @openrewrite/rewrite version, and the npm - // release of that version can lag the Maven one, leaving nothing for the RPC process to run. Tests - // annotated with @RequiresJavaScriptRpc skip rather than fail the build over that gap upstream. - val marker = javaScriptRpcMarker - jvmArgumentProviders.add(CommandLineArgumentProvider { - listOf("-DjavaScriptRpcAvailable=${marker.get().asFile.isFile}") - }) } tasks.withType { diff --git a/src/test/java/org/openrewrite/staticanalysis/AllBranchesIdenticalTest.java b/src/test/java/org/openrewrite/staticanalysis/AllBranchesIdenticalTest.java index 9499ab97a..add79971c 100644 --- a/src/test/java/org/openrewrite/staticanalysis/AllBranchesIdenticalTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/AllBranchesIdenticalTest.java @@ -248,7 +248,6 @@ void test(boolean a) { } @Test - @RequiresJavaScriptRpc void collapseIdenticalBranchesTypeScript() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/AnnotateNullableMethodsTest.java b/src/test/java/org/openrewrite/staticanalysis/AnnotateNullableMethodsTest.java index 865a348a4..c3e436c7a 100644 --- a/src/test/java/org/openrewrite/staticanalysis/AnnotateNullableMethodsTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/AnnotateNullableMethodsTest.java @@ -666,7 +666,6 @@ public class Test { } @Test - @RequiresJavaScriptRpc void typescriptCode() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/CollapsibleIfStatementsTest.java b/src/test/java/org/openrewrite/staticanalysis/CollapsibleIfStatementsTest.java index a795c0d8a..772b87329 100644 --- a/src/test/java/org/openrewrite/staticanalysis/CollapsibleIfStatementsTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/CollapsibleIfStatementsTest.java @@ -297,7 +297,6 @@ void test(boolean a, boolean b) { } @Test - @RequiresJavaScriptRpc void mergeNestedIfsTypeScript() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/DefaultComesLastTest.java b/src/test/java/org/openrewrite/staticanalysis/DefaultComesLastTest.java index 3df9f8213..e546d4422 100644 --- a/src/test/java/org/openrewrite/staticanalysis/DefaultComesLastTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/DefaultComesLastTest.java @@ -780,7 +780,6 @@ void test (int state) { } @Test - @RequiresJavaScriptRpc void doNotChangeNonJavaLanguages() { rewriteRun( typescript( diff --git a/src/test/java/org/openrewrite/staticanalysis/MergeIdenticalBranchesTest.java b/src/test/java/org/openrewrite/staticanalysis/MergeIdenticalBranchesTest.java index bcbe14917..94d99fac0 100644 --- a/src/test/java/org/openrewrite/staticanalysis/MergeIdenticalBranchesTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/MergeIdenticalBranchesTest.java @@ -269,7 +269,6 @@ void test(boolean a, boolean b) { } @Test - @RequiresJavaScriptRpc void mergeIdenticalBranchesTypeScript() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/RemoveDuplicateConditionsTest.java b/src/test/java/org/openrewrite/staticanalysis/RemoveDuplicateConditionsTest.java index 135b65ca8..a15afd044 100644 --- a/src/test/java/org/openrewrite/staticanalysis/RemoveDuplicateConditionsTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/RemoveDuplicateConditionsTest.java @@ -235,7 +235,6 @@ void test(int x) { } @Test - @RequiresJavaScriptRpc void removeDuplicateElseIfTypeScript() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/RemoveSelfAssignmentTest.java b/src/test/java/org/openrewrite/staticanalysis/RemoveSelfAssignmentTest.java index b9c0ff127..392d2be55 100644 --- a/src/test/java/org/openrewrite/staticanalysis/RemoveSelfAssignmentTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/RemoveSelfAssignmentTest.java @@ -246,7 +246,6 @@ public J.Identifier visitIdentifier(J.Identifier identifier, Integer p) { } @Test - @RequiresJavaScriptRpc void removeSelfAssignmentTypeScript() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/RemoveUnconditionalValueOverwriteTest.java b/src/test/java/org/openrewrite/staticanalysis/RemoveUnconditionalValueOverwriteTest.java index 22767228e..53031a145 100644 --- a/src/test/java/org/openrewrite/staticanalysis/RemoveUnconditionalValueOverwriteTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/RemoveUnconditionalValueOverwriteTest.java @@ -240,7 +240,6 @@ void test() { } @Test - @RequiresJavaScriptRpc void removeOverwrittenMapSetTypeScript() { rewriteRun( //language=typescript diff --git a/src/test/java/org/openrewrite/staticanalysis/RemoveUnusedLocalVariablesTest.java b/src/test/java/org/openrewrite/staticanalysis/RemoveUnusedLocalVariablesTest.java index 78833550d..fccbbd330 100644 --- a/src/test/java/org/openrewrite/staticanalysis/RemoveUnusedLocalVariablesTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/RemoveUnusedLocalVariablesTest.java @@ -1373,7 +1373,6 @@ fun initializerRemoved() : String { } @Nested - @RequiresJavaScriptRpc class Typescript { @Test void noChange() { diff --git a/src/test/java/org/openrewrite/staticanalysis/RequiresJavaScriptRpc.java b/src/test/java/org/openrewrite/staticanalysis/RequiresJavaScriptRpc.java deleted file mode 100644 index c83c52621..000000000 --- a/src/test/java/org/openrewrite/staticanalysis/RequiresJavaScriptRpc.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2026 the original author or authors. - *

- * Licensed under the Moderne Source Available License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * https://docs.moderne.io/licensing/moderne-source-available-license - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openrewrite.staticanalysis; - -import org.junit.jupiter.api.condition.DisabledIfSystemProperty; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks a test that parses JavaScript or TypeScript, which spawns an out-of-process RPC server from the - * {@code @openrewrite/rewrite} npm package, pinned to the exact version of the resolved - * {@code rewrite-javascript} jar. - *

- * The {@code warmJavaScriptRpcCache} build task installs that package up front and sets - * {@code javaScriptRpcAvailable} to whether it succeeded. It does not when npx is absent, or while a - * published {@code rewrite-javascript} snapshot is still waiting on its matching npm release; the RPC - * process then has nothing to run, so these tests skip instead of failing over a gap upstream. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) -@DisabledIfSystemProperty(named = "javaScriptRpcAvailable", matches = "false", - disabledReason = "The @openrewrite/rewrite npm package matching the resolved rewrite-javascript version is not installed") -public @interface RequiresJavaScriptRpc { -} diff --git a/src/test/java/org/openrewrite/staticanalysis/SimplifyRedundantLogicalExpressionTest.java b/src/test/java/org/openrewrite/staticanalysis/SimplifyRedundantLogicalExpressionTest.java index 3922fb1d0..121b75bb6 100644 --- a/src/test/java/org/openrewrite/staticanalysis/SimplifyRedundantLogicalExpressionTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/SimplifyRedundantLogicalExpressionTest.java @@ -300,7 +300,6 @@ boolean test(boolean a) { } @Test - @RequiresJavaScriptRpc void simplifyLogicalAndTypeScript() { rewriteRun( //language=typescript