Skip to content

Commit 28cb9ad

Browse files
committed
Update tests to verify that there is exactly one entry for each test case & add jetbrains to test cases
1 parent b60d0bf commit 28cb9ad

File tree

2 files changed

+65
-13
lines changed

2 files changed

+65
-13
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
shellcheck -V
2626
shellcheck ./bin/functions
2727
shellcheck ./update_data.bash
28+
shellcheck ./run_tests.bash
2829
- name: Install asdf
2930
uses: actions/checkout@v2
3031
with:
@@ -40,19 +41,8 @@ jobs:
4041
env:
4142
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4243
run: |
43-
./update_data.bash
44-
grep -q adoptopenjdk-openj9-11 data/jdk-linux-x86_64.tsv
45-
echo "Found adoptopenjdk-openj9-11"
46-
grep -q adoptopenjdk-openj9-large_heap-11 data/jdk-macosx-x86_64.tsv
47-
echo "Found adoptopenjdk-openj9-large_heap-11"
48-
grep -q zulu-musl-11 data/jdk-linux-x86_64.tsv
49-
echo "Found zulu-musl-11 "
50-
grep -q liberica-javafx-16 data/jdk-linux-arm32-vfp-hflt.tsv
51-
echo "Found liberica-javafx-16"
52-
grep -q liberica-lite-11 data/jdk-macosx-x86_64.tsv
53-
echo "Found liberica-lite-11"
54-
grep "graalvm-21" data/jdk-linux-aarch64.tsv | grep -q -v "graalvm-graalvm-21"
55-
echo "Found graalvm-21"
44+
./update_data.bash
45+
./run_tests.bash
5646
- name: macOS Check java_home integration
5747
env:
5848
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run_tests.bash

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -Euo pipefail
4+
5+
check_file_uniqueness() {
6+
local file="$1"
7+
if [ ! -f "${file}" ]; then
8+
echo "WARNING: File '${file}' not found, skipping uniqueness check."
9+
return
10+
fi
11+
echo "Checking for duplicate lines in '${file}'..."
12+
13+
local total_lines
14+
total_lines=$(wc -l < "${file}")
15+
local unique_lines
16+
unique_lines=$(sort -u "${file}" | wc -l)
17+
18+
if [ "${total_lines}" -ne "${unique_lines}" ]; then
19+
echo "ERROR: Found duplicate lines in '${file}'."
20+
echo "The following lines are duplicated:"
21+
sort "${file}" | uniq -d
22+
exit 1
23+
fi
24+
echo "OK: All ${total_lines} lines in '${file}' are unique."
25+
}
26+
27+
check_entry_present() {
28+
local entry="$1"
29+
local file="$2"
30+
echo "Checking for presence of entry starting with '${entry}' in '${file}'..."
31+
32+
# Use `grep -q` for a quiet check. `^` anchors the search to the start of the line.
33+
if grep -q "^${entry}" "${file}"; then
34+
echo "OK: Entry '${entry}' found."
35+
else
36+
echo "ERROR: Entry '${entry}' not found at the start of any line in '${file}'."
37+
exit 1
38+
fi
39+
}
40+
41+
echo "--- Verifying uniqueness of all lines in data/*.tsv files ---"
42+
for file in data/*.tsv; do
43+
check_file_uniqueness "${file}"
44+
done
45+
echo "--- All .tsv files contain unique lines. ---"
46+
echo ""
47+
48+
49+
echo "--- Checking for presence of required entries ---"
50+
check_entry_present "adoptopenjdk-openj9-11" "data/jdk-linux-x86_64.tsv"
51+
check_entry_present "adoptopenjdk-openj9-large_heap-11" "data/jdk-macosx-x86_64.tsv"
52+
check_entry_present "zulu-musl-11" "data/jdk-linux-x86_64.tsv"
53+
check_entry_present "liberica-javafx-16" "data/jdk-linux-arm32-vfp-hflt.tsv"
54+
check_entry_present "liberica-lite-11" "data/jdk-macosx-x86_64.tsv"
55+
check_entry_present "graalvm-21" "data/jdk-linux-aarch64.tsv"
56+
check_entry_present "jetbrains-21" "data/jdk-linux-x86_64.tsv"
57+
check_entry_present "jetbrains-jre-21" "data/jdk-linux-x86_64.tsv"
58+
check_entry_present "adoptopenjdk-21" "data/jdk-linux-x86_64.tsv"
59+
echo "--- All required entries are present. ---"
60+
echo ""
61+
62+
echo "All checks passed successfully."

0 commit comments

Comments
 (0)