You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
Integration tests seem very slow. I presumed it was because of editor instance being spawn once each for each project type - opam, esy and bucklescript. Tried opening the editor instance once by having a unified entry for mocha
// runner.jsconstpath=require("path");const{ runTests }=require("vscode-test");asyncfunctionmain(){try{// The folder containing the Extension Manifest package.json// Passed to `--extensionDevelopmentPath`constextensionDevelopmentPath=path.resolve(__dirname,"../");// The path to the extension test script// Passed to --extensionTestsPathconstextensionTestsPath=path.resolve(__dirname,"./mocha-entry.js");// Download VS Code, unzip it and run the integration testawaitrunTests({
extensionDevelopmentPath,
extensionTestsPath,launchArgs: ["--disable-extensions"]});}catch(err){console.error("Failed to run tests");process.exit(1);}}main();
constpath=require("path");constMocha=require("mocha");constglob=require("glob");functionrun(){// Create the mocha testconstmocha=newMocha({ui: "tdd"});// Use any mocha APImocha.useColors(true);consttestsRoot=path.resolve(__dirname);returnnewPromise((c,e)=>{// Add files to the test suitemocha.addFile(path.resolve(testsRoot,path.resolve(testsRoot,"suite","integration.test.js")));try{// Run the mocha testmocha.run(failures=>{if(failures>0){e(newError(`${failures} tests failed.`));}else{c();}});}catch(err){e(err);}});}module.exports={
run
};
And clubbed the suites, but the test runner would loop indefinitely. Clubbed the test() together in one suite - still indefinite running. Clubbing everything into one test didn't help either
constassert=require("assert");constpath=require("path");constvscode=require("vscode");constos=require("os");constcp=require("child_process");constfs=require("fs-extra");const{ Uri }=vscode;letroot=path.dirname(path.dirname(__dirname));letfixtureSrcDir=path.join(root,"fixtures");suite("Running e2e tests",()=>{test("Esy",async()=>{letsampleEsySrc=path.join(fixtureSrcDir,"sample-esy");letprojectPath=path.join(os.tmpdir(),"sample-esy");letprojectUri=Uri.file(projectPath);fs.copySync(sampleEsySrc,projectPath);cp.execSync("esy",{cwd: projectPath});awaitvscode.commands.executeCommand("vscode.openFolder",projectUri);letreasonDocument=awaitvscode.workspace.openTextDocument(Uri.file(path.join(projectPath,"bin","SampleEsyApp.re")));letocamlDocument=awaitvscode.workspace.openTextDocument(Uri.file(path.join(projectPath,"bin","CamlUtil.ml")));assert.equal(reasonDocument.languageId,"reason","Must be identified as a Reason document");assert.equal(ocamlDocument.languageId,"ocaml","Must be identified as an OCaml document");functiondelay(timeout){returnnewPromise(resolve=>{setTimeout(resolve,timeout);});}awaitdelay(500);letdiagnostics=awaitvscode.languages.getDiagnostics(Uri.file(path.join(projectPath,"bin","SampleEsyApp.re")));if(process.platform!="win32"&&process.platform!="win64"){assert.equal(diagnostics.length,1,"There should only be one diagnostic");assert.equal(diagnostics[0].message,"Warning 26: unused variable foo.");assert.equal(diagnostics[0].severity,1,"Severity of this diagnostic should be 1 (Warning). It was "+diagnostics[0].severity);assert.equal(diagnostics[0].range.start.line,3);assert.equal(diagnostics[0].range.start.character,6);assert.equal(diagnostics[0].range.end.line,3);assert.equal(diagnostics[0].range.end.character,9);}// TODO: the plugin could support build related tasks// const expected = [// { subcommand: "build", group: vscode.TaskGroup.Build },// { subcommand: "run", group: undefined }// ];// const tasks = await vscode.tasks.fetchTasks();console.log("Cleaning up (esy)...");try{fs.removeSync(projectPath);}catch(e){}if(process.platform=="win32"||process.platform=="win64"){return;}letsampleOpamSrc=path.join(fixtureSrcDir,"sample-opam");projectPath=path.join(os.tmpdir(),"sample-opam");letopamRoot=path.join(os.tmpdir(),"opam-root");fs.copySync(sampleOpamSrc,projectPath);cp.execSync(`mkdir -p ${opamRoot}`);letenv=cp.execSync(`sh -c 'opam install . --deps-only --yes > /dev/null; opam env'`,{cwd: projectPath}).toString();letregexpMatch=env.match(/PATH=[^;]+;/g);if(regexpMatch.length>=1){process.env["PATH"]=Array.prototype.reduce.call(regexpMatch,function(acc,pathString){return(acc+pathString.replace(/[;'"]/g,"").split("=")[1].split(":").concat(process.env["PATH"].split("=")[1]).join(":"));},"");}projectUri=Uri.file(projectPath);awaitvscode.commands.executeCommand("vscode.openFolder",projectUri);reasonDocument=awaitvscode.workspace.openTextDocument(Uri.file(path.join(projectPath,"foo.re")));ocamlDocument=awaitvscode.workspace.openTextDocument(Uri.file(path.join(projectPath,"main.ml")));assert.equal(reasonDocument.languageId,"reason","Must be identified as a Reason document");assert.equal(ocamlDocument.languageId,"ocaml","Must be identified as an OCaml document");console.log("Cleaning up (opam)...");try{console.log(" Removing switch");console.log(cp.execSync("opam switch remove e2e --yes").toString());console.log(" Removing test project");fs.removeSync(projectPath);}catch(e){}});// test("Bsb", async () => {// let sampleEsySrc = path.join(fixtureSrcDir, "sample-bsb");// let projectPath = path.join(os.tmpdir(), "sample-bsb");// let projectUri = Uri.file(projectPath);// fs.copySync(sampleEsySrc, projectPath);// cp.execSync("npm i", { cwd: projectPath });// await vscode.commands.executeCommand("vscode.openFolder", projectUri);// let reasonDocument = await vscode.workspace.openTextDocument(// Uri.file(path.join(projectPath, "src", "Lib.re"))// );// let ocamlDocument = await vscode.workspace.openTextDocument(// Uri.file(path.join(projectPath, "src", "main.ml"))// );// assert.equal(// reasonDocument.languageId,// "reason",// "Must be identified as a Reason document"// );// assert.equal(// ocamlDocument.languageId,// "ocaml",// "Must be identified as an OCaml document"// );// function delay(timeout) {// return new Promise(resolve => {// setTimeout(resolve, timeout);// });// }// await delay(500);// let diagnostics = await vscode.languages.getDiagnostics(// Uri.file(path.join(projectPath, "lib", "Lib.re"))// );// assert.equal(diagnostics.length, 0, "There should only be one diagnostic");// // TODO: the plugin could support build related tasks// // const expected = [// // { subcommand: "build", group: vscode.TaskGroup.Build },// // { subcommand: "run", group: undefined }// // ];// // const tasks = await vscode.tasks.fetchTasks();// console.log("Cleaning up...");// try {// fs.removeSync(projectPath);// } catch (e) {}// });});
The text was updated successfully, but these errors were encountered:
Integration tests seem very slow. I presumed it was because of editor instance being spawn once each for each project type -
opam
,esy
andbucklescript
. Tried opening the editor instance once by having a unified entry for mochaAnd clubbed the suites, but the test runner would loop indefinitely. Clubbed the
test()
together in one suite - still indefinite running. Clubbing everything into one test didn't help eitherThe text was updated successfully, but these errors were encountered: