@@ -8,7 +8,7 @@ const csv = require('fast-csv');
8
8
const fs = require ( 'fs' ) ;
9
9
const { spawn } = require ( 'child_process' ) ;
10
10
const async = require ( 'async' ) ;
11
-
11
+ const moment = require ( 'moment' ) ;
12
12
13
13
14
14
// default logger
@@ -114,13 +114,18 @@ async function runTest(program, file, address) {
114
114
}
115
115
116
116
117
- async function main ( { mode = 3 , limit = Infinity , outputFile = './result.json' } ) {
117
+ async function main ( { mode = 3 , limit = Infinity , outputFile = './result.json' , tag } ) {
118
118
return new Promise ( async ( resolve , reject ) => {
119
119
const allTestData = await readTestCases ( './data/testcases_ogcio_searchable.csv' ) ;
120
120
const result = {
121
121
total : 0
122
122
}
123
123
124
+
125
+ result . date = moment ( ) . format ( 'YYYY-MM-DD hh:mm:ss' ) ;
126
+ if ( typeof ( tag ) === 'string' && tag . length > 0 ) {
127
+ result . tag = tag ;
128
+ }
124
129
if ( mode & 2 ) {
125
130
result . py_success = 0 ;
126
131
result . py_failed = [ ] ;
@@ -166,7 +171,8 @@ async function main({ mode = 3, limit = Infinity, outputFile = './result.json' }
166
171
if ( mode & 1 ) {
167
172
result . js_success_rate = `${ result . js_success / result . total } ` ;
168
173
}
169
- fs . writeFileSync ( outputFile , JSON . stringify ( result , null , 4 ) ) ;
174
+
175
+ fs . appendFileSync ( outputFile , JSON . stringify ( result ) + '\n' ) ;
170
176
log ( result ) ;
171
177
resolve ( ) ;
172
178
} )
@@ -196,14 +202,17 @@ program
196
202
program
197
203
. description ( 'Run the test cases' )
198
204
. option ( '-o, --output [file]' , 'Output the test result to the file' )
199
- . option ( '-c, --ci [file]' , 'Running in CI mode, will append the percentage to the file' )
200
205
. option ( '-l, --limit [n]' , 'Limit the number of test cases to run' )
201
206
. option ( '-p, --python' , 'Running only the python test' )
202
207
. option ( '-j, --js' , 'Running only the javascript test' )
208
+ . option ( '-t, --tag [tag]' , 'Save the tag with the result' )
203
209
. parse ( process . argv ) ;
204
210
205
211
206
212
const outputFile = program . output || './results.json' ;
213
+ const ciOutputFile = program . ci || null ;
214
+ const tag = program . tag ;
215
+
207
216
// bitwise flag: | python | node |
208
217
const mode = ! program . python | ! program . js << 1 ;
209
218
const limit = program . limit || Infinity ;
@@ -214,7 +223,7 @@ if (mode === 0) {
214
223
end ( ) ;
215
224
}
216
225
217
- main ( { mode, limit, outputFile } )
226
+ main ( { mode, limit, outputFile, ciOutputFile , tag } )
218
227
. then ( ( end ) => {
219
228
log ( 'Done' ) ;
220
229
} )
0 commit comments