scripts: add run-wasm-tests.ps1 to configure LLVM toolchain and run wasm tests
This commit is contained in:
parent
d4fe243e32
commit
fb15aad77e
58
scripts/run-wasm-tests.ps1
Normal file
58
scripts/run-wasm-tests.ps1
Normal file
@ -0,0 +1,58 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Set-WasmToolchainEnv {
|
||||
param()
|
||||
$clang = $env:CC
|
||||
if (-not $clang -or -not (Test-Path $clang)) {
|
||||
$defaultClang = "C:\\Program Files\\LLVM\\bin\\clang.exe"
|
||||
if (Test-Path $defaultClang) {
|
||||
$clang = $defaultClang
|
||||
} else {
|
||||
$cmd = Get-Command clang.exe -ErrorAction SilentlyContinue
|
||||
if ($cmd) { $clang = $cmd.Path }
|
||||
}
|
||||
}
|
||||
if (-not $clang) { throw "Clang introuvable. Installez LLVM/Clang et relancez." }
|
||||
|
||||
$env:CC = $clang
|
||||
$llvmBin = Split-Path $clang -Parent
|
||||
$env:AR = Join-Path $llvmBin "llvm-ar.exe"
|
||||
$env:NM = Join-Path $llvmBin "llvm-nm.exe"
|
||||
|
||||
$env:TARGET_CC = $env:CC
|
||||
$env:CC_wasm32_unknown_unknown = $env:CC
|
||||
$env:AR_wasm32_unknown_unknown = $env:AR
|
||||
$env:NM_wasm32_unknown_unknown = $env:NM
|
||||
$env:CC_wasm32-unknown-unknown = $env:CC
|
||||
$env:AR_wasm32-unknown-unknown = $env:AR
|
||||
$env:NM_wasm32-unknown-unknown = $env:NM
|
||||
}
|
||||
|
||||
function Invoke-WasmPackTests {
|
||||
param(
|
||||
[switch]$Chrome,
|
||||
[switch]$Firefox,
|
||||
[switch]$Node
|
||||
)
|
||||
if ($Chrome) { wasm-pack test --headless --chrome }
|
||||
if ($Firefox) { wasm-pack test --headless --firefox }
|
||||
if ($Node) { wasm-pack test --node }
|
||||
}
|
||||
|
||||
$scriptsDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$repoRoot = Split-Path -Parent $scriptsDir
|
||||
Push-Location $repoRoot
|
||||
try {
|
||||
Set-WasmToolchainEnv
|
||||
cargo clean --target wasm32-unknown-unknown | Out-Null
|
||||
try {
|
||||
Invoke-WasmPackTests -Chrome -Firefox
|
||||
} catch {
|
||||
Write-Warning "Tests headless navigateur échoués, tentative avec Node."
|
||||
Invoke-WasmPackTests -Node
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user