Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/missing-diagnostics-in-node-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdp authored Jun 25, 2024
2 parents 685377c + ee9bf4f commit 1024727
Show file tree
Hide file tree
Showing 22 changed files with 377 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "14.18.1"
node-version: "16.20.2"
# - run: npm run build
- run: cd bsc-plugin && npm install
- run: cd bsc-plugin && npm run preversion
Expand All @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "10.19.0"
node-version: "16.20.2"
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ./.npmrc
- run: npm ci
- run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion bsc-plugin/src/lib/rooibos/Annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ export class RooibosAnnotation {

export function getAnnotationType(text: string): AnnotationType {
return annotationLookup[text.toLowerCase()] || AnnotationType.None;
}
}
27 changes: 27 additions & 0 deletions bsc-plugin/src/lib/rooibos/MockUtil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.sayhello
__stubOrMockResult = __stubFunction(a1, a2)
return __stubOrMockResult
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("sayhello")
value = __stubs_globalAa.__globalStubs.sayhello
return value
end if
print "hello"
end function
Expand Down Expand Up @@ -122,6 +125,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.sayhello
__stubOrMockResult = __stubFunction(a1, a2)
return __stubOrMockResult
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("sayhello")
value = __stubs_globalAa.__globalStubs.sayhello
return value
end if
print "hello"
end function
Expand Down Expand Up @@ -162,6 +168,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.redlines_setrulerlines
__stubOrMockResult = __stubFunction(rulerLines)
return
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("redlines_setrulerlines")
value = __stubs_globalAa.__globalStubs.redlines_setrulerlines
return
end if
For Each line In rulerLines.Items()
RedLines_AddLine(line.key, line.value.position, line.value.coords, m.node, m.childMap)
Expand All @@ -177,6 +186,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.redlines_addline
__stubOrMockResult = __stubFunction(id, position, coords, node, childMap)
return __stubOrMockResult
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("redlines_addline")
value = __stubs_globalAa.__globalStubs.redlines_addline
return value
end if
line = CreateObject("roSGNode", "Rectangle")
line.setField("id", id)
Expand Down Expand Up @@ -213,6 +225,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.sayhello
__stubOrMockResult = __stubFunction(a1, a2)
return
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("sayhello")
value = __stubs_globalAa.__globalStubs.sayhello
return
end if
print "hello"
end sub
Expand Down Expand Up @@ -250,6 +265,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.person_utils_sayhello
__stubOrMockResult = __stubFunction(a1, a2)
return __stubOrMockResult
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("person_utils_sayhello")
value = __stubs_globalAa.__globalStubs.person_utils_sayhello
return value
end if
print "hello"
end function
Expand Down Expand Up @@ -287,6 +305,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.person_utils_sayhello
__stubOrMockResult = __stubFunction(a1, a2)
return
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("person_utils_sayhello")
value = __stubs_globalAa.__globalStubs.person_utils_sayhello
return
end if
print "hello"
end sub
Expand Down Expand Up @@ -378,6 +399,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.beings_sayhello
__stubOrMockResult = __stubFunction()
return __stubOrMockResult
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("beings_sayhello")
value = __stubs_globalAa.__globalStubs.beings_sayhello
return value
end if
print "hello2"
end function
Expand All @@ -391,6 +415,9 @@ describe('MockUtil', () => {
__stubFunction = __stubs_globalAa.__globalStubs.sayhello
__stubOrMockResult = __stubFunction()
return __stubOrMockResult
else if __stubs_globalAa?.__globalStubs <> invalid and __stubs_globalAa.__globalStubs.doesExist("sayhello")
value = __stubs_globalAa.__globalStubs.sayhello
return value
end if
print "hello3"
end function
Expand Down
5 changes: 4 additions & 1 deletion bsc-plugin/src/lib/rooibos/MockUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ export class MockUtil {
${globalAaName} = getGlobalAa()
if RBS_SM_${this.fileId}_getMocksByFunctionName()["${methodName}"] <> invalid
${resultName} = RBS_SM_${this.fileId}_getMocksByFunctionName()["${methodName}"].callback(${paramNames})
return${requiresReturnValue ? ` ${resultName}` : '' }
return${requiresReturnValue ? ` ${resultName}` : ''}
else if type(${globalAaName}?.${storageName}?.${methodName}).endsWith("Function")
__stubFunction = ${globalAaName}.${storageName}.${methodName}
${resultName} = __stubFunction(${paramNames})
return${requiresReturnValue ? ` ${resultName}` : ''}
else if ${globalAaName}?.${storageName} <> invalid and ${globalAaName}.${storageName}.doesExist("${methodName}")
value = ${globalAaName}.${storageName}.${methodName}
return${requiresReturnValue ? ` value` : ''}
end if
`;
const astCodeToInject = Parser.parse(template).ast.statements;
Expand Down
5 changes: 5 additions & 0 deletions bsc-plugin/src/lib/rooibos/RooibosConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export interface RooibosConfig {
catchCrashes?: boolean;
throwOnFailedAssertion?: boolean;
sendHomeOnFinish?: boolean;

/**
* @deprecated Use the `reporters` array instead
*/
reporter?: string;
reporters?: string[];
keepAppOpen?: boolean;
testSceneName?: string;

Expand Down
26 changes: 25 additions & 1 deletion bsc-plugin/src/lib/rooibos/RooibosSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class RooibosSession {
method.func.body.statements.length,
Parser.parse(undent`
return {
"reporter": "${this.config.reporter || ''}"
"reporters": ${this.getReportersList()}
"failFast": ${this.config.failFast ? 'true' : 'false'}
"sendHomeOnFinish": ${this.config.sendHomeOnFinish ? 'true' : 'false'}
"logLevel": ${this.config.logLevel ?? 0}
Expand All @@ -156,6 +156,30 @@ export class RooibosSession {
}
}

getReportersList() {
let reporters = this.config.reporters;
if (!Array.isArray(reporters)) {
reporters = [];
}
if (this.config.reporter) {
// @todo: warn that `reporter` is deprecated and to use `reporters` instead
reporters.push(this.config.reporter);
}
if (reporters.length < 1) {
reporters.push('console');
}
return `[${reporters.map(this.sanitiseReporterName).toString()}]`;
}

sanitiseReporterName(name: string) {
switch (name.toLowerCase()) {
case 'console': return 'rooibos_ConsoleTestReporter';
case 'junit': return 'rooibos_JUnitTestReporter';
}
// @todo: check if function name is valid
return name;
}

updateVersionTextFunction(classStatement: ClassStatement, editor: AstEditor) {
let method = classStatement.methods.find((m) => m.name.text === 'getVersionText');
if (method) {
Expand Down
2 changes: 1 addition & 1 deletion bsc-plugin/src/lib/rooibos/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function getPathValuePartAsString(expr: Expression) {

export function getScopeForSuite(testSuite: TestSuite) {
if (testSuite.isNodeTest) {
return testSuite.file.program.getScopesForFile(testSuite.file).find((scope)=> {
return testSuite.file.program.getScopesForFile(testSuite.file).find((scope) => {
return isXmlScope(scope) && scope.xmlFile.componentName.text === testSuite.generatedNodeName;
});

Expand Down
Loading

0 comments on commit 1024727

Please sign in to comment.