-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
## | ||
# @license Copyright 2020 The Lighthouse Authors. All Rights Reserved. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
## | ||
|
||
set -euo pipefail | ||
|
||
roll_devtools() { | ||
# Roll devtools. Besides giving DevTools the latest lighthouse source files, | ||
# this also copies over the webtests. | ||
cd "$LH_ROOT" | ||
yarn devtools "$DEVTOOLS_PATH" | ||
cd - | ||
} | ||
|
||
# Setup inspector-sources. | ||
cd "$DEVTOOLS_PATH" | ||
git --no-pager log -1 | ||
roll_devtools | ||
autoninja -C out/Default # Build devtools resources. | ||
cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
lighthouse-core/test/chromium-web-tests/test-page-devtools.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
## | ||
# @license Copyright 2020 The Lighthouse Authors. All Rights Reserved. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
## | ||
|
||
set -euo pipefail | ||
|
||
if [ -z "$1" ]; then | ||
echo "ERROR: No URL provided." | ||
exit 1 | ||
fi | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
export LH_ROOT="$( cd "$SCRIPT_DIR/../../.." && pwd )" | ||
|
||
# Setup dependencies. | ||
TEST_DIR="$LH_ROOT/.tmp/chromium-web-tests" | ||
export DEPOT_TOOLS_PATH="$TEST_DIR/depot-tools" | ||
export DEVTOOLS_PATH=${DEVTOOLS_PATH:-"$TEST_DIR/devtools/devtools-frontend"} | ||
export BLINK_TOOLS_PATH="$TEST_DIR/blink_tools" | ||
export PATH=$DEPOT_TOOLS_PATH:$PATH | ||
|
||
bash "$SCRIPT_DIR/download-depot-tools.sh" | ||
bash "$SCRIPT_DIR/download-devtools.sh" | ||
bash "$SCRIPT_DIR/download-blink-tools.sh" | ||
bash "$SCRIPT_DIR/download-content-shell.sh" | ||
|
||
bash "$SCRIPT_DIR/roll-devtools.sh" | ||
|
||
# Add test to run lighthouse in DevTools and print LHR. | ||
echo " | ||
(async function() { | ||
await TestRunner.navigatePromise('$1'); | ||
await TestRunner.loadModule('lighthouse_test_runner'); | ||
await TestRunner.showPanel('lighthouse'); | ||
LighthouseTestRunner.getRunButton().click(); | ||
const {lhr} = await LighthouseTestRunner.waitForResults(); | ||
TestRunner.addResult(JSON.stringify(lhr)); | ||
TestRunner.completeTest(); | ||
})(); | ||
" > "$DEVTOOLS_PATH/test/webtests/http/tests/devtools/lighthouse/lighthouse-run-dt.js" | ||
|
||
set +e | ||
bash "$SCRIPT_DIR/web-test-server.sh" --no-show-results --time-out-ms=60000 http/tests/devtools/lighthouse/lighthouse-run-dt.js | ||
set -e | ||
|
||
# Copy results to latest-run folder. | ||
# Sometimes there will be extra output before the line with LHR. To get around this, only copy the last line with content. | ||
grep "lighthouseVersion" -m 1 \ | ||
"$LH_ROOT/.tmp/layout-test-results/http/tests/devtools/lighthouse/lighthouse-run-dt-actual.txt" \ | ||
> "$LH_ROOT/latest-run/devtools-lhr.json" | ||
|
||
echo "Open the LHR at $LH_ROOT/latest-run/devtools-lhr.json" |
66 changes: 66 additions & 0 deletions
66
lighthouse-core/test/chromium-web-tests/web-test-server.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
## | ||
# @license Copyright 2020 The Lighthouse Authors. All Rights Reserved. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
## | ||
|
||
set -euo pipefail | ||
|
||
# Get newest folder | ||
latest_content_shell_dir=$(ls -t "$LH_ROOT/.tmp/chromium-web-tests/content-shells/" | head -n1) | ||
export latest_content_shell="$LH_ROOT/.tmp/chromium-web-tests/content-shells/$latest_content_shell_dir" | ||
|
||
# Run a very basic server on port 8000. Only thing we need is: | ||
# - /devtools -> the layout tests for devtools frontend | ||
# - /inspector-sources -> the inspector resources from the content shell | ||
# - CORS (Access-Control-Allow-Origin header) | ||
|
||
ln -s "$DEVTOOLS_PATH/out/Default/resources/inspector" "$DEVTOOLS_PATH/test/webtests/http/tests/inspector-sources" | ||
|
||
# Kill background jobs when script ends. | ||
cleanup() { | ||
rm "$DEVTOOLS_PATH/test/webtests/http/tests/inspector-sources" | ||
kill ${SERVER_PID} | ||
} | ||
trap 'cleanup' EXIT | ||
|
||
# Serve from devtools frontend webtests folder. | ||
(npx http-server@0.12.3 "$DEVTOOLS_PATH/test/webtests/http/tests" -p 8000 --cors > /dev/null 2>&1) & | ||
SERVER_PID=$! | ||
|
||
echo "Waiting for server" | ||
health_check_url='http://localhost:8000/inspector-sources/integration_test_runner.html?experiments=true&test=http://127.0.0.1:8000/devtools/lighthouse/lighthouse-view-trace-run.js' | ||
until $(curl --output /dev/null --silent --head --fail $health_check_url); do | ||
printf '.' | ||
sleep 1 | ||
done | ||
echo "Server is up" | ||
|
||
# webtests sometimes error if results are already present. | ||
rm -rf "$latest_content_shell/out/Release/layout-test-results" | ||
|
||
# Add typ to python path. The regular method assumes there is a Chromium checkout. | ||
export PYTHONPATH="${PYTHONPATH:-}:$BLINK_TOOLS_PATH/latest/third_party/typ" | ||
|
||
# Don't quit if the python command fails. | ||
set +e | ||
# Print the python command. | ||
set -x | ||
|
||
python \ | ||
"$BLINK_TOOLS_PATH/latest/third_party/blink/tools/run_web_tests.py" \ | ||
--layout-tests-directory="$DEVTOOLS_PATH/test/webtests" \ | ||
--build-directory="$latest_content_shell/out" \ | ||
$* | ||
status=$? | ||
|
||
set +x | ||
set -e | ||
|
||
rm -rf "$LH_ROOT/.tmp/layout-test-results" | ||
cp -r "$latest_content_shell/out/Release/layout-test-results" "$LH_ROOT/.tmp/layout-test-results" | ||
cp "$DEVTOOLS_PATH/test/webtests/http/tests/devtools/lighthouse/"*-expected.txt "$LH_ROOT/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse" | ||
|
||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters