Added setup and teardown for test; add variable to control run python… (#4782)

* Added setup and teardown for test; add variable to control run python/pyspark tests; remove dup code in clearAlloutput tests

* Resolve PR comments
This commit is contained in:
Yurong He
2019-04-02 15:16:54 -07:00
committed by GitHub
parent f8706abebe
commit 22c62fb524
4 changed files with 87 additions and 74 deletions

View File

@@ -73,14 +73,18 @@ export const pythonKernelMetadata = {
}
};
export function writeNotebookToFile(pythonNotebook: azdata.nb.INotebookContents): vscode.Uri {
export function writeNotebookToFile(pythonNotebook: azdata.nb.INotebookContents, testName: string): vscode.Uri {
let fileName = getFileName(testName);
let notebookContentString = JSON.stringify(pythonNotebook);
let localFile = path.join(os.tmpdir(), 'notebook' + Math.floor(Math.random() * 101) + '.ipynb');
while (fs.existsSync(localFile)) {
localFile = path.join(os.tmpdir(), 'notebook' + Math.floor(Math.random() * 101) + '.ipynb');
}
fs.writeFileSync(localFile, notebookContentString);
console.log(`Local file is created: '${localFile}'`);
let uri = vscode.Uri.file(localFile);
fs.writeFileSync(fileName, notebookContentString);
console.log(`Local file is created: '${fileName}'`);
let uri = vscode.Uri.file(fileName);
return uri;
}
export function getFileName(testName: string): string {
if (testName) {
return path.join(os.tmpdir(), testName + '.ipynb');
}
return undefined;
}