OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet / deprecated / bug-reports / bug-report / test-all.sh

150 lines · bash ref:
#!/bin/bash
# test-all.sh - Run minimal WDK test across all runtimes
#
# This script demonstrates that WDK works in Node.js and Bare v1.26.0
# but FAILS in Pear runtime (which bundles Bare v1.24.3)

set -e  # Exit on error

echo "╔══════════════════════════════════════════════════════════════╗"
echo "║                                                              ║"
echo "║  WDK + Pear Runtime Bug Reproduction                        ║"
echo "║                                                              ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""

# Check if dependencies are installed
if [ ! -d "node_modules" ]; then
  echo "Installing dependencies..."
  npm install
  echo ""
fi

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "TEST 1: Node.js Runtime"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Runtime: $(node --version)"
echo ""

if node minimal-wdk-test.js; then
  echo ""
  echo "✅ TEST 1 PASSED: Works with Node.js"
else
  echo ""
  echo "❌ TEST 1 FAILED: Node.js test failed"
  exit 1
fi

echo ""
echo ""

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "TEST 2: Bare v1.26.0+ Runtime"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Check if bare is installed
if ! command -v bare &> /dev/null; then
  echo "⚠️  Bare runtime not found. Install with:"
  echo "   npm install -g bare-runtime"
  echo ""
  echo "⏭️  Skipping Bare test"
  BARE_SKIPPED=1
else
  echo "Runtime: Bare $(bare --version 2>&1 | head -1)"
  echo ""

  if bare minimal-wdk-test.js; then
    echo ""
    echo "✅ TEST 2 PASSED: Works with Bare v1.26.0+"
  else
    echo ""
    echo "❌ TEST 2 FAILED: Bare test failed"
    echo "   (Note: Requires Bare v1.26.0+)"
    exit 1
  fi
fi

echo ""
echo ""

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "TEST 3: Pear Runtime (EXPECTED TO FAIL)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Check if pear is installed
if ! command -v pear &> /dev/null; then
  echo "⚠️  Pear runtime not found. Install with:"
  echo "   npm install -g pear"
  echo ""
  echo "⏭️  Skipping Pear test"
  PEAR_SKIPPED=1
else
  echo "Runtime: Pear $(pear --version 2>&1 | grep -i version | head -1)"
  echo ""

  # Get Bare version from Pear
  echo "Bundled Bare version:"
  pear run -d . -e "console.log('Bare', Bare.version)" 2>&1 | grep "Bare v" || echo "  (Unable to detect)"
  echo ""

  echo "Running test..."
  echo ""

  # Capture output and exit code
  set +e  # Don't exit on error for this test
  pear run -d . minimal-wdk-test.js 2>&1 | tee pear-output.log
  PEAR_EXIT_CODE=$?
  set -e

  echo ""

  if [ $PEAR_EXIT_CODE -eq 0 ]; then
    echo "✅ TEST 3 PASSED: Works with Pear (bug fixed!)"
    echo ""
    echo "🎉 The Pear runtime has been upgraded!"
    echo "   No bug report needed."
  else
    echo "❌ TEST 3 FAILED: Pear runtime issue (EXPECTED)"
    echo ""
    echo "This is the bug we're reporting."
    echo "See full error in: pear-output.log"
  fi
fi

echo ""
echo ""

echo "╔══════════════════════════════════════════════════════════════╗"
echo "║  SUMMARY                                                     ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo "✅ Node.js:  PASS"
if [ -z "$BARE_SKIPPED" ]; then
  echo "✅ Bare:     PASS (v1.26.0+)"
else
  echo "⏭️  Bare:     SKIPPED (not installed)"
fi
if [ -z "$PEAR_SKIPPED" ]; then
  if [ $PEAR_EXIT_CODE -eq 0 ]; then
    echo "✅ Pear:     PASS (bug fixed!)"
  else
    echo "❌ Pear:     FAIL (Bare v1.24.3 bundled)"
  fi
else
  echo "⏭️  Pear:     SKIPPED (not installed)"
fi
echo ""

if [ -z "$PEAR_SKIPPED" ] && [ $PEAR_EXIT_CODE -ne 0 ]; then
  echo "📋 Bug Report Data:"
  echo "   - Minimal test: minimal-wdk-test.js"
  echo "   - Error log: pear-output.log"
  echo "   - Package: @tetherto/wdk@1.0.0-beta.5"
  echo "   - Issue: Pear bundles Bare v1.24.3, needs v1.26.0+"
  echo ""
  echo "Run './generate-bug-report.sh' to create GitHub issue"
fi