15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
+ const fs = require ( 'fs' ) ;
19
+ const glob = require ( 'glob' ) ;
20
+ const path = require ( 'path' ) ;
21
+
18
22
const argv = require ( `command-line-args` ) ( [
19
23
{ name : `all` , type : Boolean } ,
20
24
{ name : 'update' , alias : 'u' , type : Boolean } ,
@@ -36,4 +40,25 @@ argv.module && !modules.length && modules.push(argv.module);
36
40
( argv . all || ! targets . length ) && targets . push ( `all` ) ;
37
41
( argv . all || ! modules . length ) && modules . push ( `all` ) ;
38
42
43
+ if ( argv . coverage && ( ! argv . json_files || ! argv . json_files . length ) ) {
44
+
45
+ let [ jsonPaths , arrowPaths ] = glob
46
+ . sync ( path . resolve ( __dirname , `../test/data/json/` , `*.json` ) )
47
+ . reduce ( ( paths , jsonPath ) => {
48
+ const { name } = path . parse ( jsonPath ) ;
49
+ const [ jsonPaths , arrowPaths ] = paths ;
50
+ [ 'cpp' , 'java' ] . forEach ( ( source ) => [ 'file' , 'stream' ] . forEach ( ( format ) => {
51
+ const arrowPath = path . resolve ( __dirname , `../test/data/${ source } /${ format } /${ name } .arrow` ) ;
52
+ if ( fs . existsSync ( arrowPath ) ) {
53
+ jsonPaths . push ( jsonPath ) ;
54
+ arrowPaths . push ( arrowPath ) ;
55
+ }
56
+ } ) ) ;
57
+ return paths ;
58
+ } , [ [ ] , [ ] ] ) ;
59
+
60
+ argv . json_files = jsonPaths ;
61
+ argv . arrow_files = arrowPaths ;
62
+ }
63
+
39
64
module . exports = { argv, targets, modules } ;
0 commit comments