|
| 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