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/30 07:10:21 UTC
[echarts] branch enhance-visual-regression-test updated:
test(visual): add disk size stat
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 ccfa1ad test(visual): add disk size stat
ccfa1ad is described below
commit ccfa1ad9b5dbc3ded07bd90bd79530c10199b12a
Author: pissang <bm...@gmail.com>
AuthorDate: Fri Apr 30 15:08:57 2021 +0800
test(visual): add disk size stat
---
test/runTest/client/client.js | 7 ++++++-
test/runTest/client/index.html | 9 +++++----
test/runTest/store.js | 37 +++++++++++++++++++++++++++++++++----
3 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/test/runTest/client/client.js b/test/runTest/client/client.js
index a9dd0e5..99d2f99 100644
--- a/test/runTest/client/client.js
+++ b/test/runTest/client/client.js
@@ -348,7 +348,12 @@ const app = new Vue({
},
switchTestsRun(runResult) {
-
+ this.runConfig.expectedVersion = runResult.expectedVersion;
+ this.runConfig.actualVersion = runResult.actualVersion;
+ // TODO
+ this.runConfig.isExpectedNightly = runResult.expectedVersion.includes('-dev.');
+ this.runConfig.isActualNightly = runResult.actualVersion.includes('-dev.');
+ this.runConfig.renderer = runResult.renderer;
},
genTestsRunReport(runResult) {
diff --git a/test/runTest/client/index.html b/test/runTest/client/index.html
index 6205407..697493c 100644
--- a/test/runTest/client/index.html
+++ b/test/runTest/client/index.html
@@ -287,16 +287,17 @@ under the License.
title="All Tests Runs"
>
<el-table :data="testsRuns">
- <el-table-column property="expectedVersion" label="Expected"></el-table-column>
- <el-table-column property="actualVersion" label="Actual"></el-table-column>
+ <el-table-column property="expectedVersion" label="Expected" width="160"></el-table-column>
+ <el-table-column property="actualVersion" label="Actual" width="160"></el-table-column>
<el-table-column property="renderer" label="Renderer" width="100"></el-table-column>
- <el-table-column property="lastRunTime" label="lastRunTime"></el-table-column>
+ <el-table-column property="lastRunTime" label="Last Run"></el-table-column>
+ <el-table-column property="diskSize" label="Disk Size" width="100"></el-table-column>
<el-table-column property="total" label="Total Tests" width="100"></el-table-column>
<el-table-column property="finished" label="Finished" width="100"></el-table-column>
<el-table-column property="passed" label="Passed" width="100"></el-table-column>
<el-table-column
fixed="right"
- label=""
+ label="Operations"
width="160">
<template slot-scope="scope">
<el-button type="text" @click="switchTestsRun(scope.row)" size="small">View</el-button>
diff --git a/test/runTest/store.js b/test/runTest/store.js
index a6135bb..391da70 100644
--- a/test/runTest/store.js
+++ b/test/runTest/store.js
@@ -23,6 +23,7 @@ const fs = require('fs');
const globby = require('globby');
const {testNameFromFile} = require('./util');
const {blacklist, SVGBlacklist} = require('./blacklist');
+const { promisify } = require('util');
let _tests = [];
let _testsMap = {};
@@ -33,6 +34,14 @@ const RESULTS_ROOT_DIR = path.join(__dirname, 'tmp', 'result');
const TEST_HASH_SPLITTER = '__';
+function convertBytes(bytes) {
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
+ if (bytes == 0) {
+ return 'N/A';
+ }
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
+ return (bytes / Math.pow(1024, i)).toFixed(Math.min(1, i)) + ' ' + sizes[i]
+}
class Test {
constructor(fileUrl) {
this.fileUrl = fileUrl;
@@ -201,13 +210,31 @@ module.exports.updateActionsMeta = function (testName, actions) {
), 'utf-8');
};
+
+async function getFolderSize(dir) {
+ const files = await globby(dir);
+ let size = 0;
+ for (let file of files) {
+ size += fs.statSync(file).size;
+ }
+ return size;
+ // const statAsync = promisify(fs.stat);
+ // return Promise.all(
+ // files.map(file => statAsync(file))
+ // ).then(sizes => {
+ // return sizes.reduce((total, current) => {
+ // return total + current.size;
+ // }, 0)
+ // });
+}
/**
* Get results of all runs
- * @return [ { id, expectedVersion, actualVersion, renderer, lastRunTime, total, finished, passed } ]
+ * @return [ { id, expectedVersion, actualVersion, renderer, lastRunTime, total, finished, passed, diskSize } ]
*/
module.exports.getAllTestsRuns = async function () {
const dirs = await globby('*', { cwd: RESULTS_ROOT_DIR, onlyDirectories: true });
- return dirs.map((dir) => {
+ const results = [];
+ for (let dir of dirs) {
const params = parseRunHash(dir);
const resultJson = JSON.parse(fs.readFileSync(path.join(
RESULTS_ROOT_DIR,
@@ -243,9 +270,11 @@ module.exports.getAllTestsRuns = async function () {
params.passed = passedCount;
params.finished = finishedCount;
params.id = dir;
+ params.diskSize = convertBytes(await getFolderSize(path.join(RESULTS_ROOT_DIR, dir)));
- return params;
- });
+ results.push(params);
+ };
+ return results;
}
module.exports.delTestsRun = async function (hash) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org