提交 59e5b808 编写于 作者: P pissang

chore(visual): optimize running status

上级 9b97e376
......@@ -423,7 +423,19 @@ function updateUrl(notRefresh) {
history.pushState({}, '', location.pathname + '?' + searchUrl);
}
else {
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;
}
}
}
......
......@@ -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;"
......
......@@ -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) => {
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!');
......
......@@ -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;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册