Skip to content
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

Beta #121

Merged
merged 87 commits into from
May 18, 2021
Merged

Beta #121

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
81b9e8f
first stab at moving over to ropm
georgejecook Sep 27, 2020
3bba97a
rewrite for rooibos v4
georgejecook Sep 28, 2020
3ac11bd
groups are back
georgejecook Sep 28, 2020
32faa19
refactoring to reflect new plugin-driven pattenr
georgejecook Oct 4, 2020
bc1398a
rename get all method
georgejecook Oct 5, 2020
81f4ed9
tweaks running
georgejecook Oct 5, 2020
e171a33
imports plugin code into main repo - the framework and plugin sitting…
georgejecook Oct 13, 2020
3804b07
moves stub project to plugin tests
georgejecook Oct 14, 2020
3badb61
more moving stuff about; fixing runtime problems after overhaul
georgejecook Oct 15, 2020
cab1266
adds linting and testing setup. Thanks Bronley Plumb
georgejecook Oct 15, 2020
879076b
fixes annotation issues caused by reflection
georgejecook Oct 15, 2020
30cfd5a
adds a bunch of tests for basic annotation, suite, group parsing
georgejecook Oct 15, 2020
004a917
fixes remaining group tag tests
georgejecook Oct 15, 2020
96d9cd8
adds param parsing tests
georgejecook Oct 15, 2020
9621510
various fixes - expects can now do 15 args
georgejecook Oct 23, 2020
ab03990
feat(logs): Adds settings for controlling log ouput width
georgejecook Oct 24, 2020
88b0b96
chore(build):Use correct bsc
georgejecook Oct 24, 2020
d214a9f
fix(assertions): Fix missing message
georgejecook Oct 24, 2020
6144cc2
feat(mocks): Can now include 15 params
georgejecook Oct 24, 2020
9b098a3
chore(tests): misc changes to tests project
georgejecook Oct 24, 2020
bf24bc5
minor fixes
georgejecook Nov 12, 2020
86b8f18
minor fixes
georgejecook Nov 12, 2020
ede613c
fixes various compiler issues
georgejecook Jan 5, 2021
ea6652b
updated documentation
georgejecook Jan 5, 2021
a1884aa
updateds to use sync api in bs
georgejecook Jan 18, 2021
06dd016
fixes runtime crash
georgejecook Jan 21, 2021
72e14dc
tidies up project, and adds plugin tests
georgejecook Jan 22, 2021
d5bbf19
finally fixes linting issue
georgejecook Jan 22, 2021
b2370a1
fixes missing roku-deploy
georgejecook Jan 22, 2021
1b42315
adds missing nyc package
georgejecook Jan 22, 2021
8e24fe7
add github workflow
georgejecook Jan 22, 2021
cdebce2
Merge branch 'master' into beta
georgejecook Jan 22, 2021
b1f3256
updated to latest bsc
georgejecook Jan 22, 2021
9fc55e4
updated to latest bsc
georgejecook Jan 22, 2021
79b804f
adds ability to inject main when none is present (to make it easier t…
georgejecook Jan 22, 2021
363b62c
remove erroneous duplicate files that got in via a merge
georgejecook Jan 22, 2021
6a2dbb7
fix linting error
georgejecook Jan 22, 2021
bcc32b9
linting fixes
georgejecook Jan 23, 2021
4edd61c
can filter the files to process for unit test searching
georgejecook Jan 23, 2021
7788db5
imrpoves log output with better file links
georgejecook Jan 23, 2021
2f8d58f
minor tweak to line numbers
georgejecook Jan 23, 2021
e12be0c
no longer have to type method names for tests - the annotation name i…
georgejecook Jan 23, 2021
a74811c
fixes @ignore not working, and improves tag behaviour
georgejecook Feb 2, 2021
56d0063
fixes tests
georgejecook Feb 9, 2021
3ee9dd2
some project tidying
georgejecook Feb 9, 2021
e4e62c0
tidy up package, remove test project
georgejecook Feb 9, 2021
3d03577
add support for catching crashes
georgejecook Feb 10, 2021
ecf69ab
update package version
georgejecook Feb 10, 2021
5c3758b
fixes @nocatch annottation
georgejecook Feb 11, 2021
b33f1dc
fixes @nocatch annottation again
georgejecook Feb 11, 2021
0033512
feat:adds crash resistence to suite functions like beforeEach and aft…
georgejecook Feb 11, 2021
f80d19b
feat: improves handling of errors in assertions
georgejecook Feb 12, 2021
54a8c38
fix couple of minor issues in reporting
georgejecook Feb 15, 2021
12e146e
version bounce
georgejecook Feb 15, 2021
35ac8ae
version bounce
georgejecook Feb 15, 2021
32dc45f
fix: fixes crash in console report
georgejecook Feb 16, 2021
b6c1537
version bounce
georgejecook Feb 16, 2021
d95a506
bunch of fixes
georgejecook Feb 23, 2021
f349941
bump to 4.1.1
georgejecook Feb 23, 2021
c033761
adds scripts for easy remote/local npm switching
georgejecook Feb 24, 2021
7d2c187
compile against latest bsc
georgejecook Mar 1, 2021
58d3c7a
doc improvements
georgejecook Mar 2, 2021
d5dcfbc
update docs
georgejecook Mar 3, 2021
d0cc5fe
update docs
georgejecook Mar 3, 2021
b9e184d
adds setFields to mockNode
georgejecook Mar 4, 2021
01b2b95
doc update
georgejecook Mar 4, 2021
715aed1
adds info on missing tags and options
georgejecook Mar 7, 2021
717777d
fixes issue that caused strange breakpoint behaviour on assertions
georgejecook Mar 7, 2021
ef0fa97
more doc improvements
georgejecook Mar 7, 2021
297836b
fix(plugin): Update to bsc 37.4
georgejecook Apr 22, 2021
e2fd357
feat(TestSuite): Adds @noearlyexit annotation, to allow unit tests to…
georgejecook Apr 22, 2021
867acc9
fix(plugin): Fixes node class generation
georgejecook Apr 22, 2021
7008e9d
fix(framework): Fixes framework tests
georgejecook Apr 22, 2021
fd8b43c
fix(ConsoleTestReporter): Fixes issue that showed success/fail messag…
georgejecook Apr 22, 2021
fe1d2f4
docs: Adds docs for @noEarlyExit
georgejecook Apr 22, 2021
a5dc306
version bump
georgejecook Apr 22, 2021
530dd06
show crash count in output
georgejecook Apr 22, 2021
92f05a8
chore: indentation fix
georgejecook Apr 23, 2021
ac24938
chore: ignore dist folder
georgejecook Apr 23, 2021
f1aa90d
chore(build): adds launch tasks for tests in base project
georgejecook Apr 23, 2021
5fb340c
try to fix bsc-yml
georgejecook Apr 30, 2021
65feb83
try to fix bsc-yml
georgejecook Apr 30, 2021
4a0169b
try to fix bsc-yml
georgejecook Apr 30, 2021
cf5fcdd
try to fix bsc-yml
georgejecook Apr 30, 2021
34084d2
try to fix bsc-yml
georgejecook Apr 30, 2021
5b1aaad
improves default config, ensures times are printed on tests
georgejecook May 18, 2021
73a1cf3
Merge branch 'beta' of github.com:georgejecook/rooibos into beta
georgejecook May 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add support for catching crashes
  • Loading branch information
georgejecook committed Feb 10, 2021
commit 3d03577973593d338deaeff2e6f08d7b2595b859
20 changes: 14 additions & 6 deletions bsc-plugin/src/lib/rooibos/Annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export enum AnnotationType {
Params = 'params',
IgnoreParams = 'ignoreparams',
SoloParams = 'onlyparams',
Tags = 'tags'
Tags = 'tags',
NoCatch = 'nocatch'
}

let annotationLookup = {
Expand All @@ -33,7 +34,8 @@ let annotationLookup = {
params: AnnotationType.Params,
ignoreparams: AnnotationType.IgnoreParams,
onlyparams: AnnotationType.SoloParams,
tags: AnnotationType.Tags
tags: AnnotationType.Tags,
nocatch: AnnotationType.NoCatch
};

interface ParsedComment {
Expand All @@ -49,7 +51,8 @@ export class AnnotationParams {
public lineNumber: number,
public params: any[],
public isIgnore = false,
public isSolo = false
public isSolo = false,
public noCatch = false,
) {

}
Expand All @@ -69,7 +72,8 @@ export class RooibosAnnotation {
public isSolo = false,
public params: AnnotationParams[] = [],
public nodeName?: string,
rawTags: string[] = []
rawTags: string[] = [],
public noCatch = false
) {
this.tags = new Set<string>(rawTags);
}
Expand All @@ -83,6 +87,7 @@ export class RooibosAnnotation {
let testAnnotation: RooibosAnnotation;
let isSolo = false;
let isIgnore = false;
let noCatch = false;
let nodeName = null;
let tags = [];
if (statement.annotations?.length) {
Expand All @@ -95,6 +100,9 @@ export class RooibosAnnotation {
for (let annotation of statement.annotations) {
const annotationType = getAnnotationType(annotation.name);
switch (annotationType) {
case AnnotationType.NoCatch:
noCatch = true;
break;
case AnnotationType.Solo:
isSolo = true;
break;
Expand All @@ -116,7 +124,7 @@ export class RooibosAnnotation {
case AnnotationType.Describe:
case AnnotationType.TestSuite:
const groupName = annotation.getArguments()[0] as string;
blockAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, groupName, isIgnore, isSolo, null, nodeName, tags);
blockAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, groupName, isIgnore, isSolo, null, nodeName, tags, noCatch);
nodeName = null;
isSolo = false;
isIgnore = false;
Expand All @@ -126,7 +134,7 @@ export class RooibosAnnotation {
if (!testName || testName.trim() === '') {
diagnosticNoTestNameDefined(file, annotation);
}
let newAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, testName, isIgnore, isSolo, undefined, undefined, tags);
let newAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, testName, isIgnore, isSolo, undefined, undefined, tags, noCatch);
if (testAnnotation) {
diagnosticMultipleTestOnFunctionDefined(file, newAnnotation.annotation);
} else {
Expand Down
1 change: 1 addition & 0 deletions bsc-plugin/src/lib/rooibos/RooibosConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export interface RooibosConfig {
lineWidth?: number;
includeFilters?: string[];
tags?: string[];
catchCrashes?: boolean;
}
1 change: 1 addition & 0 deletions bsc-plugin/src/lib/rooibos/RooibosSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ end function`);
"lineWidth": ${this.config.lineWidth || 60}
"printLcov": ${this.config.printLcov ? 'true' : 'false'}
"port": "${this.config.port || 'invalid'}"
"catchCrashes": ${this.config.catchCrashes ? 'true' : 'false'}
}`));
}
}
Expand Down
1 change: 1 addition & 0 deletions bsc-plugin/src/lib/rooibos/TestCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class TestCase {
return `
{
isSolo: ${this.isSolo}
noCatch: ${this.annotation.noCatch}
funcName: "${this.funcName || ''}"
isIgnored: ${this.isIgnored}
isParamTest: ${this.isParamTest}
Expand Down
1 change: 1 addition & 0 deletions bsc-plugin/src/lib/rooibos/TestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class TestSuite extends TestBlock {
return `{
name: ${sanitizeBsJsonString(this.name)}
isSolo: ${this.isSolo}
noCatch: ${this.annotation.noCatch}
isIgnored: ${this.isIgnored}
pkgPath: "${this.pkgPath}"
filePath: "${this.filePath}"
Expand Down
27 changes: 21 additions & 6 deletions framework/src/source/BaseTestSuite.bs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace rooibos
currentResult = invalid

protected global = invalid
public catchCrashes = false

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'++ base methods to override
Expand Down Expand Up @@ -123,14 +124,28 @@ namespace rooibos
? ""

m.currentResult = test.result
test.run()

if m.isAutoAssertingMocks = true
m.AssertMocks()
m.CleanMocks()
m.CleanStubs()
if m.catchCrashes
try
test.run()
if m.isAutoAssertingMocks = true
m.AssertMocks()
m.CleanMocks()
m.CleanStubs()
end if
catch error
m.currentResult.crash("test crashed!", error)
end try
else
test.run()
if m.isAutoAssertingMocks = true
m.AssertMocks()
m.CleanMocks()
m.CleanStubs()
end if
end if

? rooibos.common.fillText("<<<< END It: " + test.name + " (" + m.currentResult.getStatusText() + ") ", "<", 80)

end function

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 18 additions & 2 deletions framework/src/source/ConsoleTestReporter.bs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ namespace rooibos
end function

function printTest(test)
if test.result.isFail
if test.result.isCrash
testChar = "|"
locationLine = StrI(test.lineNumber).trim()
else if test.result.isFail
testChar = "-"
locationLine = StrI(test.result.lineNumber + 1).trim()
else
Expand Down Expand Up @@ -121,7 +124,10 @@ namespace rooibos
m.printLine(0, messageLine + test.result.getStatusText() + timeText)
end if

if test.result.isFail
if test.result.isCrash
m.printLine(0, " | " + insettext + " |--Location: " + locationText)
m.printStackTrace(insettext, test.result.error)
else if test.result.isFail
m.printLine(0, " | " + insettext + " |--Location: " + locationText)
if test.isParamTest = true
m.printLine(0, " | " + insettext + " |--Param Line: " + StrI(test.paramlineNumber).trim())
Expand All @@ -130,6 +136,16 @@ namespace rooibos
end if
end function

function printStackTrace(insettext, error)
m.printLine(0, " | " + insettext + " |--Stack trace: ")
for i = error.backTrace.count() - 1 to 0 step -1
e = error.backTrace[i]
if e.filename.instr("pkg:/source/rooibos") = -1
m.printLine(0, " | " + insettext + " " + e.filename + "(" + stri(e.line_number).trim() + ")")
end if
end for
end function

function startReport()
m.printLine()
m.printLine(0, "[START TEST REPORT]")
Expand Down
2 changes: 2 additions & 0 deletions framework/src/source/Test.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace rooibos

public name
public isSolo
public noCatch = false
public funcName
public isIgnored
public lineNumber
Expand All @@ -21,6 +22,7 @@ namespace rooibos
m.testGroup = testGroup
m.testSuite = testGroup.testSuite
m.isSolo = data.isSolo
m.noCatch = data.noCatch
m.funcName = data.funcName
m.isIgnored = data.isIgnored
m.name = data.name
Expand Down
13 changes: 7 additions & 6 deletions framework/src/source/TestResult.bs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace rooibos
public lineNumber = -1
public test = invalid
public time = 0
public error = invalid

function new(test)
m.test = test
Expand All @@ -30,11 +31,11 @@ namespace rooibos
end if
end function

function crash(message as string, lineNumber = -1)
function crash(message as string, error)
if message <> "" and not m.isCrash
if not m.isCrash
m.lineNumber = lineNumber
m.message = message
m.error = error
m.message = "test crashed!"
m.isFail = true
m.isCrash = true
end if
Expand All @@ -60,10 +61,10 @@ namespace rooibos
end function

function getStatusText()
if m.isFail
return "FAIL"
else if m.isCrash
if m.isCrash
return "CRASH"
else if m.isFail
return "FAIL"
else
return "PASS"
end if
Expand Down
2 changes: 1 addition & 1 deletion framework/src/source/TestRunner.bs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace rooibos
testSuite.context = m.nodeContext
testSuite.top = m.nodeContext.top
testSuite.scene = m.nodeContext.global.testsScene

testSuite.catchCrashes = m.config.catchCrashes
m.runTestSuite(testSuite)
if m.stats.hasFailures = true and m.config.failFast = true
exit for
Expand Down