Files
zeekay d696a015aa fix(brand): one name for the script language, and a guard that keeps it
The rename runs on the way in and nothing checked it afterwards, so paths and
content drifted apart in three places, and each one broke something quietly.

The script language had three names at once.
Files on disk carried `.iql`/`.iqle`, the source matchers said `.script`, and
the bytecode matchers said `.hoge`, so the test harness globbed zero files and
the STL compiler regenerated an empty table.
It is `script` now, in one place: `.script` source, `.scriptc` bytecode,
`bin/script` to run one and `bin/scriptc` to compile one.

190 TypeScript specifiers named files that had been renamed away, which is the
whole CDP consumer graph -- the event worker, not the web boot.
`--check` only ever read Python imports; it reads both module systems now, and
repoints both.

`-hog-` became `-mascot-` in paths while content said `script`, so the code
review product's skill directories stopped matching the prefix that discovers
them and it ran with no perspectives at all.

PATH_REGEX is CONTENT_REGEX -- the same list, not a copy -- so a rule can no
longer land in one and miss the other, and the four disagreeing `hog` path
rules collapse into the one word rule content already had.

`HOGLI_*` becomes `INSIGHTSCLI_*` at every reader and writer, with no alias: an
env var read under two names is two names.
The seven casings of `hogql` and five of `hogvm` collapse into one rule per
prefix casing, which leaves the suffix alone because `QL` is SQL's and `VM` is
a virtual machine's.

`--check` now refuses every retired spelling, in content and in paths, and
draws the line the rules draw: `insights_hogfunction` is a Postgres table so it
is left alone, and a migration filename is its identity in `django_migrations`
so it is frozen rather than failed.
Third-party names we cannot rename are reported as pending, never exempted.
2026-08-08 18:38:11 -07:00

135 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
set -e
# List of test files to skip the compiledjs tests
SKIP_COMPILEDJS_FILES=("")
# Files on which we only want to run Node.js tests
ONLY_NODEJS_FILES=("sql.script")
# Navigate to the script's directory
cd "$(dirname "$0")"
# Build the project
cd typescript
pnpm run build
cd ..
# Navigate to the project root (parent of 'common/scriptvm')
cd ../..
# Function to compute the basename for a given file
get_basename() {
local file="$1"
local base="${file%.script}"
base="${base##*/}"
echo "common/scriptvm/__tests__/__snapshots__/$base"
}
# Function to check if a value is in an array
is_in_array() {
local val="$1"
shift
local arr=("$@")
for item in "${arr[@]}"; do
if [ "$item" == "$val" ]; then
return 0
fi
done
return 1
}
# Collect test files based on optional argument
if [ "$#" -eq 1 ]; then
test_file="$1"
# Adjust the test file path if it doesn't start with 'common/scriptvm/'
if [[ ! "$test_file" == common/scriptvm/* ]]; then
test_file="common/scriptvm/__tests__/$test_file"
fi
# Check if the test file exists
if [ ! -f "$test_file" ]; then
echo "Test file $test_file does not exist."
exit 1
fi
test_files=("$test_file")
# Remove previous outputs for this test file only
basename=$(get_basename "$test_file")
rm -f "$basename.stdout.nodejs" "$basename.stdout.python" "$basename.stdout.compiledjs"
else
shopt -s nullglob
test_files=(common/scriptvm/__tests__/*.script)
shopt -u nullglob
if [ ${#test_files[@]} -eq 0 ]; then
echo "No test files found in common/scriptvm/__tests__/"
exit 1
fi
# Remove all previous outputs
rm -f common/scriptvm/__tests__/__snapshots__/*.stdout.nodejs
rm -f common/scriptvm/__tests__/__snapshots__/*.stdout.python
rm -f common/scriptvm/__tests__/__snapshots__/*.stdout.compiledjs
fi
for file in "${test_files[@]}"; do
echo "Testing $file"
basename=$(get_basename "$file")
filename=$(basename "$file")
# Compile to .scriptc
./bin/scriptc "$file" "$basename.scriptc"
# Always run Node.js test
./bin/script --nodejs "$basename.scriptc" > "$basename.stdout.nodejs"
# If this file is in ONLY_NODEJS_FILES, skip python + compiledjs
if is_in_array "$filename" "${ONLY_NODEJS_FILES[@]}"; then
mv "$basename.stdout.nodejs" "$basename.stdout"
echo "Test passed (only nodejs tested)."
continue
fi
# Otherwise, run Python
./bin/script --python "$basename.scriptc" > "$basename.stdout.python"
# Check if compiledjs is skipped
if is_in_array "$filename" "${SKIP_COMPILEDJS_FILES[@]}"; then
echo "Skipping compiledjs tests for $filename"
set +e
diff "$basename.stdout.nodejs" "$basename.stdout.python"
if [ $? -eq 0 ]; then
mv "$basename.stdout.nodejs" "$basename.stdout"
rm "$basename.stdout.python"
echo "Test passed"
else
echo "Test failed: Output differs between Node.js and Python interpreters."
fi
set -e
else
# Run compiledjs
set +e
./bin/scriptc "$file" "$basename.js"
node "$basename.js" > "$basename.stdout.compiledjs" 2>&1
set -e
# Compare outputs
set +e
diff "$basename.stdout.nodejs" "$basename.stdout.compiledjs"
if [ $? -eq 0 ]; then
diff "$basename.stdout.nodejs" "$basename.stdout.python"
if [ $? -eq 0 ]; then
mv "$basename.stdout.nodejs" "$basename.stdout"
rm "$basename.stdout.python"
rm "$basename.stdout.compiledjs"
echo "Test passed"
else
echo "Test failed: Output differs between Node.js and Python interpreters."
fi
else
echo "Test failed: Output differs between Node.js interpreter and compiled JavaScript."
fi
set -e
fi
done