From 6a870601b5df491f68b81adfc9a1e63a410ebf36 Mon Sep 17 00:00:00 2001 From: zgw <13623675548@163.com> Date: Tue, 11 Aug 2026 19:44:18 +0800 Subject: [PATCH] test: support algorithm contract in linked worktrees --- .../contract/JsAlgorithmContractTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/contract/JsAlgorithmContractTest.java b/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/contract/JsAlgorithmContractTest.java index 58c26ba..abee145 100644 --- a/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/contract/JsAlgorithmContractTest.java +++ b/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/contract/JsAlgorithmContractTest.java @@ -40,7 +40,7 @@ class JsAlgorithmContractTest { assertThat(stream).as("run tools/export-js-contracts.js first").isNotNull(); JsonNode root = mapper.readTree(stream); assertThat(root.path("sourceAlgorithmVersion").asText()).isEqualTo("1.2.0"); - Path source = Path.of("..", "..", "..", "ft546-storage-scheduling-algorithm.js"); + Path source = findSourceAlgorithm(); assertThat(root.path("sourceSha256").asText()).isEqualTo(sha256(Files.readAllBytes(source))); assertThat(root.path("fixtures")).hasSize(4); for (JsonNode fixture : root.path("fixtures")) { @@ -134,4 +134,17 @@ class JsAlgorithmContractTest { private String sha256(byte[] value) throws Exception { return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(value)); } + + private Path findSourceAlgorithm() { + Path directory = Path.of("").toAbsolutePath(); + while (directory != null) { + Path candidate = directory.resolve("ft546-storage-scheduling-algorithm.js"); + if (Files.isRegularFile(candidate)) { + return candidate; + } + directory = directory.getParent(); + } + throw new IllegalStateException("Cannot find ft546-storage-scheduling-algorithm.js above " + + Path.of("").toAbsolutePath()); + } }