#!/bin/bash # CTest: publish the recorded Electron 45 snapshot with the browser publisher # on a private accessibility bus, and compare what readers would see with # native Linux Chromium: the document with text boundaries against Chromium # 158, and the whole application against Electron 42. No Wine is needed. # Usage: publisher_snapshot_test.sh PUBLISHER set -u if [[ $# -ne 1 || ! -x "$1" ]]; then echo "Usage: $0 PUBLISHER" exit 2 fi publisher="$1" testDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" dataDir="$testDir/data" workDir="$(mktemp -d)" trap 'rm -rf "$workDir"' EXIT export publisher testDir dataDir workDir # shellcheck disable=SC2016 # expanded by the inner shell timeout 180 "$testDir/private_session.sh" bash -c ' "$publisher" "$dataDir/electron45-snapshot.json" --active > "$workDir/publisher.log" 2>&1 & publisherPid=$! python3 -I "$testDir/atspi_dump.py" --app-name electron --boundaries > "$workDir/document.txt" 2>&1 python3 -I "$testDir/atspi_dump.py" --app-name electron --whole-app > "$workDir/application.txt" 2>&1 kill "$publisherPid" 2> /dev/null wait "$publisherPid" 2> /dev/null exit 0 ' 2> "$workDir/session.log" sessionStatus=$? if [[ "$sessionStatus" -ne 0 ]]; then echo "FAIL: private session (status $sessionStatus)" cat "$workDir/session.log" exit 1 fi failures=0 if python3 -I "$testDir/compare_dumps.py" "$dataDir/native-chromium158-document.txt" "$workDir/document.txt" \ > "$workDir/document.diff"; then echo "PASS: document and text boundaries match native Chromium 158" else echo "FAIL: document differs from native Chromium 158" tail -n 40 "$workDir/document.diff" failures=$((failures + 1)) fi if python3 -I "$testDir/compare_dumps.py" "$dataDir/native-electron42-application.txt" "$workDir/application.txt" \ --baseline electron42 > "$workDir/application.diff"; then echo "PASS: application matches native Electron 42" else echo "FAIL: application differs from native Electron 42" tail -n 40 "$workDir/application.diff" failures=$((failures + 1)) fi if grep -q -E 'WARNING|CRITICAL' "$workDir/publisher.log"; then echo "FAIL: publisher warnings" grep -E 'WARNING|CRITICAL' "$workDir/publisher.log" | head -n 10 failures=$((failures + 1)) else echo "PASS: no publisher warnings" fi [[ "$failures" -eq 0 ]]