run-tests.sh raw

   1  #!/bin/bash
   2  
   3  # Run wasmdb tests using Node.js with fake-indexeddb
   4  # This script builds the test binary and runs it in Node.js
   5  
   6  set -e
   7  
   8  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
   9  TESTDATA_DIR="$SCRIPT_DIR/testdata"
  10  WASM_FILE="$TESTDATA_DIR/wasmdb_test.wasm"
  11  
  12  # Ensure Node.js dependencies are installed
  13  if [ ! -d "$TESTDATA_DIR/node_modules" ]; then
  14      echo "Installing Node.js dependencies..."
  15      cd "$TESTDATA_DIR"
  16      npm install
  17      cd - > /dev/null
  18  fi
  19  
  20  # Build the test binary
  21  echo "Building WASM test binary..."
  22  GOOS=js GOARCH=wasm CGO_ENABLED=0 go test -c -o "$WASM_FILE" "$SCRIPT_DIR"
  23  
  24  # Run the tests
  25  echo "Running tests in Node.js..."
  26  node "$TESTDATA_DIR/run_wasm_tests.mjs" "$WASM_FILE" "$@"
  27