diff options
| author | David Lönnhager <david.l@mullvad.net> | 2024-05-08 14:44:22 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-05-16 16:39:03 +0200 |
| commit | 9670a6a6269b3169c6a6bec064eea02b5484786f (patch) | |
| tree | a2c023e2be1877f221786bb312cf47245b8426ed /gui/scripts | |
| parent | 816d40716b6cd329cb39d59e18ecef6e41dc19ca (diff) | |
| download | mullvadvpn-9670a6a6269b3169c6a6bec064eea02b5484786f.tar.xz mullvadvpn-9670a6a6269b3169c6a6bec064eea02b5484786f.zip | |
Use sea instead of pkg for test executable
Diffstat (limited to 'gui/scripts')
| -rwxr-xr-x | gui/scripts/build-test-executable.sh | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/gui/scripts/build-test-executable.sh b/gui/scripts/build-test-executable.sh index 273e1d4920..dd2758ebc3 100755 --- a/gui/scripts/build-test-executable.sh +++ b/gui/scripts/build-test-executable.sh @@ -8,16 +8,57 @@ cd "$SCRIPT_DIR/.." TARGET=${1:-$(rustc -vV | sed -n 's|host: ||p')} PRODUCT_VERSION=$(cargo run -q --bin mullvad-version) +ASSETS=( + "build/src/config.json" + "build/src/renderer/lib/routes.js" + "build/test/e2e/utils.js" + "build/test/e2e/shared/*.js" + "build/test/e2e/installed/*.js" + "build/test/e2e/installed/**/*.js" + "node_modules/.bin/playwright" + "node_modules/playwright" + "node_modules/playwright-core" + "node_modules/@playwright/test" +) + function build_test_executable { local pkg_target=$1 - local suffix=${2:-""} - local output="../dist/app-e2e-tests-$PRODUCT_VERSION-$TARGET$suffix" + local bin_suffix=${2:-""} + local temp_dir + temp_dir="$(mktemp -d)" + local temp_executable="$temp_dir/temp-test-executable$bin_suffix" + local output="../dist/app-e2e-tests-$PRODUCT_VERSION-$TARGET$bin_suffix" + local node_copy_path="$temp_dir/node$bin_suffix" + local node_path + node_path="$(volta which node || which node)" + + # pack assets + cp "$node_path" "$node_copy_path" + # shellcheck disable=SC2068 + tar -czf ./build/test/assets.tar.gz ${ASSETS[@]} + + cp "$node_copy_path" "$temp_executable" + node --experimental-sea-config standalone-tests.sea.json + + # Inject SEA blob + case $pkg_target in + macos-*) + codesign --remove-signature "$temp_executable" + npx postject "$temp_executable" NODE_SEA_BLOB \ + standalone-tests.sea.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \ + --macho-segment-name NODE_SEA + codesign --sign - "$temp_executable" + ;; + *) + npx postject "$temp_executable" NODE_SEA_BLOB \ + standalone-tests.sea.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 + ;; + esac + + mkdir -p "$(dirname "$output")" + mv "$temp_executable" "$output" - npm exec pkg -- \ - --config standalone-tests.pkg.json \ - --targets "$pkg_target" \ - --output "$output" \ - build/standalone-tests.js + rm -rf "$temp_dir" } case "$TARGET" in |
