mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00

This patch: - drops dependency on playwright-core in all our packages. Instead of the dependency, packages are now built with `//packages/build_package.sh` script. - unifies `browsers.json` - now there's a single `//browsers.json` file that is used to manage browser revisions. This patch temporary switches canary publishing to `--dryn-run` from CI/CD so that we can verify that it does sane things. We'll unify all our package management scripts under `//packages/` in a follow-up. Fixes #2268
141 lines
4.6 KiB
Bash
Executable File
141 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
set +x
|
|
|
|
trap "cd $(pwd -P)" EXIT
|
|
cd "$(dirname $0)"
|
|
|
|
rm -rf ./output
|
|
mkdir ./output
|
|
cd ./output
|
|
|
|
# cleanup environment
|
|
unset PLAYWRIGHT_DOWNLOAD_HOST
|
|
unset PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD
|
|
export PLAYWRIGHT_BROWSERS_PATH=0
|
|
|
|
# Pack all packages and put them in our output folder.
|
|
PACKAGE_BUILDER="../../../packages/build_package.js"
|
|
PLAYWRIGHT_CORE_TGZ="$(node ${PACKAGE_BUILDER} playwright-core ./playwright-core.tgz)"
|
|
PLAYWRIGHT_TGZ="$(node ${PACKAGE_BUILDER} playwright ./playwright.tgz)"
|
|
PLAYWRIGHT_CHROMIUM_TGZ="$(node ${PACKAGE_BUILDER} playwright-chromium ./playwright-chromium.tgz)"
|
|
PLAYWRIGHT_WEBKIT_TGZ="$(node ${PACKAGE_BUILDER} playwright-webkit ./playwright-webkit.tgz)"
|
|
PLAYWRIGHT_FIREFOX_TGZ="$(node ${PACKAGE_BUILDER} playwright-firefox ./playwright-firefox.tgz)"
|
|
|
|
SANITY_JS="$(pwd -P)/../sanity.js"
|
|
TEST_ROOT="$(pwd -P)"
|
|
|
|
function run_tests {
|
|
test_skip_browser_download
|
|
test_playwright_global_installation_subsequent_installs
|
|
test_playwright_should_work
|
|
test_playwright_chromium_should_work
|
|
test_playwright_webkit_should_work
|
|
test_playwright_firefox_should_work
|
|
test_playwright_global_installation
|
|
}
|
|
|
|
function test_playwright_global_installation {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
local BROWSERS="$(pwd -P)/browsers"
|
|
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
|
|
if [[ ! -d "${BROWSERS}" ]]; then
|
|
echo "Directory for shared browsers was not created!"
|
|
exit 1
|
|
fi
|
|
cp ${SANITY_JS} .
|
|
if node sanity.js playwright chromium 2>/dev/null; then
|
|
echo "Should not be able to launch chromium without PLAYWRIGHT_BROWSERS_PATH variable!"
|
|
exit 1
|
|
fi
|
|
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node sanity.js playwright chromium
|
|
}
|
|
|
|
|
|
# @see https://github.com/microsoft/playwright/issues/1651
|
|
function test_playwright_global_installation_subsequent_installs {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
local BROWSERS="$(pwd -P)/browsers"
|
|
|
|
mkdir install-1 && pushd install-1 && npm init -y
|
|
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
|
|
# Note: the `npm install` would not actually crash, the error
|
|
# is merely logged to the console. To reproduce the error, we should make
|
|
# sure that script's install.js can be run subsequently without unhandled promise rejections.
|
|
# Note: the flag `--unahdnled-rejections=strict` will force node to terminate in case
|
|
# of UnhandledPromiseRejection.
|
|
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node --unhandled-rejections=strict node_modules/playwright/install.js
|
|
}
|
|
|
|
function test_skip_browser_download {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
|
|
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
|
|
echo "missing log message that browsers download is skipped"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -d ./node_modules/playwright/.local-browsers ]]; then
|
|
echo "local browsers folder should be empty"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function test_playwright_should_work {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
npm install ${PLAYWRIGHT_TGZ}
|
|
cp ${SANITY_JS} . && node sanity.js playwright chromium firefox webkit
|
|
}
|
|
|
|
function test_playwright_chromium_should_work {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
npm install ${PLAYWRIGHT_CHROMIUM_TGZ}
|
|
cp ${SANITY_JS} . && node sanity.js playwright-chromium chromium
|
|
}
|
|
|
|
function test_playwright_webkit_should_work {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
npm install ${PLAYWRIGHT_WEBKIT_TGZ}
|
|
cp ${SANITY_JS} . && node sanity.js playwright-webkit webkit
|
|
}
|
|
|
|
function test_playwright_firefox_should_work {
|
|
initialize_test "${FUNCNAME[0]}"
|
|
|
|
npm install ${PLAYWRIGHT_CORE_TGZ}
|
|
npm install ${PLAYWRIGHT_FIREFOX_TGZ}
|
|
cp ${SANITY_JS} . && node sanity.js playwright-firefox firefox
|
|
}
|
|
|
|
function initialize_test {
|
|
cd ${TEST_ROOT}
|
|
local TEST_NAME="./$1"
|
|
mkdir ${TEST_NAME} && cd ${TEST_NAME} && npm init -y
|
|
echo "====================================================================================="
|
|
echo "====================================================================================="
|
|
echo
|
|
echo " RUNNING TEST: ${TEST_NAME}"
|
|
echo
|
|
echo "====================================================================================="
|
|
echo "====================================================================================="
|
|
}
|
|
|
|
# Run all tests
|
|
# Script will terminate if there's some error somewhere.
|
|
run_tests
|
|
|
|
echo
|
|
echo "SUCCESS!"
|