فهرست منبع

more work on capturing output

Nicholas Bollweg 4 سال پیش
والد
کامیت
37615888b5
2فایلهای تغییر یافته به همراه18 افزوده شده و 7 حذف شده
  1. 16 1
      jupyterlab/chrome-test.js
  2. 2 6
      scripts/release_test.sh

+ 16 - 1
jupyterlab/chrome-test.js

@@ -1,12 +1,22 @@
 const puppeteer = require('puppeteer');
 const inspect = require('util').inspect;
 const path = require('path');
+const fs = require('fs');
 
 const URL = process.argv[2];
 const OUTPUT_VAR = 'JLAB_BROWSER_CHECK_OUTPUT';
 const OUTPUT = process.env[OUTPUT_VAR];
 
 let nextScreenshot = 0;
+const screenshotStem = `screenshot-${+new Date()}`;
+
+if (OUTPUT) {
+  console.log(`Screenshots will be saved in ${OUTPUT}...`);
+  if (!fs.existsSync(OUTPUT)) {
+    console.log(`Creating ${OUTPUT}...`);
+    fs.mkdirSync(OUTPUT, { recursive: true });
+  }
+}
 
 async function main() {
   /* eslint-disable no-console */
@@ -23,9 +33,14 @@ async function main() {
     if (!OUTPUT) {
       return;
     }
+    const screenshotPath = path.join(
+      OUTPUT,
+      `${screenshotStem}-${++nextScreenshot}.png`
+    );
+    console.log(`Capturing screenshot ${screenshotPath}...`);
     await page.screenshot({
       type: 'png',
-      path: path.join(OUTPUT, `screenshot-${++nextScreenshot}.png`)
+      path: screenshotPath
     });
   }
 

+ 2 - 6
scripts/release_test.sh

@@ -10,10 +10,6 @@ set -ex
 JLAB_TEST_ENV="${CONDA_DEFAULT_ENV}_test"
 TEST_DIR=$(mktemp -d -t ${JLAB_TEST_ENV}XXXXX)
 
-# make a folder for output
-JLAB_BROWSER_CHECK_OUTPUT=$(pwd)/build/${GROUP}_output
-mkdir -p $JLAB_BROWSER_CHECK_OUTPUT
-
 conda create --override-channels --strict-channel-priority -c conda-forge -c nodefaults -y -n "$JLAB_TEST_ENV" 'nodejs>=10,!=13.*,!=15.*,!=17.*' pip wheel setuptools
 conda activate "$JLAB_TEST_ENV"
 
@@ -23,7 +19,7 @@ cp examples/notebooks/*.ipynb $TEST_DIR/
 
 pushd $TEST_DIR
 
-python -m jupyterlab.browser_check || python -m jupyterlab.browser_check
+JLAB_BROWSER_CHECK_OUTPUT=$(pwd)/build/${GROUP}_output python -m jupyterlab.browser_check
 
 jupyter lab clean --all
 
@@ -50,7 +46,7 @@ pushd $TEST_DIR
 jupyter lab build
 
 # retry once, much flake
-python -m jupyterlab.browser_check || python -m jupyterlab.browser_check
+JLAB_BROWSER_CHECK_OUTPUT=$(pwd)/build/${GROUP}_output python -m jupyterlab.browser_check
 
 # if not running on github actions, start JupyterLab
 if [[ -z "${GITHUB_ACTIONS}" ]]; then