Skip to content

Commit f78dd94

Browse files
committed
[CALCITE-6385] LintTest fails when run in source distribution
The testContributorsFileIsSorted and testMailmapFile tests fail cause they rely on git and there is no git info available in source distribution. In fact the tests don't really need git and the paths to the .mailmap and contributor.yml files can be specified explicitly. This removes the git requirement and also makes the tests more efficient since there is no process calls and lookup involved.
1 parent 1566663 commit f78dd94

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ allprojects {
826826
passProperty("user.country", "tr")
827827
passProperty("user.timezone", "UTC")
828828
passProperty("calcite.avatica.version", props.string("calcite.avatica.version"))
829+
passProperty("gradle.rootDir", rootDir.toString())
829830
val props = System.getProperties()
830831
for (e in props.propertyNames() as `java.util`.Enumeration<String>) {
831832
if (e.startsWith("calcite.") || e.startsWith("avatica.")) {

core/src/test/java/org/apache/calcite/test/LintTest.java

+6-13
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import java.io.IOException;
3838
import java.io.PrintWriter;
3939
import java.io.StringWriter;
40+
import java.nio.file.Path;
41+
import java.nio.file.Paths;
4042
import java.util.ArrayList;
4143
import java.util.Comparator;
4244
import java.util.List;
@@ -46,10 +48,6 @@
4648
import java.util.regex.Pattern;
4749
import java.util.stream.Stream;
4850

49-
import static com.google.common.collect.Iterables.getOnlyElement;
50-
51-
import static org.apache.calcite.util.Util.filter;
52-
5351
import static org.hamcrest.CoreMatchers.is;
5452
import static org.hamcrest.MatcherAssert.assertThat;
5553
import static org.hamcrest.Matchers.empty;
@@ -64,6 +62,7 @@ class LintTest {
6462
* space. */
6563
private static final Pattern CALCITE_PATTERN =
6664
Pattern.compile("^(\\[CALCITE-[0-9]{1,4}][ ]).*");
65+
private static final Path ROOT_PATH = Paths.get(System.getProperty("gradle.rootDir"));
6766

6867
@SuppressWarnings("Convert2MethodRef") // JDK 8 requires lambdas
6968
private Puffin.Program<GlobalState> makeProgram() {
@@ -397,10 +396,7 @@ private static void checkMessage(String subject, String body,
397396
/** Ensures that the {@code contributors.yml} file is sorted by name. */
398397
@Test void testContributorsFileIsSorted() throws IOException {
399398
final ObjectMapper mapper = new YAMLMapper();
400-
final List<File> files = TestUnsafe.getTextFiles();
401-
final File contributorsFile =
402-
getOnlyElement(
403-
filter(files, f -> f.getName().equals("contributors.yml")));
399+
final File contributorsFile = ROOT_PATH.resolve("site/_data/contributors.yml").toFile();
404400
JavaType listType =
405401
mapper.getTypeFactory()
406402
.constructCollectionType(List.class, Contributor.class);
@@ -416,12 +412,9 @@ private static void checkMessage(String subject, String body,
416412

417413
/** Ensures that the {@code .mailmap} file is sorted. */
418414
@Test void testMailmapFile() {
419-
final List<File> files = TestUnsafe.getTextFiles();
420-
final File contributorsFile =
421-
getOnlyElement(
422-
filter(files, f -> f.getName().equals(".mailmap")));
415+
final File mailmapFile = ROOT_PATH.resolve(".mailmap").toFile();
423416
final List<String> lines = new ArrayList<>();
424-
forEachLineIn(contributorsFile, line -> {
417+
forEachLineIn(mailmapFile, line -> {
425418
if (!line.startsWith("#")) {
426419
lines.add(line);
427420
}

0 commit comments

Comments
 (0)