Skip to content

Commit 263d06d

Browse files
committed
clean up js integration script
1 parent 78cba38 commit 263d06d

1 file changed

Lines changed: 59 additions & 67 deletions

File tree

js/bin/integration.js

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,15 @@
1717
// specific language governing permissions and limitations
1818
// under the License.
1919

20-
var fs = require('fs');
21-
var glob = require('glob');
22-
var path = require('path');
23-
var gulp = require.resolve(path.join(`..`, `node_modules/gulp/bin/gulp.js`));
24-
var child_process = require(`child_process`);
25-
var optionList = [
26-
{
27-
type: String,
28-
name: 'mode',
29-
description: 'The integration test to run'
30-
},
31-
{
32-
type: String,
33-
name: 'arrow', alias: 'a',
34-
multiple: true, defaultValue: [],
35-
description: 'The Arrow file[s] to read/write'
36-
},
37-
{
38-
type: String,
39-
name: 'json', alias: 'j',
40-
multiple: true, defaultValue: [],
41-
description: 'The JSON file[s] to read/write'
42-
}
43-
];
44-
45-
var argv = require(`command-line-args`)(optionList, { partial: true });
46-
47-
function print_usage() {
48-
console.log(require('command-line-usage')([
49-
{
50-
header: 'integration',
51-
content: 'Script for running Arrow integration tests'
52-
},
53-
{
54-
header: 'Synopsis',
55-
content: [
56-
'$ integration.js -j file.json -a file.arrow --mode validate'
57-
]
58-
},
59-
{
60-
header: 'Options',
61-
optionList: [
62-
...optionList,
63-
{
64-
name: 'help',
65-
description: 'Print this usage guide.'
66-
}
67-
]
68-
},
69-
]));
70-
process.exit(1);
71-
}
20+
const fs = require('fs');
21+
const glob = require('glob');
22+
const path = require('path');
23+
const child_process = require(`child_process`);
24+
const argv = require(`command-line-args`)(cliOpts(), { partial: true });
25+
const gulpPath = require.resolve(path.join(`..`, `node_modules/gulp/bin/gulp.js`));
7226

73-
let jsonPaths = argv.json;
74-
let arrowPaths = argv.arrow;
27+
let jsonPaths = [...(argv.json || [])];
28+
let arrowPaths = [...(argv.arrow || [])];
7529

7630
if (!argv.mode) {
7731
return print_usage();
@@ -89,12 +43,13 @@ if (mode === 'VALIDATE' && !jsonPaths.length) {
8943
if (fs.existsSync(arrowPath)) {
9044
jsonPaths.push(jsonPath);
9145
arrowPaths.push(arrowPath);
92-
console.log('-j', jsonPath, '-a', arrowPath, '\\');
9346
}
9447
}
9548
}
9649
return [jsonPaths, arrowPaths];
9750
}, [[], []]);
51+
console.log(`jsonPaths: [\n\t${jsonPaths.join('\n\t')}\n]`);
52+
console.log(`arrowPaths: [\n\t${arrowPaths.join('\n\t')}\n]`);
9853
}
9954
} else if (!jsonPaths.length) {
10055
return print_usage();
@@ -107,24 +62,61 @@ switch (mode) {
10762
args.push('-j', p, '-a', arrowPaths[i]);
10863
});
10964
process.exitCode = child_process.spawnSync(
110-
gulp, args,
65+
gulpPath, args,
11166
{
11267
cwd: path.resolve(__dirname, '..'),
11368
stdio: ['ignore', 'inherit', 'inherit']
11469
}
11570
).status || process.exitCode || 0;
116-
// for (let i = -1, n = jsonPaths.length; ++i < n;) {
117-
// const jsonPath = jsonPaths[i];
118-
// const arrowPath = arrowPaths[i];
119-
// child_process.spawnSync(
120-
// gulp, args.concat(['-j', jsonPath, '-a', arrowPath]),
121-
// {
122-
// cwd: path.resolve(__dirname, '..'),
123-
// stdio: ['ignore', 'inherit', 'inherit']
124-
// }
125-
// );
126-
// }
12771
break;
12872
default:
12973
print_usage();
13074
}
75+
76+
function cliOpts() {
77+
return [
78+
{
79+
type: String,
80+
name: 'mode',
81+
description: 'The integration test to run'
82+
},
83+
{
84+
type: String,
85+
name: 'arrow', alias: 'a',
86+
multiple: true, defaultValue: [],
87+
description: 'The Arrow file[s] to read/write'
88+
},
89+
{
90+
type: String,
91+
name: 'json', alias: 'j',
92+
multiple: true, defaultValue: [],
93+
description: 'The JSON file[s] to read/write'
94+
}
95+
];
96+
}
97+
98+
function print_usage() {
99+
console.log(require('command-line-usage')([
100+
{
101+
header: 'integration',
102+
content: 'Script for running Arrow integration tests'
103+
},
104+
{
105+
header: 'Synopsis',
106+
content: [
107+
'$ integration.js -j file.json -a file.arrow --mode validate'
108+
]
109+
},
110+
{
111+
header: 'Options',
112+
optionList: [
113+
...cliOpts(),
114+
{
115+
name: 'help',
116+
description: 'Print this usage guide.'
117+
}
118+
]
119+
},
120+
]));
121+
process.exit(1);
122+
}

0 commit comments

Comments
 (0)