This is an automated email from the ASF dual-hosted git repository.
snuyanzin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 253ed4639f [CALCITE-7261] `DiffRepository` generation xml does not
respect alphabetical order
253ed4639f is described below
commit 253ed4639fdc07dd58de3f310503df2847500973
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Sun Nov 2 15:27:55 2025 +0100
[CALCITE-7261] `DiffRepository` generation xml does not respect
alphabetical order
---
.../org/apache/calcite/test/DiffRepository.java | 8 +--
.../test/DiffRepositoryGeneratedFileTest.java | 78 ++++++++++++++++++++++
.../test/DiffRepositoryGeneratedFileTest.xml | 18 +++++
3 files changed, 100 insertions(+), 4 deletions(-)
diff --git a/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
b/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
index 735a1247f4..db60757f4b 100644
--- a/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
+++ b/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
@@ -586,7 +586,7 @@ private synchronized void update(
int i = 0;
final List<String> names = Pair.left(map);
for (String s : names) {
- if (s.compareToIgnoreCase(testCaseName) <= 0) {
+ if (s.compareTo(testCaseName) <= 0) {
++i;
}
}
@@ -598,13 +598,13 @@ private synchronized void update(
// will end up in exactly the right position, and if the list is not
sorted,
// the new item will end up in approximately the right position.
while (i < map.size()
- && names.get(i).compareToIgnoreCase(testCaseName) < 0) {
+ && names.get(i).compareTo(testCaseName) < 0) {
++i;
}
- if (i >= map.size() - 1) {
+ if (i > map.size() - 1) {
return null;
}
- while (i >= 0 && names.get(i).compareToIgnoreCase(testCaseName) > 0) {
+ while (i >= 0 && names.get(i).compareTo(testCaseName) > 0) {
--i;
}
return map.get(i + 1).right;
diff --git
a/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryGeneratedFileTest.java
b/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryGeneratedFileTest.java
new file mode 100644
index 0000000000..a14f4e1b89
--- /dev/null
+++
b/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryGeneratedFileTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.apache.calcite.test;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.endsWith;
+
+/**
+ * Tests checking generated actual XML version.
+ *
+ * <p>Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-7261">[CALCITE-7261]
+ * DiffRepository generation xml doesn't respect alphabetical order</a>.
+ */
+public class DiffRepositoryGeneratedFileTest {
+ private static final DiffRepository REPO =
+ DiffRepository.lookup(DiffRepositoryGeneratedFileTest.class);
+
+ @AfterAll
+ static void tearDown() throws IOException {
+ final String fileContent =
+ String.join("\n", Files.readAllLines(Paths.get(REPO.logFilePath())));
+ assertThat(
+ fileContent, endsWith(
+ "<Root>\n"
+ + " <TestCase name=\"testDiff\">\n"
+ + " <Resource name=\"resource\">\n"
+ + " <![CDATA[diff]]>\n"
+ + " </Resource>\n"
+ + " </TestCase>\n"
+ + " <TestCase name=\"testNull\">\n"
+ + " <Resource name=\"resource\">\n"
+ + " <![CDATA[null]]>\n"
+ + " </Resource>\n"
+ + " </TestCase>\n"
+ + " <TestCase name=\"testmulti\">\n"
+ + " <Resource name=\"resource\">\n"
+ + " <![CDATA[multi]]>\n"
+ + " </Resource>\n"
+ + " </TestCase>\n"
+ + "</Root>"));
+ }
+
+ @Test void testDiff() {
+ REPO.set("resource", "diff");
+ }
+
+ // Here method name was intentionally written in lower case to highlight
+ // discrepancy between checking logic and generated logic
+ @Test void testmulti() {
+ REPO.set("resource", "multi");
+ }
+
+ @Test void testNull() {
+ REPO.set("resource", "null");
+ }
+}
diff --git
a/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryGeneratedFileTest.xml
b/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryGeneratedFileTest.xml
new file mode 100644
index 0000000000..ef64ba1e38
--- /dev/null
+++
b/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryGeneratedFileTest.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to you under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ 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.
+ -->
+<Root></Root>