summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/tools/assets
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /remote/test/puppeteer/tools/assets
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/test/puppeteer/tools/assets')
-rwxr-xr-xremote/test/puppeteer/tools/assets/verify_issue.ts68
1 files changed, 68 insertions, 0 deletions
diff --git a/remote/test/puppeteer/tools/assets/verify_issue.ts b/remote/test/puppeteer/tools/assets/verify_issue.ts
new file mode 100755
index 0000000000..5814eff66c
--- /dev/null
+++ b/remote/test/puppeteer/tools/assets/verify_issue.ts
@@ -0,0 +1,68 @@
+import {spawnSync} from 'child_process';
+import {readFile, writeFile} from 'fs/promises';
+
+(async () => {
+ const error = await readFile('puppeteer-error.txt', 'utf-8');
+ const behavior = JSON.parse(
+ await readFile('puppeteer-behavior.json', 'utf-8')
+ ) as {flaky?: boolean; noError?: boolean};
+
+ let maxRepetitions = 1;
+ if (behavior.flaky) {
+ maxRepetitions = 100;
+ }
+
+ let status: number | null = null;
+ let stderr = '';
+ let stdout = '';
+
+ const preHook = async () => {
+ console.log('Writing output and error logs...');
+ await Promise.all([
+ writeFile('output.log', stdout),
+ writeFile('error.log', stderr),
+ ]);
+ };
+
+ let checkStatusWithError: () => Promise<void>;
+ if (behavior.noError) {
+ checkStatusWithError = async () => {
+ if (status === 0) {
+ await preHook();
+ console.log('Script ran successfully; no error found.');
+ process.exit(0);
+ }
+ };
+ } else {
+ checkStatusWithError = async () => {
+ if (status !== 0) {
+ await preHook();
+ if (stderr.toLowerCase().includes(error.toLowerCase())) {
+ console.log('Script failed; error found.');
+ process.exit(0);
+ }
+ console.error('Script failed; unknown error found.');
+ process.exit(1);
+ }
+ };
+ }
+
+ for (let i = 0; i < maxRepetitions; ++i) {
+ const result = spawnSync('npm', ['start'], {
+ shell: true,
+ encoding: 'utf-8',
+ });
+ status = result.status;
+ stdout = result.stdout ?? '';
+ stderr = result.stderr ?? '';
+ await checkStatusWithError();
+ }
+
+ await preHook();
+ if (behavior.noError) {
+ console.error('Script failed; unknown error found.');
+ } else {
+ console.error('Script ran successfully; no error found.');
+ }
+ process.exit(1);
+})();