Skip to content

Commit 321b19d

Browse files
committed
try to make CI more robust
1 parent fb5c8c2 commit 321b19d

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

scripts/ciTest.js

+22-23
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ if (all) {
4141
bsbTest = true;
4242
}
4343

44-
4544
var fs = require("fs");
4645

47-
4846
function init() {
4947
var vendorOCamlPath = path.join(
5048
__dirname,
@@ -72,14 +70,13 @@ function main() {
7270
// console.log('OCaml:', output)
7371
var binDir = path.join(__dirname, "..", "jscomp", "bin");
7472
if (ounitTest) {
75-
7673
// running tests for native code
7774
fs.copyFileSync(
7875
path.join(
7976
__dirname,
8077
"..",
8178
"lib",
82-
'4.06.1',
79+
"4.06.1",
8380
"unstable",
8481
"all_ounit_tests.ml"
8582
),
@@ -95,15 +92,15 @@ function main() {
9592
cp.execSync(`./test.exe`, { cwd: binDir, stdio: [0, 1, 2] });
9693
}
9794

98-
// running generated js tests
95+
// running generated js tests
9996
if (mochaTest) {
10097
cp.execSync(`mocha jscomp/test/**/*test.js`, {
10198
cwd: path.join(__dirname, ".."),
10299
stdio: [0, 1, 2]
103100
});
104101
}
105102

106-
// set up global directory properly using
103+
// set up global directory properly using
107104
// npm config set prefix '~/.npm-global'
108105
if (installGlobal) {
109106
console.log("install bucklescript globally");
@@ -132,9 +129,9 @@ function main() {
132129
.filter(x => x);
133130
var themesDir = path.join(__dirname, "..", "themes");
134131

135-
if(fs.existsSync(themesDir)){
132+
if (fs.existsSync(themesDir)) {
136133
// fs.rmdirSync(themesDir,{recursive : true})
137-
cp.execSync(`rm -rf ${themesDir}`,{stdio:[0,1,2]})
134+
cp.execSync(`rm -rf ${themesDir}`, { stdio: [0, 1, 2] });
138135
// we dont remove post-installation
139136
// since it is useful for debugging
140137
}
@@ -149,19 +146,21 @@ function main() {
149146
if (error !== null) {
150147
throw new Error(`init theme ${theme} failed`);
151148
}
152-
cp.exec(
153-
`npm link bs-platform && npm install && npm run clean && npm run build`,
154-
{ cwd: path.join(themesDir, theme) },
155-
function(error, stdout, stderr) {
156-
console.log(stdout);
157-
console.log(stderr);
158-
if (error !== null) {
159-
throw new Error(
160-
`clean && install & build theme ${theme} failed`
161-
);
162-
}
163-
}
164-
);
149+
let config = {
150+
cwd: path.join(themesDir, theme),
151+
encoding: "utf8"
152+
};
153+
var output ;
154+
try {
155+
output = cp.execSync(`npm link bs-platform`, config);
156+
output = cp.execSync(`npm install`, config);
157+
output = cp.execSync(`npm run clean`, config);
158+
output = cp.execSync(`npm run build`, config);
159+
} catch (err) {
160+
console.error(`failed in theme ${theme}`)
161+
console.log(output+"")
162+
console.log(err + "")
163+
}
165164
}
166165
);
167166
});
@@ -178,8 +177,8 @@ function main() {
178177
var files = fs.readdirSync(buildTestDir);
179178
files.forEach(function(file) {
180179
var testDir = path.join(buildTestDir, file);
181-
if(file === 'node_modules' || !fs.lstatSync(testDir).isDirectory()){
182-
return
180+
if (file === "node_modules" || !fs.lstatSync(testDir).isDirectory()) {
181+
return;
183182
}
184183
if (!fs.existsSync(path.join(testDir, "input.js"))) {
185184
console.warn(`input.js does not exist in ${testDir}`);

0 commit comments

Comments
 (0)