-
-
Notifications
You must be signed in to change notification settings - Fork 5
v2 test runner #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
v2 test runner #46
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
777830f
v2 test runner
BNAndras 0f95c46
Update dockerignore
BNAndras 0709533
Fix stale expected results
BNAndras e70b4d8
Pin to specific version
BNAndras 42a4c36
revert changes to Docker run and build commands
BNAndras 7c4c1e1
Apply edits to DNS lookup issue
BNAndras f311cf8
Simplify script dir detection
BNAndras cf0d40b
Revert changes to diff checking
BNAndras 44c3689
Fix script_dir path
BNAndras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| tests/**/results.json | ||
| tests/**/testbox/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| solutionPath = server.cli.parsed.positionals[ 1 ]; | ||
| resultsPath = server.cli.parsed.positionals[ 2 ]; | ||
|
|
||
| try { | ||
| userHome = server.system.properties[ "user.home" ]; | ||
| mappings = getApplicationMetadata().mappings; | ||
| mappings[ "/solution" ] = solutionPath; | ||
| mappings[ "/testbox" ] = userHome & "/.boxlang/modules/testbox"; | ||
|
|
||
| testBox = new testbox.system.TestBox(); | ||
| testFiles = directoryList( solutionPath, false, "name", "*Test.cfc" ); | ||
| for ( file in testFiles ) { | ||
| testBox.addBundles( "solution." & file.listFirst( "." ) ); | ||
| } | ||
|
|
||
| results = testBox.runRaw().getMemento(); | ||
| bundleStats = results.bundleStats ?: []; | ||
|
|
||
| status = "pass"; | ||
| message = ""; | ||
| tests = []; | ||
|
|
||
| for ( bundle in bundleStats ) { | ||
| if ( structKeyExists( bundle, "globalException" ) && !isSimpleValue( bundle.globalException ) ) { | ||
| status = "error"; | ||
| message = ( bundle.globalException.message ?: "Bundle compilation error" ).replace( solutionPath, "/solution", "ALL" ); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if ( status != "error" ) { | ||
| if ( ( results.totalBundles ?: 0 ) == 0 ) { | ||
| status = "error"; | ||
| message = "No tests found"; | ||
| } else { | ||
| // Read test file contents | ||
| for ( bundle in bundleStats ) { | ||
| testFileName = bundle.name.listLast( "." ) & ".cfc"; | ||
| filePath = solutionPath & "/" & testFileName; | ||
| fileContent = fileExists( filePath ) ? fileRead( filePath ) : ""; | ||
| collectSpecs( bundle.suiteStats ?: [], tests, fileContent ); | ||
| } | ||
| if ( ( results.totalFail ?: 0 ) > 0 || ( results.totalError ?: 0 ) > 0 ) { | ||
| status = "fail"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| output = { "version": 2, "status": status }; | ||
| if ( message.len() ) { | ||
| output[ "message" ] = message; | ||
| } | ||
| if ( tests.len() ) { | ||
| output[ "tests" ] = tests; | ||
| } | ||
|
|
||
| fileWrite( resultsPath & "/results.json", jsonSerialize( output ) ); | ||
|
|
||
| } catch ( any e ) { | ||
| errMessage = e.message.replace( solutionPath, "/solution", "ALL" ); | ||
| fileWrite( resultsPath & "/results.json", | ||
| jsonSerialize( { "version": 2, "status": "error", "message": errMessage } ) ); | ||
| } | ||
|
|
||
| // Recursively collect specs | ||
| function collectSpecs( required array suites, required array tests, required string fileContent ) { | ||
| for ( var suite in suites ) { | ||
| for ( var spec in ( suite.specStats ?: [] ) ) { | ||
| var specStatus = ( spec.status ?: "failed" ).lCase(); | ||
| var testResult = { | ||
| "name": spec.name ?: "Unknown", | ||
| "status": specStatus == "passed" ? "pass" : ( specStatus == "failed" ? "fail" : "error" ), | ||
| "test_code": extractTestCode( fileContent, spec.name ?: "" ) | ||
| }; | ||
| if ( testResult.status != "pass" && ( spec.failMessage ?: "" ).len() ) { | ||
| testResult[ "message" ] = spec.failMessage; | ||
| } | ||
| tests.append( testResult ); | ||
| } | ||
| if ( structKeyExists( suite, "suiteStats" ) && suite.suiteStats.len() ) { | ||
| collectSpecs( suite.suiteStats, tests, fileContent ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Extract the body of an it() block | ||
| function extractTestCode( required string fileContent, required string testName ) { | ||
| if ( !fileContent.len() || !testName.len() ) return ""; | ||
|
|
||
| var lines = fileContent.listToArray( char( 10 ) ); | ||
| var depth = 1; | ||
| var found = false; | ||
| var body = []; | ||
|
|
||
| for ( var line in lines ) { | ||
| if ( !found ) { | ||
| if ( line.reFind( "it\(\s*['""]" & testName & "['""]" ) > 0 && line.find( "{" ) > 0 ) { | ||
| found = true; | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| for ( var ch in line.listToArray( "" ) ) { | ||
| if ( ch == "{" ) depth++; | ||
| if ( ch == "}" ) depth--; | ||
| } | ||
| if ( depth <= 0 ) break; | ||
| body.append( line ); | ||
| } | ||
|
|
||
| return trim( body.toList( char( 10 ) ) ); | ||
| } |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| component extends="testbox.system.BaseSpec" { | ||
|
|
||
| function beforeAll(){ | ||
| SUT = createObject( 'ErrorIfEmptyFile' ); | ||
| } | ||
|
|
||
| function run(){ | ||
|
|
||
| describe( 'ErrorIfEmptyFile', function(){ | ||
|
|
||
| it( 'This should error', function(){ | ||
| expect( SUT.alwaysTrue() ).toBeTrue(); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "message": "Error compiling [ /solution/ErrorIfEmptyFile.cfc ]. /solution/ErrorIfEmptyFile.cfc: Line: 1 Col: 0 - '<EOF>' was unexpected \nexpecting one of: 'abstract', 'final', Operator, Statement\n\n", | ||
| "version": 2, | ||
| "status": "error" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| componentTTT@@ clazzzz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| component extends="testbox.system.BaseSpec" { | ||
|
|
||
| function beforeAll(){ | ||
| SUT = createObject( 'ErrorIfSyntaxError' ); | ||
| } | ||
|
|
||
| function run(){ | ||
|
|
||
| describe( 'ErrorIfSyntaxError', function(){ | ||
|
|
||
| it( 'This will error out', function(){ | ||
| expect( SUT.alwaysTrue() ).toBeTrue(); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "message": "Error compiling [ /solution/ErrorIfSyntaxError.cfc ]. /solution/ErrorIfSyntaxError.cfc: Line: 1 Col: 0 - 'componentTTT' was unexpected \nexpecting one of: 'abstract', 'final', Operator, Statement\ncomponentTTT@@ clazzzz\n^^^^^^^^^^^^", | ||
| "version": 2, | ||
| "status": "error" | ||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.