Log cas-viewer url to screenshot html file

Code predicts the cas-viewer url where the screenshots file
will be uploaded so that the link can be copied from the test log.

Bug: None
Change-Id: Ia5739f7915c2ab657ab8085ce20496327f552684
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4813643
Commit-Queue: Eric Leese <leese@chromium.org>
Reviewed-by: Almothana Athamneh <almuthanna@chromium.org>
This commit is contained in:
Eric Leese
2023-08-30 13:56:56 +00:00
committed by Devtools-frontend LUCI CQ
parent e05c7d315b
commit f5943cd8a7
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as Crypto from 'crypto';
import * as fs from 'fs';
import {createCoverageMap, createFileCoverage} from 'istanbul-lib-coverage';
import * as report from 'istanbul-lib-report';
@@ -62,6 +63,18 @@ export function mochaGlobalTeardown() {
stopServer();
}
function logScreenshotFileUrl() {
const screenshotFile = process.env.HTML_OUTPUT_FILE;
if (screenshotFile) {
const hash = Crypto.createHash('sha256');
const contents = fs.readFileSync(screenshotFile);
hash.update(contents);
console.error(
`If running on bots, screenshots can be downloaded from: https://cas-viewer.appspot.com/projects/chromium-swarm/instances/default_instance/blobs/${
hash.digest('hex')}/${contents.byteLength}?filename=screenshots.html`);
}
}
const testSuiteCoverageMap = createCoverageMap();
const testsRunWithCoverageEnvSet = Boolean(process.env.COVERAGE || process.env.COVERAGE_FOLDERS);
@@ -88,6 +101,7 @@ export const mochaHooks = {
// In parallel mode, run after all tests end, for each file.
afterAll: async function(this: Mocha.Suite) {
await postFileTeardown();
logScreenshotFileUrl();
if (!SHOULD_GATHER_COVERAGE_INFORMATION) {
return;
+1 -1
View File
@@ -12,7 +12,7 @@ import {AsyncScope} from './async-scope.js';
import {getEnvVar} from './config.js';
import {platform, type Platform, stepDescription} from './helper.js';
export {beforeEach} from 'mocha';
export {after, beforeEach} from 'mocha';
let didInitializeHtmlOutputFile = false;