Skip to content

Commit 1511907

Browse files
committed
fix(valgrind): compile TypeScript before running valgrind with the test script
1 parent 27a47e8 commit 1511907

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/valgrind.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@ PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
1313
# Create a temporary file for valgrind output
1414
VALGRIND_LOG=$(mktemp)
1515

16-
# Run valgrind with our test script
16+
# Create a temporary directory for compiled JS
17+
TEMP_DIR=$(mktemp -d)
18+
COMPILED_JS="$TEMP_DIR/valgrind-test.js"
19+
20+
# Compile TypeScript to JavaScript
21+
echo "Compiling TypeScript..."
22+
npx tsc "$SCRIPT_DIR/valgrind-test.ts" --outDir "$TEMP_DIR" --module commonjs --target es2020 --skipLibCheck || {
23+
echo "Failed to compile TypeScript"
24+
rm -rf "$TEMP_DIR"
25+
rm -f "$VALGRIND_LOG"
26+
exit 1
27+
}
28+
29+
# Run valgrind with the compiled JavaScript
1730
valgrind \
1831
--leak-check=full \
1932
--show-leak-kinds=definite,indirect \
2033
--track-origins=yes \
2134
--suppressions="$PROJECT_ROOT/.valgrind.supp" \
2235
--log-file="$VALGRIND_LOG" \
23-
node "$SCRIPT_DIR/valgrind-test.mjs"
36+
node "$COMPILED_JS"
2437

2538
# Check the exit code
2639
EXIT_CODE=$?
@@ -41,6 +54,7 @@ fi
4154

4255
# Clean up
4356
rm -f "$VALGRIND_LOG"
57+
rm -rf "$TEMP_DIR"
4458

4559
# Return the worst exit code
4660
if [ $EXIT_CODE -ne 0 ] || [ $LEAK_EXIT_CODE -ne 0 ]; then

0 commit comments

Comments
 (0)