Skip to content

Commit

Permalink
add support for parallel test cases and example implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Nov 10, 2023
1 parent cd60831 commit e72ec5c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static void deploy(Resource dir, boolean doNew) {
deploy(testDir, testPath, doNew, "LuceeTestSuite");
deploy(testDir, testPath, doNew, "LuceeTestSuiteRunner");
deploy(testDir, testPath, doNew, "LuceeTestCase");
deploy(testDir, testPath, doNew, "LuceeTestCaseParallel");
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
component extends="org.lucee.cfml.test.LuceeTestCase" {


private function parallel(title, threadCount=1, repetitition=1, body) {
if(arguments.threadcount<1 || arguments.threadcount>1000) {
throw "thread count need to be a number between 1 and 1000, now it is [#arguments.threadcount#]";
}
if(arguments.repetitition<1 || arguments.repetitition>1000) {
throw "repetitition need to be a number between 1 and 1000, now it is [#arguments.repetitition#]";
}
if(arguments.threadcount==1 || arguments.repetitition==1) {
throw "repetitition or thread count need to be bigger than 1";
}
var prefix=createUniqueID();
var exceptions = [];
for (var i = 1; i <= arguments.repetitition; i++) {
var names = [];
for (var y = 1; y <= arguments.threadcount; y++) {
var name="testThread-#prefix#:#i#:#y#";
arrayAppend(names, name);
thread action="run" name=name title=arguments.title body=arguments.body exceptions=exceptions {
try {
it(title,body);
}
catch(e) {
arrayAppend(exceptions, e);
}
}
}
thread action="join" name=arrayToList(names);
}
}
}
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.0.1.22-SNAPSHOT"/>
<property name="version" value="6.0.1.23-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.0.1.22-SNAPSHOT</version>
<version>6.0.1.23-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down
4 changes: 2 additions & 2 deletions test/functions/xmlNew.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component extends="org.lucee.cfml.test.LuceeTestCase" {
component extends="org.lucee.cfml.test.LuceeTestCaseParallel" {
function run( testResults , testBox ) {
describe( title = "Testcase for xmlNew() function", body = function() {
it( title = "checking xmlNew() function", body = function( currentSpec ) {
parallel( title = "checking xmlNew() function",threadCount=5, repetitition=2, body = function( currentSpec ) {
var XmlDocument = xmlNew();
XMLDocument.XmlRoot = "element";

Expand Down

0 comments on commit e72ec5c

Please sign in to comment.