Simple fixes for the tests

This commit is contained in:
Mohamed Hegazy
2014-09-11 09:22:27 -07:00
parent 7439ee35ba
commit 1f2a2d2ae3
2 changed files with 46 additions and 41 deletions

View File

@@ -33,44 +33,44 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re
fs.mkdirSync(testDirectoryPath);
child_process.exec(cmd, {
maxBuffer: 1 * 1024 * 1024,
cwd: testDirectoryPath
}, (error, stdout, stderr) => {
//console.log("importing " + testCaseName + " ...");
//console.log(cmd);
if (error) {
console.log("importing " + testCaseName + " ...");
console.log(cmd);
console.log("==> error " + JSON.stringify(error));
console.log("==> stdout " + String(stdout));
console.log("==> stderr " + String(stderr));
console.log("\r\n");
return;
}
// copy generated file to output location
var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
copyFileSync(outputFilePath, testCasePath);
//console.log("output generated at: " + outputFilePath);
if (!fs.existsSync(testCasePath)) {
throw new Error("could not find test case at: " + testCasePath);
}
else {
fs.unlinkSync(outputFilePath);
fs.rmdirSync(testDirectoryPath);
//console.log("testcase generated at: " + testCasePath);
//console.log("Done.");
}
//console.log("\r\n");
})
.on('error', function (error) {
console.log("==> error " + JSON.stringify(error));
console.log("\r\n");
maxBuffer: 1 * 1024 * 1024,
cwd: testDirectoryPath
}, (error, stdout, stderr) => {
console.log("importing " + testCaseName + " ...");
console.log(cmd);
if (error) {
console.log("importing " + testCaseName + " ...");
console.log(cmd);
console.log("==> error " + JSON.stringify(error));
console.log("==> stdout " + String(stdout));
console.log("==> stderr " + String(stderr));
console.log("\r\n");
return;
}
// copy generated file to output location
var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
copyFileSync(outputFilePath, testCasePath);
//console.log("output generated at: " + outputFilePath);
if (!fs.existsSync(testCasePath)) {
throw new Error("could not find test case at: " + testCasePath);
}
else {
fs.unlinkSync(outputFilePath);
fs.rmdirSync(testDirectoryPath);
//console.log("testcase generated at: " + testCasePath);
//console.log("Done.");
}
//console.log("\r\n");
})
.on('error', function (error) {
console.log("==> error " + JSON.stringify(error));
console.log("\r\n");
});
}
@@ -79,7 +79,8 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void {
if (err) throw err;
subDirectorys
.filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) >= 0)
.filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0)
.filter(i => i.indexOf("sipml") >=0 )
.filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
.forEach(d => {
var directoryPath = path.join(definitelyTypedRoot, d);

View File

@@ -227,11 +227,15 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons
send('success', res, null);
break;
case RequestType.DeleteFile:
fs.unlinkSync(reqPath);
if (fs.existsSync(reqPath)) {
fs.unlinkSync(reqPath);
}
send('success', res, null);
break;
case RequestType.DeleteDir:
fs.rmdirSync(reqPath);
if (fs.existsSync(reqPath)) {
fs.rmdirSync(reqPath);
}
send('success', res, null);
break;
case RequestType.AppendFile: