Skip to content

Commit

Permalink
wip on getting BoxLang certified and running with BX classes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Sep 4, 2024
1 parent 5ed5afe commit 5e85ad1
Show file tree
Hide file tree
Showing 17 changed files with 472 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/settings.xml
.settings/
.engine/
grapher/**

# Test Results
tests/results/**
Expand Down
13 changes: 7 additions & 6 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"cfengine":"boxlang@be",
"serverHomeDirectory":".engine/boxlang"
},
"name":"coldbox-boxlang",
"name":"testbox-boxlang",
"force":true,
"openBrowser":false,
"web":{
Expand All @@ -19,15 +19,16 @@
}
},
"JVM":{
"heapSize":"1024"
"heapSize":"1024",
"javaVersion":"openjdk21_jdk"
},
"cfconfig":{
"file":".cfconfig.json"
},
"env":{
"BOXLANG_DEBUG": true
"BOXLANG_DEBUG":true
},
"scripts" : {
"onServerInitialInstall":"install bx-compat"
}
"scripts":{
"onServerInitialInstall":"install bx-compat,bx-unsafe-evaluate"
}
}
2 changes: 1 addition & 1 deletion system/Assertion.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ component {
}
// diff message types
arguments.message = (
len( arguments.message ) ? arguments.message : "The incoming function threw exception [#e.type#] [#e.message#] [#e.detail#] different than expected params type=[#arguments.type#], regex=[#arguments.regex#]"
len( arguments.message ) ? arguments.message : "The incoming function threw exception [type: #e.type#] [message: #e.message#] [#e.detail#] different than expected params type=[#arguments.type#], regex=[#arguments.regex#]"
);
detail = e.stackTrace;
}
Expand Down
27 changes: 18 additions & 9 deletions system/TestBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ component accessors="true" {
property name="coverageService";
// TestBox Modules Registry
property name="modules";
// A list of globbing patterns to match bundles to test ONLY! Ex: *Spec,*Test
// A list of globbing patterns to match bundles to test ONLY! Ex: *Spec|*Test
property name="bundlesPattern";

// Constants
variables.TESTBOX_PATH = expandPath( "/testbox" );
variables.IS_BOXLANG = server.keyExists( "boxlang" );

/**
* Constructor
Expand All @@ -54,14 +55,14 @@ component accessors="true" {
any labels = [],
any excludes = [],
struct options = {},
string bundlesPattern = "*.cfc"
string bundlesPattern = "*.bx|*.cfc"
){
// TestBox version
variables.version = "@build.version@[email protected]@";
variables.codename = "";
// Bundles pattern
if ( !len( arguments.bundlesPattern ) ) {
arguments.bundlesPattern = "*.cfc";
arguments.bundlesPattern = "*.bx|*.cfc";
}
variables.bundlesPattern = arguments.bundlesPattern;
// Utility and mappings
Expand Down Expand Up @@ -820,7 +821,8 @@ component accessors="true" {
* @directory The directory information struct to test: [ mapping = the path to the directory using dot notation (myapp.testing.specs), recurse = boolean, filter = closure that receives the path of the class found, it must return true to process or false to continue process ]
*/
private function getSpecPaths( required directory ){
var results = [];
var results = [];
var pathPatternMatcher = new testbox.system.modules.globber.models.PathPatternMatcher();

// recurse default
arguments.directory.recurse = (
Expand All @@ -835,9 +837,12 @@ component accessors="true" {
bundleExpandedPath,
arguments.directory.recurse,
"path",
variables.bundlesPattern,
"asc"
);
"",
"asc",
"file"
).filter( ( path ) => {
return pathPatternMatcher.matchPatterns( variables.bundlesPattern.listToArray( "|" ), path );
} );

// cleanup paths and store them for usage
for ( var x = 1; x lte arrayLen( bundlesFound ); x++ ) {
Expand All @@ -850,9 +855,14 @@ component accessors="true" {
continue;
}

// If not in BoxLang, skip bx bundles
if ( !variables.IS_BOXLANG and bundlesFound[ x ].listLast( "." ) eq "bx" ) {
continue;
}

// standardize paths
bundlesFound[ x ] = reReplace(
replaceNoCase( bundlesFound[ x ], ".cfc", "" ),
reReplaceNoCase( bundlesFound[ x ], "\.(bx|cfc)", "" ),
"(\\|/)",
"/",
"all"
Expand All @@ -861,7 +871,6 @@ component accessors="true" {
bundlesFound[ x ] = replace( bundlesFound[ x ], bundleExpandedPath, "" );
// Clean out slashes and append the mapping.
bundlesFound[ x ] = arguments.directory.mapping & reReplace( bundlesFound[ x ], "(\\|/)", ".", "all" );

arrayAppend( results, bundlesFound[ x ] );
}

Expand Down
4 changes: 2 additions & 2 deletions system/TestResult.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ component accessors="true" {
variables.coverageData = {};

// CFML Engine + Version
variables.CFMLEngine = server.coldfusion.productName;
variables.CFMLEngine = server.keyExists( "boxlang" ) ? "BoxLang" : server.coldfusion.productName;
variables.CFMLEngineVersion = (
structKeyExists( server, "lucee" ) ? server.lucee.version : server.coldfusion.productVersion
server.keyExists( "boxlang" ) ? server.boxlang.version : server.keyExists( "lucee" ) ? server.lucee.version : server.coldfusion.productVersion
);

return this;
Expand Down
5 changes: 5 additions & 0 deletions system/mockutils/MockGenerator.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,14 @@ A mock generator
udfOut.append( "</cffunction>#instance.lb#" );
}

writeDump( var = arguments.md, top = 10 );

// Check extends and recurse
if ( structKeyExists( arguments.md, "extends" ) ) {
for ( var thisKey in arguments.md.extends ) {
writeDump( var = thisKey, top = 10 );
writeDump( var = arguments.md.extends[ thisKey ], top = 10 );
abort;
generateMethodsFromMD( udfOut, arguments.md.extends[ thisKey ] );
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/runners/HTMLRunner.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<cfparam name="url.reportpath" default="">
<cfparam name="url.propertiesFilename" default="TEST.properties">
<cfparam name="url.propertiesSummary" default="false" type="boolean">
<cfparam name="url.bundlesPattern" default="*.cfc">
<cfparam name="url.bundlesPattern" default="*.bx|*.cfc">

<cfparam name="url.coverageEnabled" default="false" type="boolean">
<cfparam name="url.coverageSonarQubeXMLOutputPath" default="">
Expand Down
2 changes: 1 addition & 1 deletion test-browser/index.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</cfoutput>
</div>
</div>
<!--- Listing --->
<div class="row">
<div class="col-md-12">
Expand Down
4 changes: 2 additions & 2 deletions test-harness/runner.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<cfparam name="url.propertiesFilename" default="TEST.properties">
<cfparam name="url.propertiesSummary" default="false" type="boolean">
<cfparam name="url.editor" default="vscode">
<cfparam name="url.bundlesPattern" default="*Spec*.cfc|*Test*.cfc">
<cfparam name="url.bundlesPattern" default="*Spec*.cfc|*Test*.cfc|*Spec*.bx|*Test*.bx">

<!--- Code Coverage requires FusionReactor --->
<cfparam name="url.coverageEnabled" default="true">
<cfparam name="url.coveragePathToCapture" default="#expandPath( '/root' )#">
<cfparam name="url.coverageWhitelist" default="">
<cfparam name="url.coverageBlacklist" default="/testbox,/coldbox,/tests,/modules,Application.cfc,/index.cfm">
<cfparam name="url.coverageBlacklist" default="/testbox,/coldbox,/tests,/modules,Application.cfc,/index.cfm,Application.bx,/index.bxm">
<!---<cfparam name="url.coverageBrowserOutputDir" default="#expandPath( '/tests/results/coverageReport' )#">--->
<!---<cfparam name="url.coverageSonarQubeXMLOutputPath" default="#expandPath( '/tests/results/SonarQubeCoverage.xml' )#">--->
<!--- Enable batched code coverage reporter, useful for large test bundles which require spreading over multiple testbox run commands. --->
Expand Down
2 changes: 1 addition & 1 deletion test-runner/index.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<cfparam name="url.propertiesFilename" default="TEST.properties">
<cfparam name="url.propertiesSummary" default="false" type="boolean">
<cfparam name="url.editor" default="vscode">
<cfparam name="url.bundlesPattern" default="*Spec*.cfc|*Test*.cfc">
<cfparam name="url.bundlesPattern" default="*Spec*.cfc|*Test*.cfc|*Spec*.bx|*Test*.bx">

<cfparam name="url.coverageEnabled" default="false">
<cfparam name="url.coverageSonarQubeXMLOutputPath" default="">
Expand Down
1 change: 0 additions & 1 deletion tests/coverageReport.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/runner.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<cfparam name="url.coverageSonarQubeXMLOutputPath" default="">
<cfparam name="url.coveragePathToCapture" default="#expandPath( '/testbox/system/' )#">
<cfparam name="url.coverageWhitelist" default="">
<cfparam name="url.coverageBlacklist" default="/stubs/**,/modules/**,/coverage/**,Application.cfc">
<cfparam name="url.coverageBlacklist" default="/stubs/**,/modules/**,/coverage/**,Application.cfc,Application.bx">

<!--- FYI the "coverageBrowserOutputDir" folder will be DELETED and RECREATED each time
you generate the report. Don't point this setting to a folder that has other important
Expand Down
4 changes: 0 additions & 4 deletions tests/runners/cf9runner.cfm

This file was deleted.

2 changes: 1 addition & 1 deletion tests/specs/AssertionsTest.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component
displayName="TestBox xUnit suite for cf10 and above"
labels ="lucee,cf"
extends ="Assertionscf9Test"
extends ="BaseAssertionsTest"
{

function beforeTests(){
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/BDDTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ component extends="testbox.system.BaseSpec" {

it( "can validate instance types", function(){
expect( this ).toBeInstanceOf( "testbox.system.BaseSpec" );
expect( now() ).toBeInstanceOf( "java.util.Date" );
expect( createObject( "java", "java.util.Date" ).init() ).toBeInstanceOf( "java.util.Date" );
expect( [] ).toBeInstanceOf( "java.util.List" );
expect( {} ).toBeInstanceOf( "java.util.Map" );
expect( queryNew( "" ) ).notToBeInstanceOf( "Query" );
expect( [] ).notToBeInstanceOf( "Query" );
} );

it( "can validate json", function(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
component
displayName="TestBox xUnit suite for CF9"
labels ="lucee,cf"
extends ="testbox.system.BaseSpec"
{
component labels="lucee,cf" extends="testbox.system.BaseSpec" {

/*********************************** LIFE CYCLE Methods ***********************************/

Expand Down Expand Up @@ -133,7 +129,8 @@ component

$assert.isEqual( f1, f1 );

$assert.isEqual( new testbox.system.MockBox(), new testbox.system.MockBox() );
var target = new testbox.system.MockBox();
$assert.isEqual( target, target );

var xmlString = "<root><item attr=""value"" /><item attr=""again"" /></root>";
$assert.isEqual( xmlParse( xmlString ), xmlParse( xmlString ) );
Expand Down
Loading

0 comments on commit 5e85ad1

Please sign in to comment.