Skip to content

Commit b91a3ec

Browse files
elrrrrrrrclaude
andcommitted
test(e2e): add npm pack + install -g verification
Simulates the setup-utoo / end-user flow: 1. Pack utoo binary into an npm tarball 2. npm install -g the tarball to a temp prefix 3. Verify the installed binary runs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ae1c297 commit b91a3ec

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

e2e/utoo-pm.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,54 @@ finally {
224224
Remove-Item -Recurse -Force $optDepsDir -ErrorAction SilentlyContinue
225225
}
226226

227+
# Case: Verify npm pack + npm install -g works (simulates setup-utoo flow)
228+
Write-Yellow "Case: npm pack and install -g utoo"
229+
$packDir = Join-Path $env:TEMP "utoo-e2e-pack-$(Get-Random)"
230+
$installPrefix = Join-Path $env:TEMP "utoo-e2e-prefix-$(Get-Random)"
231+
try {
232+
New-Item -ItemType Directory -Path "$packDir\pkg\bin" -Force | Out-Null
233+
New-Item -ItemType Directory -Path $installPrefix -Force | Out-Null
234+
235+
# Copy the actual built binary
236+
$utooBin = (Get-Command utoo).Source
237+
Copy-Item $utooBin "$packDir\pkg\bin\utoo.exe"
238+
239+
# Create package.json
240+
@{
241+
name = "utoo"
242+
version = "0.0.0-e2e-test"
243+
bin = @{ utoo = "bin/utoo"; ut = "bin/utoo" }
244+
scripts = @{ postinstall = "echo postinstall-ok" }
245+
} | ConvertTo-Json | Set-Content "$packDir\pkg\package.json"
246+
247+
# Pack
248+
Push-Location "$packDir\pkg"
249+
npm pack 2>&1
250+
$tarball = Get-ChildItem "utoo-*.tgz" | Select-Object -First 1
251+
Write-Host "Packed: $($tarball.Name)"
252+
253+
# Install globally to temp prefix
254+
npm install -g $tarball.FullName "--prefix=$installPrefix" 2>&1
255+
Write-Host "Installed to: $installPrefix"
256+
257+
# Verify the binary works
258+
$installedUtoo = Join-Path $installPrefix "node_modules\utoo\bin\utoo.exe"
259+
if (-not (Test-Path $installedUtoo)) {
260+
$installedUtoo = Join-Path $installPrefix "utoo.exe"
261+
}
262+
if (-not (Test-Path $installedUtoo)) {
263+
throw "utoo binary not found after npm install -g"
264+
}
265+
266+
& $installedUtoo --version
267+
if ($LASTEXITCODE -ne 0) { throw "utoo --version failed" }
268+
269+
Write-Green "PASS: npm pack + install -g works correctly"
270+
}
271+
finally {
272+
Pop-Location
273+
Remove-Item -Recurse -Force $packDir -ErrorAction SilentlyContinue
274+
Remove-Item -Recurse -Force $installPrefix -ErrorAction SilentlyContinue
275+
}
276+
227277
Write-Green "All e2e tests passed successfully!"

e2e/utoo-pm.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,58 @@ echo -e "${GREEN}PASS: optional dependencies with platform bindings work correct
392392
popd
393393
rm -rf "$OPTDEPS_DIR"
394394

395+
# Case: Verify npm pack + npm install -g works (simulates setup-utoo flow)
396+
echo -e "${YELLOW}Case: npm pack and install -g utoo${NC}"
397+
PACK_DIR=$(mktemp -d)
398+
INSTALL_PREFIX=$(mktemp -d)
399+
REPO_ROOT=$(cd "$(dirname "$0")/.."; pwd)
400+
401+
pushd "$PACK_DIR"
402+
403+
# Build a utoo npm package using the vendor templates
404+
mkdir -p pkg/bin
405+
# Use the actual built binary from the e2e environment
406+
UTOO_BIN=$(which utoo)
407+
cp "$UTOO_BIN" pkg/bin/utoo
408+
chmod +x pkg/bin/utoo
409+
410+
# Create package.json
411+
cat > pkg/package.json << 'PKGJSON'
412+
{
413+
"name": "utoo",
414+
"version": "0.0.0-e2e-test",
415+
"bin": { "utoo": "bin/utoo", "ut": "bin/utoo" },
416+
"scripts": { "postinstall": "echo postinstall-ok" }
417+
}
418+
PKGJSON
419+
420+
# Pack it
421+
cd pkg
422+
npm pack 2>&1
423+
TARBALL=$(ls utoo-*.tgz)
424+
echo "Packed: $TARBALL"
425+
426+
# Install globally to a temp prefix
427+
npm install -g "$TARBALL" --prefix="$INSTALL_PREFIX" 2>&1
428+
echo "Installed to: $INSTALL_PREFIX"
429+
430+
# Verify the binary works
431+
INSTALLED_UTOO="$INSTALL_PREFIX/bin/utoo"
432+
if [ ! -f "$INSTALLED_UTOO" ]; then
433+
# Try lib path on some systems
434+
INSTALLED_UTOO="$INSTALL_PREFIX/lib/node_modules/utoo/bin/utoo"
435+
fi
436+
437+
if [ ! -f "$INSTALLED_UTOO" ]; then
438+
echo -e "${RED}FAIL: utoo binary not found after npm install -g${NC}"
439+
ls -R "$INSTALL_PREFIX" 2>/dev/null | head -20
440+
exit 1
441+
fi
442+
443+
"$INSTALLED_UTOO" --version
444+
echo -e "${GREEN}PASS: npm pack + install -g works correctly${NC}"
445+
446+
popd
447+
rm -rf "$PACK_DIR" "$INSTALL_PREFIX"
448+
395449
echo -e "${GREEN}All e2e tests passed successfully!${NC}"

0 commit comments

Comments
 (0)