Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e57617

Browse files
committed
use memory instead of read/writes for tests
1 parentb57c0ab commit4e57617

File tree

9 files changed

+34
-97
lines changed

9 files changed

+34
-97
lines changed

‎lib/reducers/run-tests/run.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ var fs = require('fs');
55
varpath=require('path');
66
varparse_loaders_1=require('./parse-loaders');
77
functionrunTaskTests(setup){
8-
vartestFile=_base_1.store.getState().taskTests;
9-
if(testFile){
8+
vartests=_base_1.store.getState().taskTests;
9+
if(tests&&tests.length){
1010
varconfig=window.coderoad;
1111
config.taskPosition=_base_1.store.getState().taskPosition;
12-
varfileType=testFile.substr(testFile.lastIndexOf('.')+1,testFile.length)||null;
13-
vartests=fs.readFileSync(testFile,'utf8');
14-
varoutput=parse_loaders_1.default(tests,fileType);
15-
vartarget=path.join(window.coderoad.tutorialDir||window.coderoad.dir,"_tmp"+window.coderoad.suffix);
12+
varoutput=parse_loaders_1.default(tests,window.coderoad.suffix);
13+
vartarget=path.join(window.coderoad.tutorialDir||window.coderoad.dir,"_tmp."+window.coderoad.suffix);
1614
fs.writeFileSync(target,output,'utf8');
1715
window.coderoad.runner(target,config,test_result_1.handleResult);
1816
}

‎lib/reducers/task-tests/loader.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎lib/reducers/task-tests/task-tests.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
'use strict';
2-
varpath=require('path');
1+
"use strict";
2+
varfs=require('fs');
33
varType=require('../../actions/actionTypes');
4-
varloader_1=require('./loader');
54
functiontaskTestsReducer(taskTests,action){
65
if(taskTests===void0){taskTests='';}
76
switch(action.type){
87
caseType.SET_PAGE:
9-
vartarget=path.join(window.coderoad.tutorialDir||window.coderoad.dir,"_tmpTests"+window.coderoad.suffix);
10-
loader_1.default(target,action.payload.taskTests);
11-
returntarget;
8+
vartests_1='';
9+
action.payload.taskTests.forEach(function(file){
10+
try{
11+
vardata=fs.readFileSync(file,'utf8');
12+
tests_1+=data+'\n';
13+
}
14+
catch(e){
15+
console.log('Error reading test file',e);
16+
}
17+
});
18+
returntests_1;
1219
default:
1320
returntaskTests;
1421
}

‎lib/services/setGlobals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var exists_1 = require('./exists');
44
functionsetGlobals(config){
55
window.coderoad=Object.assign(window.coderoad,{
66
tutorial:config.name,
7-
suffix:config.config.testSuffix.substring(config.config.testSuffix.lastIndexOf('.'),config.config.testSuffix.length),
7+
suffix:config.config.testSuffix.substring(config.config.testSuffix.lastIndexOf('.')+1,config.config.testSuffix.length),
88
tutorialDir:path.join(window.coderoad.dir,'node_modules',config.name,config.config.testDir),
99
testRunner:config.config.testRunner,
1010
testRunnerOptions:config.config.testRunnerOptions||{}

‎src/reducers/run-tests/run.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@ import * as fs from 'fs';
44
import*aspathfrom'path';
55
importparseLoadersfrom'./parse-loaders';
66

7-
// TODO: use memcache for test files instead of read/writes
8-
97
exportfunctionrunTaskTests(setup?:boolean):boolean{
10-
consttestFile:string=store.getState().taskTests;
8+
consttests:string=store.getState().taskTests;
119

12-
if(testFile){
10+
if(tests&&tests.length){
1311
letconfig=window.coderoad;
1412
config.taskPosition=store.getState().taskPosition;
13+
letoutput=parseLoaders(tests,window.coderoad.suffix);
1514

16-
letfileType:string=testFile.substr(testFile.lastIndexOf('.')+1,testFile.length)||null;
17-
lettests=fs.readFileSync(testFile,'utf8');
18-
letoutput=parseLoaders(tests,fileType);
19-
20-
lettarget=path.join(window.coderoad.tutorialDir||window.coderoad.dir,`_tmp${window.coderoad.suffix}`);
15+
// write temporary test file in tutorial directory
16+
lettarget=path.join(window.coderoad.tutorialDir||window.coderoad.dir,`_tmp.${window.coderoad.suffix}`);
2117
fs.writeFileSync(target,output,'utf8');
2218

2319
// call test runner

‎src/reducers/task-tests/concat-tests.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎src/reducers/task-tests/task-tests.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ import concatTests from './concat-tests';
66
exportdefaultfunctiontaskTestsReducer(taskTests='',action:CR.Action):string{
77
switch(action.type){
88
caseType.SET_PAGE:
9-
lettarget=path.join(window.coderoad.tutorialDir||window.coderoad.dir,`_tmpTests${window.coderoad.suffix}`);
10-
concatTests(target,action.payload.taskTests);
11-
returntarget;
9+
lettests='';
10+
action.payload.taskTests.forEach(function(file:string){
11+
try{
12+
letdata=fs.readFileSync(file,'utf8');
13+
tests+=data+'\n';
14+
}catch(e){
15+
console.log('Error reading test file',e);
16+
}
17+
});
18+
returntests;
1219
default:
1320
returntaskTests;
1421
}

‎src/services/setGlobals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {fileExists} from './exists';
44
exportfunctionsetGlobals(config:PackageJson){
55
window.coderoad=Object.assign(window.coderoad,{
66
tutorial:config.name,
7-
suffix:config.config.testSuffix.substring(config.config.testSuffix.lastIndexOf('.'),config.config.testSuffix.length),
7+
suffix:config.config.testSuffix.substring(config.config.testSuffix.lastIndexOf('.')+1,config.config.testSuffix.length),
88
tutorialDir:path.join(window.coderoad.dir,'node_modules',config.name,config.config.testDir),
99
testRunner:config.config.testRunner,
1010
testRunnerOptions:config.config.testRunnerOptions||{}

‎tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"src/reducers/run-tests/run.ts",
8585
"src/reducers/run-tests/test-result.ts",
8686
"src/reducers/task-position/task-position.ts",
87-
"src/reducers/task-tests/concat-tests.ts",
8887
"src/reducers/task-tests/task-tests.ts",
8988
"src/reducers/tasks/tasks.ts",
9089
"src/reducers/tutorials/tutorials.ts",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp