From 63854e36b4952aafe5490dfc0bfc9f7ad30ffdb8 Mon Sep 17 00:00:00 2001 From: Cornelius Riemenschneider Date: Fri, 3 Nov 2023 14:15:13 +0100 Subject: [PATCH] Use the TestPaths helper to lookup files. --- .../test/com/semmle/js/extractor/test/ASTMatchingTests.java | 3 ++- .../extractor/test/com/semmle/js/extractor/test/JSXTests.java | 3 ++- .../test/com/semmle/js/extractor/test/RobustnessTests.java | 3 ++- .../extractor/test/com/semmle/js/extractor/test/TrapTests.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/ASTMatchingTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/ASTMatchingTests.java index f46c604d17e..b1a29580047 100644 --- a/javascript/extractor/test/com/semmle/js/extractor/test/ASTMatchingTests.java +++ b/javascript/extractor/test/com/semmle/js/extractor/test/ASTMatchingTests.java @@ -12,6 +12,7 @@ import com.semmle.jcorn.SyntaxError; import com.semmle.js.ast.AST2JSON; import com.semmle.js.ast.Program; import com.semmle.util.io.WholeIO; +import com.semmle.util.tests.TestPaths; import java.io.File; import java.util.Iterator; import java.util.Map.Entry; @@ -54,7 +55,7 @@ public abstract class ASTMatchingTests { } } - private static final File BABYLON_BASE = new File("parser-tests/babylon").getAbsoluteFile(); + private static final File BABYLON_BASE = TestPaths.get("parser-tests/babylon").toAbsolutePath().toFile(); protected void babylonTest(String dir) { babylonTest(dir, new Options().esnext(true)); diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/JSXTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/JSXTests.java index 65c660d05b1..b3b7a13fbf1 100644 --- a/javascript/extractor/test/com/semmle/js/extractor/test/JSXTests.java +++ b/javascript/extractor/test/com/semmle/js/extractor/test/JSXTests.java @@ -10,6 +10,7 @@ import com.semmle.js.ast.AST2JSON; import com.semmle.js.ast.Program; import com.semmle.util.files.FileUtil; import com.semmle.util.io.WholeIO; +import com.semmle.util.tests.TestPaths; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -25,7 +26,7 @@ import org.junit.runners.Parameterized.Parameters; */ @RunWith(Parameterized.class) public class JSXTests extends ASTMatchingTests { - private static final File BASE = new File("parser-tests/jcorn-jsx").getAbsoluteFile(); + private static final File BASE = TestPaths.get("parser-tests/jcorn-jsx").toAbsolutePath().toFile(); @Parameters(name = "{0}") public static Iterable tests() { diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/RobustnessTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/RobustnessTests.java index 3bf164af06f..1bc64fc8ffa 100644 --- a/javascript/extractor/test/com/semmle/js/extractor/test/RobustnessTests.java +++ b/javascript/extractor/test/com/semmle/js/extractor/test/RobustnessTests.java @@ -3,6 +3,7 @@ package com.semmle.js.extractor.test; import com.semmle.jcorn.Options; import com.semmle.jcorn.Parser; import com.semmle.util.io.WholeIO; +import com.semmle.util.tests.TestPaths; import java.io.File; import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -11,7 +12,7 @@ public class RobustnessTests { @Test public void letLookheadTest() { - File test = new File("parser-tests/robustness/letLookahead.js"); + File test = TestPaths.get("parser-tests/robustness/letLookahead.js").toFile(); String src = new WholeIO(StandardCharsets.UTF_8.name()).strictread(test); new Parser(new Options(), src, 0).parse(); } diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/TrapTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/TrapTests.java index ae3a28cbc35..5991ac6669a 100644 --- a/javascript/extractor/test/com/semmle/js/extractor/test/TrapTests.java +++ b/javascript/extractor/test/com/semmle/js/extractor/test/TrapTests.java @@ -13,6 +13,7 @@ import com.semmle.util.extraction.ExtractorOutputConfig; import com.semmle.util.io.WholeIO; import com.semmle.util.process.Env; import com.semmle.util.srcarchive.DummySourceArchive; +import com.semmle.util.tests.TestPaths; import com.semmle.util.trap.ITrapWriterFactory; import com.semmle.util.trap.TrapWriter; import com.semmle.util.trap.pathtransformers.ProjectLayoutTransformer; @@ -35,7 +36,7 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class TrapTests { - private static final File BASE = new File("tests").getAbsoluteFile(); + private static final File BASE = TestPaths.get("tests").toAbsolutePath().toFile(); @Parameters(name = "{0}:{1}") public static Iterable tests() {