summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/tools/assets
diff options
context:
space:
mode:
Diffstat (limited to '')
-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);
+})();