Skip to content

Visual Studio Code, rebuilt in Rust

Rust
2.1 KB
Raw Blame
#!/bin/bash
# Runs the release build on a git repository copy of port/fixtures/workspace with
# port/fixtures/extensions/linux-smoke-tests in it (git and emmet activate, an edit saves to disk): under Xvfb on Linux
# (port/tools/linux-build port/tools/linux/smoke), in a window on macOS. APP overrides the binary; FIXTURE=webview-tests
# runs that fixture instead, as port/tools/webview-check does on macOS. CI's smoke job runs it on the dev build.
set -uo pipefail
REF=$(cd upstream && pwd -P)
# A packaged app (APP=<folder>/vsrustium) runs its own resources/app/extensions; the dev build the reference's.
if [[ -z ${APP:-} ]]; then
  APP=$CARGO_TARGET_DIR/release/vsrustium
  export VSCODE_GPUI_EXTENSIONS=${VSCODE_GPUI_EXTENSIONS:-$REF/extensions}
fi
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
if [[ $(uname) == Linux ]]; then
  trap 'kill %1; rm -rf "$dir"' EXIT
  # -displayfd picks a free display and writes its number once Xvfb accepts clients; the app exits with
  # "Failed to initialize X11 client" when it starts before that.
  # A loaded CI runner took more than 10 s to start Xvfb, leaving DISPLAY=":".
  Xvfb -displayfd 1 -screen 0 1600x1000x24 >"$dir/display" 2>"$dir/xvfb.log" &
  for _ in $(seq 600); do [ -s "$dir/display" ] && break; sleep 0.1; done
  if [[ ! -s "$dir/display" ]]; then
    cat "$dir/xvfb.log"
    echo "linux smoke: Xvfb gave no display in 60 s"
    exit 1
  fi
  export DISPLAY=:$(cat "$dir/display")
fi

cp -R port/fixtures/workspace "$dir/workspace"
git -C "$dir/workspace" init -q && git -C "$dir/workspace" add -A && git -C "$dir/workspace" -c user.name=smoke -c user.email=smoke@localhost commit -qm fixture
tests=$PWD/port/fixtures/extensions/${FIXTURE:-linux-smoke-tests}
# perl's alarm, not timeout: GitHub's macOS runners have no coreutils. A run past 300 s ends with exit 142.
perl -e 'alarm 300; exec @ARGV' "$APP" "$dir/workspace" --user-data-dir "$dir/user-data" --skip-welcome --disable-workspace-trust \
  --extensionDevelopmentPath="$tests" --extensionTestsPath="$tests/tests" >"$dir/log" 2>&1
code=$?
grep -E "^handshake done|^(ok|FAILED) " "$dir/log"
[[ $code == 0 ]] || tail -40 "$dir/log"
echo "linux smoke: exit $code"
exit $code