Skip to content

Commit b7969a6

Browse files
committed
Merge branch 'mr/thevenoux/langkit-query-language#471' into 'master'
GNATcheck/LKQL: replace LKQL_RULES_PATH usage by LKQL_PATH Closes #471 See merge request eng/libadalang/langkit-query-language!602
2 parents 9a9f779 + 8d8b14a commit b7969a6

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

lkql_checker/src/lkql_checker.adb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ package body Lkql_Checker is
8080
-- Get the default LKQL rule options file name.
8181

8282
procedure Setup_Search_Paths;
83-
-- Initialize LKQL_RULES_PATH to include path to built-in rules.
83+
-- Initialize LKQL_PATH to include path to built-in rules.
8484
-- Assuming this executable is in $PREFIX/bin, this includes the
8585
-- $PREFIX/share/lkql and $PREFIX/share/lkql/kp paths. That way, only
8686
-- the driver needs to be aware of built-in rules, and worker can be
@@ -150,8 +150,8 @@ package body Lkql_Checker is
150150
Lib : constant String := Compose (Prefix, "lib");
151151
Lib_LAL : constant String := Compose (Lib, "libadalang");
152152
begin
153-
Add_Path ("LKQL_RULES_PATH", Lkql);
154-
Add_Path ("LKQL_RULES_PATH", Kp);
153+
Add_Path ("LKQL_PATH", Lkql);
154+
Add_Path ("LKQL_PATH", Kp);
155155

156156
Add_Path ("PATH", Lib);
157157
Add_Path ("PATH", Lib_LAL);
@@ -565,7 +565,7 @@ package body Lkql_Checker is
565565
end;
566566
end if;
567567

568-
-- Setup LKQL_RULES_PATH to point on built-in rules
568+
-- Setup LKQL_PATH to point on built-in rules
569569

570570
Setup_Search_Paths;
571571

lkql_checker/src/rules_factory.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ package body Rules_Factory is
9898
return True;
9999
end Add_Rules_Path;
100100
begin
101-
if Ada.Environment_Variables.Exists ("LKQL_RULES_PATH") then
101+
if Ada.Environment_Variables.Exists ("LKQL_PATH") then
102102
GNATCOLL.Utils.Split
103-
(Ada.Environment_Variables.Value ("LKQL_RULES_PATH"),
103+
(Ada.Environment_Variables.Value ("LKQL_PATH"),
104104
GNAT.OS_Lib.Path_Separator & "",
105105
Add_Rules_Path'Access);
106106
end if;

lkql_jit/language/src/main/java/com/adacore/lkql_jit/LKQLContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public LKQLOptions.AutoFixMode getAutoFixMode() {
354354
public String[] getRuleDirectories() {
355355
if (this.ruleDirectories == null) {
356356
final var rulesDirsList = new ArrayList<>(this.getOptions().rulesDirs());
357-
final var additionalRulesDirs = System.getenv(Constants.LKQL_RULES_PATH);
357+
final var additionalRulesDirs = System.getenv(Constants.LKQL_PATH);
358358
if (additionalRulesDirs != null) {
359359
rulesDirsList.addAll(Arrays.asList(StringUtils.splitPaths(additionalRulesDirs)));
360360
}

lkql_jit/language/src/main/java/com/adacore/lkql_jit/utils/Constants.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ public class Constants {
3737
/** MIME type for LKQL. */
3838
public static final String LKQL_MIME = "application/langkit-query-language";
3939

40-
/** Environment variable which contains paths to look LKQL scripts in. */
40+
/** Environment variable which contains paths to look LKQL scripts and rules in. */
4141
public static final String LKQL_PATH = "LKQL_PATH";
4242

43-
/** Environment variable which contains the paths to look LKQL rules in. */
44-
public static final String LKQL_RULES_PATH = "LKQL_RULES_PATH";
45-
4643
// ----- Built-in symbols -----
4744

4845
/** Symbol which contains the "this" value in selectors. */

testsuite/drivers/checker_driver.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import os
23

34
from drivers.base_driver import BaseDriver, TaggedLines
45

@@ -62,7 +63,11 @@ def run(self) -> None:
6263
else:
6364
# Use `catch_error=False` to avoid failing on non-zero status code,
6465
# as some tests actually exert erroneous behaviors.
65-
self.check_run(self.lkql_checker_exe + args, catch_error=False)
66+
self.check_run(
67+
self.lkql_checker_exe + args,
68+
catch_error=False,
69+
lkql_path=os.environ["LKQL_PATH"],
70+
)
6671

6772
# If required, run the LKQL fix command
6873
if self.test_env.get("auto_fix"):
@@ -76,6 +81,7 @@ def run(self) -> None:
7681
self.lkql_fix_exe + args + ["--auto-fix-mode", auto_fix_mode],
7782
check_flags=False,
7883
catch_error=False,
84+
lkql_path=os.environ["LKQL_PATH"],
7985
)
8086

8187
# If the auto-fix mode is "NEW_FILE" or "PATCH_FILE", then

testsuite/drivers/gnatcheck_driver.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,14 @@ def default_process_timeout(self):
238238
def run(self) -> None:
239239
gnatcheck_env = dict(os.environ)
240240

241-
# Here we don't want to pollute the LKQL_RULES_PATH and LKQL_PATH with
242-
# this repository's LKQL rules: GNATcheck will find those itself by
243-
# looking next to its executable. If we let this variable, we might end
244-
# up with duplicate definitions of rules, for example if this repository
245-
# is a copy of the original LKQL repository (which is actually what
246-
# happens in production: the checkout used for testing is separate
247-
# from that used for building).
248-
gnatcheck_env["LKQL_RULES_PATH"] = getattr(self.env, "gnatcheck_rules_path", "")
249-
gnatcheck_env["LKQL_PATH"] = ""
241+
# Here we don't want to pollute LKQL_PATH with this repository's LKQL
242+
# rules: GNATcheck will find those itself by looking next to its
243+
# executable. If we let this variable, we might end up with duplicate
244+
# definitions of rules, for example if this repository is a copy of the
245+
# original LKQL repository (which is actually what happens in
246+
# production: the checkout used for testing is separate from that used
247+
# for building).
248+
gnatcheck_env["LKQL_PATH"] = getattr(self.env, "gnatcheck_rules_path", "")
250249

251250
# Get the test provided custom GNATcheck worker
252251
custom_worker = self.test_env.get("worker", None)

testsuite/drivers/interpreter_driver.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def compute_failures(self):
8181

8282
def run(self) -> None:
8383

84-
lkql_path = [self.working_dir(d) for d in self.test_env.get("lkql_path", [])]
84+
lkql_path = os.pathsep.join(
85+
[self.working_dir(d) for d in self.test_env.get("lkql_path", [])]
86+
+ [(os.environ["LKQL_PATH"])]
87+
)
8588

8689
# If lkt_refactor flag is set, then before we run the interpreter,
8790
# we refactor the "script.lkql" file and run the interpreter on it.
@@ -107,13 +110,11 @@ def run(self) -> None:
107110
# Run test on refactored script
108111
lkt_result = self.check_run(
109112
self.build_args(refactored_file_path),
110-
lkql_path=os.pathsep.join(lkql_path),
113+
lkql_path=lkql_path,
111114
analyze_output=False,
112115
)
113116

114117
self.lkt_output = lkt_result.out
115118

116119
# Run the interpreter
117-
self.check_run(
118-
self.build_args("script.lkql"), lkql_path=os.pathsep.join(lkql_path)
119-
)
120+
self.check_run(self.build_args("script.lkql"), lkql_path=lkql_path)

testsuite/testsuite.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,10 @@ def in_repo(*args):
245245
)
246246

247247
os.environ["LKQL_PATH"] = P.pathsep.join(
248-
[in_repo("lkql_checker/share/lkql"), os.environ.get("LKQL_PATH", "")]
249-
)
250-
251-
os.environ["LKQL_RULES_PATH"] = P.pathsep.join(
252248
[
253249
in_repo("lkql_checker/share/lkql"),
254250
in_repo("lkql_checker/share/lkql/kp"),
251+
os.environ.get("LKQL_PATH", ""),
255252
]
256253
)
257254

0 commit comments

Comments
 (0)