From 71524d88ddee7edf358c436a1910701b382c9eb0 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Wed, 13 Nov 2024 14:21:29 +0100 Subject: [PATCH 1/5] test(formatter/coverage): Add test --- src/cli/base.ts | 2 +- src/formatter/coverage.ts | 12 +- test/lib/formatter/coverage.ts | 136 ++++++++++++++ test/lib/formatter/snapshots/coverage.ts.md | 175 ++++++++++++++++++ test/lib/formatter/snapshots/coverage.ts.snap | Bin 0 -> 983 bytes 5 files changed, 317 insertions(+), 8 deletions(-) create mode 100644 test/lib/formatter/coverage.ts create mode 100644 test/lib/formatter/snapshots/coverage.ts.md create mode 100644 test/lib/formatter/snapshots/coverage.ts.snap diff --git a/src/cli/base.ts b/src/cli/base.ts index 0d61069b2..544b82bea 100644 --- a/src/cli/base.ts +++ b/src/cli/base.ts @@ -163,7 +163,7 @@ async function handleLint(argv: ArgumentsCamelCase) { if (coverage) { const coverageFormatter = new Coverage(); - await writeFile("ui5lint-report.html", await coverageFormatter.format(res)); + await writeFile("ui5lint-report.html", await coverageFormatter.format(res, new Date())); } if (format === "json") { diff --git a/src/formatter/coverage.ts b/src/formatter/coverage.ts index 23ebacea8..f67865834 100644 --- a/src/formatter/coverage.ts +++ b/src/formatter/coverage.ts @@ -1,10 +1,9 @@ -import path from "node:path"; import { LintResult, CoverageInfo, CoverageCategory, } from "../linter/LinterContext.js"; -import {readFile} from "fs/promises"; +import {readFile} from "node:fs/promises"; import {LintMessageSeverity} from "../linter/messages.js"; const visualizedSpace = "\u00b7"; @@ -17,7 +16,7 @@ function formatSeverity(severity: LintMessageSeverity) { } else if (severity === LintMessageSeverity.Warning) { return "warning"; } else { - throw new Error(`Unknown severity: ${LintMessageSeverity[severity]}`); + throw new Error(`Unknown severity: ${severity as number}`); } } @@ -45,13 +44,13 @@ function escape(str: string) { export class Coverage { #buffer = ""; - async format(lintResults: LintResult[]) { + async format(lintResults: LintResult[], reportDate: Date) { this.#writeln(` - UI5Lint Coverage Report ${new Date().toLocaleString()} + UI5Lint Coverage Report ${reportDate.toLocaleString("en-US")} ␊ + ␊ + ␊ +
manifest.json␊ +
␊ + 1␊ + {␊ +
␊ +
␊ + 2␊ + » "_version":·"1.61.0",␊ +
␊ +
␊ + 3␊ + » "sap.app":·{␊ +
␊ +
␊ + 4␊ + » » "id":·"sap.ui.demo.todo",␊ +
␊ +
␊ + 5␊ + » » "type":·"application"␊ +
␊ +
␊ + 6␊ + » },␊ +
␊ +
␊ + 7␊ + » "sap.ui5":·{␊ +
␊ +
␊ + 8␊ + » » "dependencies":·{␊ +
␊ +
␊ + 9␊ + » » » "minUI5Version":·"1.121.0",␊ +
␊ +
␊ + 10␊ + » » » "libs":·{␊ +
␊ +
␊ + 11␊ + » » » » "sap.ui.core":·{}␊ +
␊ +
␊ + 12␊ + » » » }␊ +
␊ +
␊ + 13␊ + » » },␊ +
␊ +
␊ + 14␊ + » » "rootView":·{␊ +
␊ +
␊ + 15␊ + » » » "viewName":·"sap.ui.demo.todo.view.App",␊ +
␊ +
␊ + 16␊ + » » » "type":·"XML",␊ +
␊ +
␊ + 17␊ + » » » "id":·"app",␊ + warning <message>␊ +
␊ +
␊ + 18␊ + » » » "async":·true␊ +
␊ +
␊ + 19␊ + » » }␊ +
␊ +
␊ + 20␊ + » }␊ +
␊ +
␊ + 21␊ + }␊ +
␊ +
␊ + 22␊ + ␊ +
␊ +
␊ +
Test.js␊ +
␊ + 1␊ + sap.ui.define(()·=>·{␊ +
␊ +
␊ + 2␊ + » sap.ui.getCore();␊ + error <message> & error <message>␊ +
␊ +
␊ + 3␊ + » unknownFunctionCall();␊ +
␊ +
␊ + 4␊ + });␊ +
␊ +
␊ + 5␊ + ␊ +
␊ +
␊ + ␊ + ␊ + ` diff --git a/test/lib/formatter/snapshots/coverage.ts.snap b/test/lib/formatter/snapshots/coverage.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..bb0a8c5ea2e44f93876963d243bfaffd7da5ed14 GIT binary patch literal 983 zcmV;|11S7KRzVCF3R5tY#AB*7n1OSCcIrNJR_lVMFmR>_vrH=E zkXQ->!VH`lGBX}9m|_fW{&GN2ph3!A9a9bi-#g54@+6}3m%Udg3|S@fCs;({cl=KG zuzPes{Gj_JIO>t(*I}pdX}3ac=J`V&{bjq=8cAW?5lxZL19Gg8@&lr&(5?oBqyDvp z#`h2qAJTriwP?4z5pu}=Q>qda?ob*d(|~l<$|RNyIEun7ql}?QTn-}>5Wle6Bu}M~ zI-@ac`+F-C1MiGWIVK_?3X`$vuR-SvH`w_Z2BZh?>>ER!aXJqO3XA6EC9y^1jj481 z(3&Qo*I0)%zDSgu26bE4K}*P3V<% z-RL|a-T1n2b|so9nBNO)JNzZUqTLER%i0S&MW=*A$>vczWH==;r&Wqpg zr2f}nDY%g3Sy{>ndJIzO8OdaW{Cd@h%{+sg znr0ctm>PS)wMn0rkuK^d^h>1+n_#cmg*~fwZVWOI3`C5en-Tt6iLhWzQJlZ*z1ipk zzuT-4{KI<$z;W0xU4NH+Y|*V>s~1a^SL)@WK6k0e+9Nw6(yy4gD`7& zW7VXjptSSXZ#0EF<;=6Y-f@;SDc4esxl7&tdi|;rCs`jEz7jyG5Z%^wx{>m_+YQ%@ zDuE&)kGSbCSEKr;R87W;AgP{<*v4tp1nN^(6SDe!)h!jO2H3k)sR8UR!P!Q=4Zc3K zofQMyw;k734LU*r`}>ctz6_#jQcTh5A$2DrQQ`|cuag`MSJh)(gJ{C{Qv>Eh}S F002Bc-SYqd literal 0 HcmV?d00001 From 3f5bbda9805c21c041cb9f7ce791991e94880189 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Fri, 29 Nov 2024 10:23:11 +0100 Subject: [PATCH 2/5] test(amdTranspiler): Add error handling test --- .../ui5Types/amdTranspiler/transpiler.ts | 8 +- test/lib/linter/amdTranspiler/transpiler.ts | 2 - .../amdTranspiler/transpiler_errorHandling.ts | 135 ++++++++++++++++++ 3 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 test/lib/linter/amdTranspiler/transpiler_errorHandling.ts diff --git a/src/linter/ui5Types/amdTranspiler/transpiler.ts b/src/linter/ui5Types/amdTranspiler/transpiler.ts index 0331161e7..1c481f18f 100644 --- a/src/linter/ui5Types/amdTranspiler/transpiler.ts +++ b/src/linter/ui5Types/amdTranspiler/transpiler.ts @@ -103,17 +103,19 @@ export default function transpileAmdToEsm( if (strict) { throw err; } + // Usually the UnsupportedModuleError is already caught inside and not thrown, but this is a safety net + // in case it is thrown anyway. if (err instanceof UnsupportedModuleError) { log.verbose(`Failed to transform module ${fileName}: ${err.message}`); - if (err.stack && log.isLevelEnabled("verbose")) { + if (err.stack) { log.verbose(`Stack trace:`); log.verbose(err.stack); } return {source: content, map: ""}; } else if (err instanceof Error && err.message.startsWith("Debug Failure")) { - // We probably failed to create a valid AST + // We probably failed to create a valid AST. The error is thrown by TypeScript itself. log.verbose(`AST transformation failed for module ${fileName}: ${err.message}`); - if (err.stack && log.isLevelEnabled("verbose")) { + if (err.stack) { log.verbose(`Stack trace:`); log.verbose(err.stack); } diff --git a/test/lib/linter/amdTranspiler/transpiler.ts b/test/lib/linter/amdTranspiler/transpiler.ts index ee8ee5a84..707acf62f 100644 --- a/test/lib/linter/amdTranspiler/transpiler.ts +++ b/test/lib/linter/amdTranspiler/transpiler.ts @@ -1,9 +1,7 @@ import anyTest, {TestFn} from "ava"; import sinonGlobal from "sinon"; import path from "node:path"; -// import fs from "node:fs/promises"; import {fileURLToPath} from "node:url"; -// import {amdToEsm} from "../../../../../src/detectors/transpilers/amd/transpiler.js"; import {createTestsForFixtures} from "./_helper.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/test/lib/linter/amdTranspiler/transpiler_errorHandling.ts b/test/lib/linter/amdTranspiler/transpiler_errorHandling.ts new file mode 100644 index 000000000..6181f793c --- /dev/null +++ b/test/lib/linter/amdTranspiler/transpiler_errorHandling.ts @@ -0,0 +1,135 @@ +import anyTest, {TestFn} from "ava"; +import sinonGlobal from "sinon"; +import LinterContext from "../../../../src/linter/LinterContext.js"; +import {UnsupportedModuleError} from "../../../../src/linter/ui5Types/amdTranspiler/util.js"; +import esmock from "esmock"; + +const test = anyTest as TestFn<{ + sinon: sinonGlobal.SinonSandbox; + log: {verbose: sinonGlobal.SinonStub}; + transformFunctionStub: sinonGlobal.SinonStub; + transpileAmdToEsm: typeof import("../../../../src/linter/ui5Types/amdTranspiler/transpiler.js").default; +}>; + +test.beforeEach(async (t) => { + const sinon = t.context.sinon = sinonGlobal.createSandbox(); + t.context.transformFunctionStub = sinon.stub(); + t.context.log = { + verbose: sinon.stub(), + }; + t.context.transpileAmdToEsm = await esmock("../../../../src/linter/ui5Types/amdTranspiler/transpiler.js", { + "../../../../src/linter/ui5Types/amdTranspiler/tsTransformer.js": { + createTransformer: () => () => t.context.transformFunctionStub, + }, + "@ui5/logger": { + getLogger: sinon.stub().withArgs("linter:ui5Types:amdTranspiler:transpiler").returns(t.context.log), + }, + }); +}); + +test.serial("Error: Unexpected Error during transformation", (t) => { + const {transpileAmdToEsm, transformFunctionStub} = t.context; + + const context = new LinterContext({ + rootDir: "/", + namespace: "my/app", + }); + + // Stub the createTransformer function so that the transpiler has to handle an unexpected error + transformFunctionStub.throws(new Error("TEST: Unexpected error from createTransformer")); + + t.throws(() => transpileAmdToEsm("/resources/my/app/x.js", "const x = 1;", context), { + message: "TEST: Unexpected error from createTransformer", + }); +}); + +test.serial("Error: Unexpected UnsupportedModuleError during transformation", (t) => { + const {transpileAmdToEsm, transformFunctionStub, log} = t.context; + + const context = new LinterContext({ + rootDir: "/", + namespace: "my/app", + }); + + const inputSource = "const x = 1;"; + + // Stub the createTransformer function so that the transpiler has to handle an unexpected UnsupportedModuleError + // Usually all UnsupportedModuleError are handled internally so that they are not thrown, but the catch clause + // is a safety net in case an error is thrown anyway + const error = new UnsupportedModuleError("TEST"); + transformFunctionStub.throws(error); + + const {source, map} = transpileAmdToEsm("/resources/my/app/x.js", inputSource, context); + + t.is(source, inputSource); + t.is(map, ""); + + t.is(log.verbose.callCount, 3); + t.deepEqual(log.verbose.getCall(0).args, ["Failed to transform module x.js: TEST"]); + t.deepEqual(log.verbose.getCall(1).args, ["Stack trace:"]); + t.deepEqual(log.verbose.getCall(2).args, [error.stack]); +}); + +test.serial("Error: Unexpected UnsupportedModuleError during transformation (strict = true)", (t) => { + const {transpileAmdToEsm, transformFunctionStub} = t.context; + + const context = new LinterContext({ + rootDir: "/", + namespace: "my/app", + }); + + const inputSource = "const x = 1;"; + + // Stub the createTransformer function so that the transpiler has to handle an unexpected UnsupportedModuleError + // Usually all UnsupportedModuleError are handled internally so that they are not thrown, but the catch clause + // is a safety net in case an error is thrown anyway + transformFunctionStub.throws(new UnsupportedModuleError("TEST")); + + t.throws(() => transpileAmdToEsm("/resources/my/app/x.js", inputSource, context, true), { + message: "TEST", + instanceOf: UnsupportedModuleError, + }); +}); + +test.serial("Error: Unexpected TypeScript Debug Failure during transformation", (t) => { + const {transpileAmdToEsm, transformFunctionStub, log} = t.context; + + const context = new LinterContext({ + rootDir: "/", + namespace: "my/app", + }); + + const inputSource = "const x = 1;"; + + // Stub the createTransformer function so that the transpiler has to handle an unexpected error from TypeScript + const error = new Error("Debug Failure. TEST"); + transformFunctionStub.throws(error); + + const {source, map} = transpileAmdToEsm("/resources/my/app/x.js", inputSource, context); + + t.is(source, inputSource); + t.is(map, ""); + + t.is(log.verbose.callCount, 3); + t.deepEqual(log.verbose.getCall(0).args, ["AST transformation failed for module x.js: Debug Failure. TEST"]); + t.deepEqual(log.verbose.getCall(1).args, ["Stack trace:"]); + t.deepEqual(log.verbose.getCall(2).args, [error.stack]); +}); + +test.serial("Error: Unexpected TypeScript Debug Failure during transformation (strict = true)", (t) => { + const {transpileAmdToEsm, transformFunctionStub} = t.context; + + const context = new LinterContext({ + rootDir: "/", + namespace: "my/app", + }); + + const inputSource = "const x = 1;"; + + // Stub the createTransformer function so that the transpiler has to handle an unexpected error from TypeScript + transformFunctionStub.throws(new Error("Debug Failure. TEST")); + + t.throws(() => transpileAmdToEsm("/resources/my/app/x.js", inputSource, context, true), { + message: "Debug Failure. TEST", + }); +}); From b2d5199f6ce4b45a467382a38bb8aa7ec254b877 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Fri, 29 Nov 2024 09:14:04 +0100 Subject: [PATCH 3/5] test: Remove unused snapshot file --- .../transpilers/xml/snapshots/transpiler.ts.snap | Bin 5366 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test/lib/detectors/transpilers/xml/snapshots/transpiler.ts.snap diff --git a/test/lib/detectors/transpilers/xml/snapshots/transpiler.ts.snap b/test/lib/detectors/transpilers/xml/snapshots/transpiler.ts.snap deleted file mode 100644 index 33cb3f6fcd6da4a9ce664d602461f0f2879a2658..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5366 zcmV_3qvyK6CWW)Xem5PxoAR&(6$UE)XXIf)FS~0tp3!AqavZ5ebAMB3VQr5PuK} z34$HOLk0wj!XL;&0?7jWRdvsF_w-KB?Cc^N-CFWZy}zoi@AuXBsCu=sqZy?=>*s%s z+N!P5_PH%n(XEE6(YS2X8yamB+cwpmrcJLaT9aBA_f^`u*sg1;r7I1qX4uweUM-gu zTe%hc!UUWE{1c|&iP&djYQ15YcAV(CVJo(3=mn}Zs2Q)AMm;`lDUC!^P1KDt)e;8w zkOu8keaq_=$@AK1kdVKxuWb)%~ylvcq*v+p1)kx_j<)^)UuQ+^;1_eOqy^? zdR4Ehv=vgXzF$gU(RBJ`$%dt{7%rv2ALu#Ahz@#G0aNPR$3?;>ic+ z(kETYoCW2y@q|O2P22WLe7Zn2&4}NgzG0YJ`Sx_6IbUpNX83!k#A?S;EeFd6T&0wJG-=G3qtqj>C>k{cpvU+;S`(^V(%9wK$v<$n5?K8bra7F z;+I`3(Dc!|(rBo9)p9aoUjah$vRKa&k}RYN*-RD0J(-Y}oF+tW%VJd~WKl{J^1_lN zUXsY#D*nDA&dN@U!a_l8$)qT!OGGB(Hr6PTtFqWEkh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5pRyk!XJv<4AF;*mw}LMmOrh|-aEJ_xz2t Date: Thu, 28 Nov 2024 14:07:23 +0100 Subject: [PATCH 4/5] ci: Increase coverage thresholds --- .nycrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.nycrc b/.nycrc index 6eb878f66..068466d06 100644 --- a/.nycrc +++ b/.nycrc @@ -8,10 +8,10 @@ "src/linter/xmlTemplate/lib/JSTokenizer.js" ], "check-coverage": true, - "statements": 82, - "branches": 74, - "functions": 89, - "lines": 82, + "statements": 87, + "branches": 79, + "functions": 94, + "lines": 87, "watermarks": { "statements": [70, 90], "branches": [70, 90], From d8ff46b153495bf4fa91e83c56f47fefb3c1fb15 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Fri, 29 Nov 2024 10:35:10 +0100 Subject: [PATCH 5/5] test: Prevent removal of coverage dir in npm test The additional build for e2e tests did remove the previously generated coverage report. --- package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6ccdbc07a..fba111c91 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,13 @@ "type": "module", "types": "lib/index.d.ts", "scripts": { - "build": "npm run cleanup && tsc -p tsconfig.build.json", + "build": "npm run clean-lib && tsc -p tsconfig.build.json", "build-test": "tsc --noEmit -p .", - "build-watch": "npm run cleanup && tsc -w -p tsconfig.build.json", + "build-watch": "npm run clean-lib && tsc -w -p tsconfig.build.json", "check-licenses": "licensee --errors-only", - "cleanup": "rimraf lib coverage", - "coverage": "nyc ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\"", + "clean-coverage": "rimraf coverage", + "clean-lib": "rimraf lib", + "coverage": "npm run clean-coverage && nyc ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\"", "depcheck": "depcheck --ignores @commitlint/config-conventional,@istanbuljs/esm-loader-hook,rimraf,sap,mycomp,@ui5/linter", "hooks:pre-push": "npm run lint:commit", "lint": "eslint .",