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/04/29 14:14:57 UTC

[echarts] branch enhance-visual-regression-test updated: chore(visual): optimize running status

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

shenyi pushed a commit to branch enhance-visual-regression-test
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/enhance-visual-regression-test by this push:
     new 59e5b80  chore(visual): optimize running status
59e5b80 is described below

commit 59e5b80837303c0651c910453aaee2d7de7f80ba
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Apr 29 22:12:51 2021 +0800

    chore(visual): optimize running status
---
 test/runTest/client/client.js  | 14 +++++++++++++-
 test/runTest/client/index.html |  2 +-
 test/runTest/server.js         | 30 ++++++++++++++++++------------
 test/runTest/store.js          |  4 ++++
 4 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/test/runTest/client/client.js b/test/runTest/client/client.js
index 016d847..46a9505 100644
--- a/test/runTest/client/client.js
+++ b/test/runTest/client/client.js
@@ -423,7 +423,19 @@ function updateUrl(notRefresh) {
         history.pushState({}, '', location.pathname + '?' + searchUrl);
     }
     else {
-        window.location.search = '?' + searchUrl;
+        if (app.running) {
+            app.$confirm('Change versions will stop the running tests. <br />Do you still want to continue?', 'Warn', {
+                confirmButtonText: 'Yes',
+                cancelButtonText: 'No',
+                dangerouslyUseHTMLString: true,
+                center: true
+            }).then(value => {
+                window.location.search = '?' + searchUrl;
+            }).catch(() => {});
+        }
+        else {
+            window.location.search = '?' + searchUrl;
+        }
     }
 }
 
diff --git a/test/runTest/client/index.html b/test/runTest/client/index.html
index f86c65b..72e6536 100644
--- a/test/runTest/client/index.html
+++ b/test/runTest/client/index.html
@@ -84,7 +84,7 @@ under the License.
                         </el-tooltip>
                         <el-tooltip
                             content="Not yet run"
-                            v-else
+                            v-else-if="!(test.status === 'pending' && running)"
                         >
                             <i class="el-icon-question"
                                 style="color: #ccc;font-size: 20px;"
diff --git a/test/runTest/server.js b/test/runTest/server.js
index b478d76..f9b33a3 100644
--- a/test/runTest/server.js
+++ b/test/runTest/server.js
@@ -54,7 +54,7 @@ function serve() {
 
 let runningThreads = [];
 let pendingTests;
-let aborted = true;
+let running = false;
 
 function stopRunningTests() {
     if (runningThreads) {
@@ -67,6 +67,7 @@ function stopRunningTests() {
                 testOpt.status = 'unsettled';
             }
         });
+        saveTestsList();
         pendingTests = null;
     }
 }
@@ -133,13 +134,14 @@ function startTests(testsNameList, socket, {
                 testOpt.results = [];
             });
 
-            if (!aborted) {
+            if (running) {
                 socket.emit('update', {
                     tests: getTestsList(),
                     running: true
                 });
             }
         }
+
         let runningCount = 0;
         function onExit() {
             runningCount--;
@@ -150,7 +152,7 @@ function startTests(testsNameList, socket, {
         }
         function onUpdate() {
             // Merge tests.
-            if (!aborted && !noSave) {
+            if (running && !noSave) {
                 socket.emit('update', {
                     tests: getTestsList(),
                     running: true
@@ -210,7 +212,8 @@ async function start() {
         return;
     }
 
-    updateTestsList(true);
+
+    let _currentTestHash;
 
     // let runtimeCode = await buildRuntimeCode();
     // fse.outputFileSync(path.join(__dirname, 'tmp/testRuntime.js'), runtimeCode, 'utf-8');
@@ -220,20 +223,22 @@ async function start() {
 
     io.of('/client').on('connect', async socket => {
         function abortTests() {
-            if (aborted) {
+            if (!running) {
                 return;
             }
             stopRunningTests();
             io.of('/client').emit('abort');
-            aborted = true;
+            running = false;
         }
 
         socket.on('setTestVersions', async (params) => {
-            abortTests();
+            if (_currentTestHash !== getTestHash(params)) {
+                abortTests();
+            }
 
             await updateTestsList(
-                getTestHash(params),
-                true
+                _currentTestHash = getTestHash(params),
+                !running // Set to unsettled if not running
             );
 
             socket.emit('update', {
@@ -245,12 +250,12 @@ async function start() {
         socket.on('run', async data => {
 
             let startTime = Date.now();
-            aborted = false;
+            running = true;
 
             await prepareEChartsLib(data.expectedVersion); // Expected version.
             await prepareEChartsLib(data.actualVersion); // Version to test
 
-            if (aborted) {  // If it is aborted when downloading echarts lib.
+            if (!running) {  // If it is aborted when downloading echarts lib.
                 return;
             }
 
@@ -274,13 +279,14 @@ async function start() {
                 console.error(e);
             }
 
-            if (!aborted) {
+            if (running) {
                 console.log('Finished');
                 io.of('/client').emit('finish', {
                     time: Date.now() - startTime,
                     count: data.tests.length,
                     threads: data.threads
                 });
+                running = false;
             }
             else {
                 console.log('Aborted!');
diff --git a/test/runTest/store.js b/test/runTest/store.js
index 62db9a3..8da5852 100644
--- a/test/runTest/store.js
+++ b/test/runTest/store.js
@@ -137,6 +137,10 @@ module.exports.updateTestsList = async function (
     _tests.forEach(testOpt => {
         testOpt.actions = actionsMetaData[testOpt.name] || 0;
     });
+
+    // Save once.
+    module.exports.saveTestsList();
+
     return _tests;
 };
 

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