Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

2.0 KB
Raw Blame
#!/bin/sh
# Installs RustCord from the .dmg as someone would and starts it twice: signed
# out (Discord's login page in the window) and in demo mode. A screenshot and
# the log of each go to dist/smoke. Fails if RustCord quits or panics.
# Run on a Mac from the repository root, after package.sh.
set -eu

dmg=$(ls dist/RustCord-*-macos-universal.dmg | head -n 1)
out=dist/smoke
mount=$(mktemp -d)
mkdir -p "$out"

plutil -lint packaging/macos/Info.plist
hdiutil attach "$dmg" -nobrowse -readonly -mountpoint "$mount" >/dev/null
rm -rf /Applications/RustCord.app
cp -R "$mount/RustCord.app" /Applications/
hdiutil detach "$mount" >/dev/null
codesign --verify --strict --verbose=1 /Applications/RustCord.app
echo "architectures: $(lipo -archs /Applications/RustCord.app/Contents/MacOS/rustcord)"

system_profiler SPDisplaysDataType | grep -E "Chipset Model|Metal|Resolution" || true

# Processor time process $1 has used, in seconds (ps prints [h:]m:ss.cc).
cpu_seconds() {
    ps -o time= -p "$1" | awk -F: '{ s = 0; for (i = 1; i <= NF; i++) s = s * 60 + $i; print s }'
}

# start <name> [flag]: run RustCord for 30 seconds (its OpenGL renderer goes to
# the log), measure the last 10, then screenshot and stop it.
start() {
    RUST_LOG="info,rustcord=debug,egui_glow::painter=debug" /Applications/RustCord.app/Contents/MacOS/rustcord ${2:-} >"$out/$1.log" 2>&1 &
    pid=$!
    sleep 20
    before=$(cpu_seconds "$pid")
    sleep 10
    after=$(cpu_seconds "$pid")
    screencapture -x "$out/$1.png" || echo "no screenshot for $1"
    if ! kill -0 "$pid" 2>/dev/null || grep -q "panicked" "$out/$1.log"; then
        echo "RustCord ($1) quit or panicked:"
        tail -n 60 "$out/$1.log"
        return 1
    fi
    cpu=$(echo "$before $after" | awk '{ printf "%.1f", ($2 - $1) * 10 }')
    ps -o rss= -p "$pid" | awk -v name="$1" -v cpu="$cpu" '{ printf "%s: %d MB resident, %s%% of a core over the last 10 s\n", name, $1 / 1024, cpu }'
    grep -E "opengl (version|renderer)" "$out/$1.log" || true
    kill "$pid"
    wait "$pid" || true
}

start login
start demo --demo