Skip to content

Commit

Permalink
[INTERNAL] package.json: Upgrade karma to v5.1.0
Browse files Browse the repository at this point in the history
With karma v5 the internal timings have changed due to switching from
bluebird promises to native promises.
This can causes too many files to be opened, especially on Windows
machines and within projects that contain several thousand files like
the sap.m library.
To mitigate this issue, the testsuite server will be now started before
karma is locating and processing the project files.

Also adds missing src/*/surefire-reports/ to .gitignore

Change-Id: Ic66db044d09c9acbab02b3c28341bb9a6a091ed8
  • Loading branch information
matz3 committed Jul 17, 2020
1 parent 6cb9597 commit e77a49a
Show file tree
Hide file tree
Showing 7 changed files with 630 additions and 387 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ src/*/.gitignore
src/*/target/
src/*/dist/
src/*/coverage/
src/*/surefire-reports/
/target
/tmp

Expand Down
6 changes: 4 additions & 2 deletions lib/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ async function serve(dependencyTree) {
acceptRemoteConnections,
sendSAPTargetCSP: testCsp,
serveCSPReports: testCsp
}).then(({port}) => {
let browserUrl = "http://localhost:" + port;
}).then((server) => {
let browserUrl = "http://localhost:" + server.port;
console.log("TestSuite server started");
if (acceptRemoteConnections) {
console.log("Accepting remote connections");
Expand All @@ -41,6 +41,8 @@ async function serve(dependencyTree) {
} else {
console.log(`URL: ${browserUrl}`);
}

return server;
});
}

Expand Down
31 changes: 21 additions & 10 deletions lib/server/testsuiteServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ const moduleManager = require("./moduleManager");
const server = require("./server");

const openui5Root = path.join(__dirname, "..", "..");
moduleManager.getModules({cwd: openui5Root}).then(async (modules) => {
console.log(`Found ${Object.keys(modules).length} OpenUI5 modules`);
// Always use testsuite as root project
const dependencyTree = modules["@openui5/testsuite"];

return server.serve(dependencyTree);
}).catch(function(err) {
console.error(err);
process.exit(1);
});

async function start() {
const modules = await moduleManager.getModules({cwd: openui5Root});
console.log(`Found ${Object.keys(modules).length} OpenUI5 modules`);
// Always use testsuite as root project
const dependencyTree = modules["@openui5/testsuite"];

return server.serve(dependencyTree);
}

// Start server when this script is executed directly via node
// See: https://nodejs.org/docs/latest/api/modules.html#modules_accessing_the_main_module
if (require.main === module) {
start().catch(function(err) {
console.error(err);
process.exit(1);
});
} else {
// Otherwise export the function to be used somewhere else (e.g. from lib/test/karma.conf.js)
module.exports.start = start;
}
12 changes: 9 additions & 3 deletions lib/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
module.exports = function(config) {
"use strict";

// Run the server (http://localhost:8080)
require("../server/testsuiteServer");

// Entry testsuites of libraries
var testpages = {

Expand Down Expand Up @@ -101,6 +98,15 @@ module.exports = function(config) {

});

// Run the server at http://localhost:8080
// Using a framework plugin to ensure starting it before karma runs the tests
config.plugins.push({
"framework:testsuiteServer": ["factory", function() {
return require("../server/testsuiteServer").start();
}]
});
config.frameworks.push("testsuiteServer");

if (config.lib === "sap.ui.core") {
config.plugins.push({
// When running tests for sap.ui.core we need to ensure that the version placeholder
Expand Down
Loading

0 comments on commit e77a49a

Please sign in to comment.