Skip to content

Commit 3716009

Browse files
committed
Improve settings test to check a wider scope of consistency
1 parent 2c216d4 commit 3716009

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

testsuite/drivers/shell.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def run(self) -> None:
1111

1212
# This takes care of failing the test in case the return code is
1313
# non-zero
14-
check_call(
14+
p = check_call(
1515
self,
1616
[self.working_dir("test.sh"), self.env.repo_base],
1717
parse_shebang=True,
@@ -24,3 +24,7 @@ def run(self) -> None:
2424
ignore_environ=False,
2525
timeout=15, # seconds
2626
)
27+
28+
assert self.env.main_options
29+
if self.env.main_options.verbose:
30+
print(p.out)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
import sys
3+
4+
schema = json.load(sys.stdin)
5+
properties: dict[str, dict] = schema["properties"]
6+
settings: list[str] = []
7+
8+
9+
def process_property(name: str, value: dict):
10+
"""We want to print nested properties as <name1>.<name2>.<leafname>. This function
11+
recurses into nested properties to achieve that.
12+
"""
13+
if value.get("type", None) == "object" and "properties" in value:
14+
for k, v in value["properties"].items():
15+
process_property(f"{name}.{k}", v)
16+
else:
17+
settings.append(name)
18+
19+
20+
for k, v in properties.items():
21+
process_property(k, v)
22+
23+
settings = sorted(settings)
24+
print("\n".join(settings))

testsuite/settings-doc/test.sh

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,49 @@
11
#!/bin/sh
2-
python3 get-extension-settings.py <$1/integration/vscode/ada/package.json | grep ^ada. | sort >pkg.txt
3-
grep '^### ' $1/doc/settings.md | sed -e 's/..../ada./' | sort >doc.txt
2+
3+
# Fail at the first error
4+
set -e
5+
6+
# Collect settings from package.json and remove 'ada.' prefix
7+
python3 get-extension-settings.py <"$1/integration/vscode/ada/package.json" | grep ^ada. | sed -e 's/ada\.//' | sort >pkg.txt
8+
9+
# Collect settings from documentation
10+
grep '^### ' "$1/doc/settings.md" | sed -e 's/....//' | sort >doc.txt
11+
12+
# Collect settings from the JSON schema for .als.json files
13+
python3 get-schema-properties.py <"$1/integration/vscode/ada/schemas/als-settings-schema.json" >schema.txt
14+
15+
# Collect settings read in the ALS implementation
16+
grep 'if Name = "[^"]\+"' "$1/source/ada/lsp-ada_configurations.adb" | sed -e 's/.*"\([^"]\+\)"/\1/' >impl.txt
17+
# Remove the following settings from the implementation list because they are
18+
# either hidden, or nested
19+
exclude="logThreshold onTypeFormatting indentOnly"
20+
for exc in $exclude; do
21+
echo "$(grep -v "$exc" <impl.txt)" >impl.txt
22+
done
23+
# Add the following properties because they are nested
24+
add="onTypeFormatting.indentOnly"
25+
for a in $add; do
26+
echo "$a" >>impl.txt
27+
done
28+
# Sort the list
29+
echo "$(sort <impl.txt)" >impl.txt
30+
31+
# Check that all VS Code settings are documented
432
diff -u pkg.txt doc.txt
33+
34+
# The ada.trace.server setting exists only in VS Code and not in .als.json
35+
# files. So remove it before the comparison.
36+
#
37+
# We need to use a subshell because it's not allowed to read and write the same
38+
# file in one pipeline
39+
# echo "$(grep -v trace.server <doc.txt)" >doc.txt
40+
echo "$(grep -v trace.server <doc.txt)" >doc.txt
41+
42+
# Check that all implemented settings are documented
43+
diff -u impl.txt doc.txt
44+
45+
# Check that all implemented settings are defined in the JSON Schema
46+
diff -u impl.txt schema.txt
47+
48+
# Check that all settings defined in the JSON Schema are documented
49+
diff -u schema.txt doc.txt

0 commit comments

Comments
 (0)