You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/01/10 15:51:24 UTC

[incubator-echarts-examples] 01/02: Error handling when failed to generate option in build-example

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-examples.git

commit 5b66d9346648121e3ae4d20667f9c88ab45c389a
Author: pissang <bm...@gmail.com>
AuthorDate: Sun Jan 10 23:33:07 2021 +0800

    Error handling when failed to generate option in build-example
---
 e2e/main.js           |  8 +++++++-
 tool/build-example.js | 48 +++++++++++++++++++++++++++++++++---------------
 2 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/e2e/main.js b/e2e/main.js
index a18a20f..27101bc 100644
--- a/e2e/main.js
+++ b/e2e/main.js
@@ -462,7 +462,11 @@ async function runExamples(jsFiles, result) {
     try {
         const IGNORE_LOG = [
             'A cookie associated with a cross-site resource at',
-            'A parser-blocking, cross site'
+            'A parser-blocking, cross site',
+            // For ECharts GL
+            'RENDER WARNING',
+            'GL ERROR',
+            'GL_INVALID_OPERATION'
         ];
 
         const browser = await puppeteer.launch({
@@ -470,6 +474,8 @@ async function runExamples(jsFiles, result) {
             args: [
                 '--headless',
                 '--hide-scrollbars',
+                // https://github.com/puppeteer/puppeteer/issues/4913
+                '--use-gl=egl',
                 '--mute-audio'
             ]
         });
diff --git a/tool/build-example.js b/tool/build-example.js
index 4e4a334..417634e 100644
--- a/tool/build-example.js
+++ b/tool/build-example.js
@@ -68,8 +68,13 @@ const BASE_URL = `http://localhost:${PORT}`;
 const SCREENSHOT_PAGE_URL = `${BASE_URL}/tool/screenshot.html`;
 
 const IGNORE_LOG = [
+    // For BMap
     'A cookie associated with a cross-site resource at',
-    'A parser-blocking, cross site'
+    'A parser-blocking, cross site',
+    // For ECharts GL
+    'RENDER WARNING',
+    'GL ERROR',
+    'GL_INVALID_OPERATION'
 ];
 
 async function convertToWebP(filePath) {
@@ -114,7 +119,7 @@ async function takeScreenshot(
         try {
             await page.goto(url, {
                 waitUntil: 'networkidle0',
-                timeout: 10000
+                timeout: 20000
             });
         }
         catch (e) {
@@ -132,19 +137,25 @@ async function takeScreenshot(
         fse.ensureDirSync(thumbDir);
 
         // Save option for further tests.
-        const option = await page.evaluate(() => {
-            return _$getEChartsOption()
-        });
-        const optionStr = optionToJson(option);
-
-        fse.ensureDirSync(`${rootDir}public/${sourceFolder}/option/`);
-        fs.writeFileSync(`${rootDir}public/${sourceFolder}/option/${basename}.json`, optionStr, 'utf-8');
+        try {
+            const option = await page.evaluate(() => {
+                return _$getEChartsOption()
+            });
+            const optionStr = optionToJson(option);
+            fse.ensureDirSync(`${rootDir}public/${sourceFolder}/option/`);
+            fs.writeFileSync(`${rootDir}public/${sourceFolder}/option/${basename}.json`, optionStr, 'utf-8');
+        }
+        catch (e) {
+            console.error(chalk.red('Failed to generate option'));
+            console.error(chalk.red(e));
+        }
 
         await page.screenshot({
             path: filePathTmpRaw,
             type: 'png'
         });
 
+
         await sharp(filePathTmpRaw)
             .resize(OUTPUT_IMAGE_WIDTH, OUTPUT_IMAGE_WIDTH * DEFAULT_PAGE_RATIO)
             .toFile(filePathTmp);
@@ -213,11 +224,17 @@ async function takeScreenshot(
     for (let theme of themeList) {
         for (let fileName of files) {
             const basename = path.basename(fileName, '.js');
-            tasks.push({
-                buildThumb: BUILD_THUMBS && screenshotBlackList.indexOf(basename) < 0,
-                theme,
-                basename
-            })
+            if (
+                !matchPattern || matchPattern.some(function (pattern) {
+                    return minimatch(basename, pattern);
+                })
+            ) {
+                tasks.push({
+                    buildThumb: BUILD_THUMBS && screenshotBlackList.indexOf(basename) < 0,
+                    theme,
+                    basename
+                });
+            }
         }
     }
 
@@ -229,6 +246,7 @@ async function takeScreenshot(
             || basename === 'lines3d-taxi-chengdu'
             || basename === 'map3d-colorful-cities'
 
+            // TODO Examples that can't work temporary.
             || basename === 'bar3d-music-visualization'
         ) {
             return;
@@ -278,7 +296,7 @@ async function takeScreenshot(
             await browser.close();
             throw new Error(e.toString());
         }
-    }, sourceFolder === 'data-gl' ? 4 : 16);
+    }, sourceFolder === 'data-gl' ? 2 : 16);
 
     if (BUILD_THUMBS) {
         server.close();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org