diff --git a/extra/console.clas.abap b/extra/console.clas.abap new file mode 100644 index 0000000..ef24ae9 --- /dev/null +++ b/extra/console.clas.abap @@ -0,0 +1,10 @@ +CLASS console DEFINITION PUBLIC. + PUBLIC SECTION. + CLASS-METHODS log IMPORTING value TYPE clike. +ENDCLASS. + +CLASS console IMPLEMENTATION. + METHOD log. + kernel_unit_runner=>mv_console = kernel_unit_runner=>mv_console && value. + ENDMETHOD. +ENDCLASS. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3e5ccb7..2b92cf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,28 +9,28 @@ "version": "0.1.0", "license": "AGPL-3.0-or-later", "dependencies": { - "@abaplint/cli": "^2.93.96", - "@abaplint/runtime": "^2.3.61", - "@abaplint/transpiler": "^2.3.61", - "@abaplint/transpiler-cli": "^2.3.61" + "@abaplint/cli": "^2.94.5", + "@abaplint/runtime": "^2.3.87", + "@abaplint/transpiler": "^2.3.87", + "@abaplint/transpiler-cli": "^2.3.87" }, "bin": { "abap-test-runner": "bin/run.sh" }, "devDependencies": { "@types/chai": "^4.3.4", - "@types/mocha": "^10.0.0", - "@types/node": "^18.11.9", + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.15", "chai": "^4.3.7", - "mocha": "^10.1.0", + "mocha": "^10.2.0", "source-map-support": "^0.5.21", - "typescript": "^4.9.3" + "typescript": "^4.9.4" } }, "node_modules/@abaplint/cli": { - "version": "2.93.96", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.93.96.tgz", - "integrity": "sha512-ztux6xH0yh7JdFJQRNPBSeahzcWbAtAtYWYzgCPmmFR34ffgnLQyOnfxpnt9QNcZqB5ehwkwyeFXaDv/bivodg==", + "version": "2.94.5", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.94.5.tgz", + "integrity": "sha512-+T63DIEYWJWldwxB7tfPFcQyDrvOmFfodgoazGqD9RmiGdMLGqqfO1UnFy5tYWbLyThcpIMTMtpuNUZEC+pMaw==", "bin": { "abaplint": "abaplint" }, @@ -39,9 +39,9 @@ } }, "node_modules/@abaplint/core": { - "version": "2.93.96", - "resolved": "https://registry.npmjs.org/@abaplint/core/-/core-2.93.96.tgz", - "integrity": "sha512-NmJ2OH1oK7hNo1DJ87xlNmLxiGN5prETcLWUyaVyE1WvBHUluw9pzBIrjDBsHprv8SgC1BF8pQYsUoIpNBrxSQ==", + "version": "2.94.5", + "resolved": "https://registry.npmjs.org/@abaplint/core/-/core-2.94.5.tgz", + "integrity": "sha512-Vp1c78whP+lMzvQRkNaq0Wo1UnWUfwIk/U+MkYdVX9W/5r16rmkWNSA8z0b2nrpGm3pHznOWDrQL6IYHpTntfA==", "dependencies": { "fast-xml-parser": "^4.0.12", "json5": "^2.2.1", @@ -52,26 +52,26 @@ } }, "node_modules/@abaplint/runtime": { - "version": "2.3.61", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.3.61.tgz", - "integrity": "sha512-pMMYQWyCTGB1f5sY21kv4O4UKmsXfXbCVp6v/rMcw8efHDI4+57Ljdqwxx1As7zmOvmN5vO/jDQAGae5i8qptg==", + "version": "2.3.87", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.3.87.tgz", + "integrity": "sha512-enM4tVNqKeE7+bbykD5LkxZ7rGvRIOjyi2L8i94RMttpJmI88/uu5U40J3Indij6SjimXl+FOs3tRVqO0bWdMg==", "dependencies": { "temporal-polyfill": "^0.0.8" } }, "node_modules/@abaplint/transpiler": { - "version": "2.3.61", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler/-/transpiler-2.3.61.tgz", - "integrity": "sha512-aO1sk4PJmRsgCMvJxyvVtS0d0eT1CSNsG9VyLqmauiQrx4iwtdIrnINORNjDUXNurjs6R6N0tFHpVXxxc88KNw==", + "version": "2.3.87", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler/-/transpiler-2.3.87.tgz", + "integrity": "sha512-YqYKGRuz/Wf1Lyy8KrARG4DMjC2HISgish1enyezo5xFUBAW0EbK0pk8lBMSzWQmFHLVkb8juK/RMlwo6X5sAA==", "dependencies": { - "@abaplint/core": "^2.93.96", + "@abaplint/core": "^2.94.5", "source-map": "^0.7.4" } }, "node_modules/@abaplint/transpiler-cli": { - "version": "2.3.61", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.3.61.tgz", - "integrity": "sha512-iY4b9HdsdczX6VqPVNRGb3ZFNEurGTmm8SKkbencSxZDgGs3JXAav5DrpSX51uMPBhUSs2e//Dwp9+O07xM4pA==", + "version": "2.3.87", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.3.87.tgz", + "integrity": "sha512-60EBGXEOMBrkLh9hyVl/+PNrZQXCVnku6lNUg7j7wCeWe1vHNsC0IjpIuxKoBT2yoUI30Z0YLCCEnKtPPu2aog==", "bin": { "abap_transpile": "abap_transpile" } @@ -91,15 +91,15 @@ "dev": true }, "node_modules/@types/mocha": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.0.tgz", - "integrity": "sha512-rADY+HtTOA52l9VZWtgQfn4p+UDVM2eDVkMZT1I6syp0YKxW2F9v+0pbRZLsvskhQv/vMb6ZfCay81GHbz5SHg==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", + "integrity": "sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==", "dev": true }, "node_modules/@types/node": { - "version": "18.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", - "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "version": "18.11.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz", + "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw==", "dev": true }, "node_modules/ansi-colors": { @@ -728,9 +728,9 @@ } }, "node_modules/mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", @@ -1064,9 +1064,9 @@ } }, "node_modules/typescript": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", - "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -1176,14 +1176,14 @@ }, "dependencies": { "@abaplint/cli": { - "version": "2.93.96", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.93.96.tgz", - "integrity": "sha512-ztux6xH0yh7JdFJQRNPBSeahzcWbAtAtYWYzgCPmmFR34ffgnLQyOnfxpnt9QNcZqB5ehwkwyeFXaDv/bivodg==" + "version": "2.94.5", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.94.5.tgz", + "integrity": "sha512-+T63DIEYWJWldwxB7tfPFcQyDrvOmFfodgoazGqD9RmiGdMLGqqfO1UnFy5tYWbLyThcpIMTMtpuNUZEC+pMaw==" }, "@abaplint/core": { - "version": "2.93.96", - "resolved": "https://registry.npmjs.org/@abaplint/core/-/core-2.93.96.tgz", - "integrity": "sha512-NmJ2OH1oK7hNo1DJ87xlNmLxiGN5prETcLWUyaVyE1WvBHUluw9pzBIrjDBsHprv8SgC1BF8pQYsUoIpNBrxSQ==", + "version": "2.94.5", + "resolved": "https://registry.npmjs.org/@abaplint/core/-/core-2.94.5.tgz", + "integrity": "sha512-Vp1c78whP+lMzvQRkNaq0Wo1UnWUfwIk/U+MkYdVX9W/5r16rmkWNSA8z0b2nrpGm3pHznOWDrQL6IYHpTntfA==", "requires": { "fast-xml-parser": "^4.0.12", "json5": "^2.2.1", @@ -1191,19 +1191,19 @@ } }, "@abaplint/runtime": { - "version": "2.3.61", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.3.61.tgz", - "integrity": "sha512-pMMYQWyCTGB1f5sY21kv4O4UKmsXfXbCVp6v/rMcw8efHDI4+57Ljdqwxx1As7zmOvmN5vO/jDQAGae5i8qptg==", + "version": "2.3.87", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.3.87.tgz", + "integrity": "sha512-enM4tVNqKeE7+bbykD5LkxZ7rGvRIOjyi2L8i94RMttpJmI88/uu5U40J3Indij6SjimXl+FOs3tRVqO0bWdMg==", "requires": { "temporal-polyfill": "^0.0.8" } }, "@abaplint/transpiler": { - "version": "2.3.61", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler/-/transpiler-2.3.61.tgz", - "integrity": "sha512-aO1sk4PJmRsgCMvJxyvVtS0d0eT1CSNsG9VyLqmauiQrx4iwtdIrnINORNjDUXNurjs6R6N0tFHpVXxxc88KNw==", + "version": "2.3.87", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler/-/transpiler-2.3.87.tgz", + "integrity": "sha512-YqYKGRuz/Wf1Lyy8KrARG4DMjC2HISgish1enyezo5xFUBAW0EbK0pk8lBMSzWQmFHLVkb8juK/RMlwo6X5sAA==", "requires": { - "@abaplint/core": "^2.93.96", + "@abaplint/core": "^2.94.5", "source-map": "^0.7.4" }, "dependencies": { @@ -1215,9 +1215,9 @@ } }, "@abaplint/transpiler-cli": { - "version": "2.3.61", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.3.61.tgz", - "integrity": "sha512-iY4b9HdsdczX6VqPVNRGb3ZFNEurGTmm8SKkbencSxZDgGs3JXAav5DrpSX51uMPBhUSs2e//Dwp9+O07xM4pA==" + "version": "2.3.87", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.3.87.tgz", + "integrity": "sha512-60EBGXEOMBrkLh9hyVl/+PNrZQXCVnku6lNUg7j7wCeWe1vHNsC0IjpIuxKoBT2yoUI30Z0YLCCEnKtPPu2aog==" }, "@types/chai": { "version": "4.3.4", @@ -1226,15 +1226,15 @@ "dev": true }, "@types/mocha": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.0.tgz", - "integrity": "sha512-rADY+HtTOA52l9VZWtgQfn4p+UDVM2eDVkMZT1I6syp0YKxW2F9v+0pbRZLsvskhQv/vMb6ZfCay81GHbz5SHg==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", + "integrity": "sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==", "dev": true }, "@types/node": { - "version": "18.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", - "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "version": "18.11.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz", + "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw==", "dev": true }, "ansi-colors": { @@ -1684,9 +1684,9 @@ } }, "mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dev": true, "requires": { "ansi-colors": "4.1.1", @@ -1925,9 +1925,9 @@ "dev": true }, "typescript": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", - "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true }, "vscode-languageserver-types": { diff --git a/package.json b/package.json index 90e67c3..fb6ef3d 100644 --- a/package.json +++ b/package.json @@ -26,18 +26,18 @@ "require": "source-map-support/register" }, "dependencies": { - "@abaplint/transpiler-cli": "^2.3.61", - "@abaplint/transpiler": "^2.3.61", - "@abaplint/cli": "^2.93.96", - "@abaplint/runtime": "^2.3.61" + "@abaplint/transpiler-cli": "^2.3.87", + "@abaplint/transpiler": "^2.3.87", + "@abaplint/cli": "^2.94.5", + "@abaplint/runtime": "^2.3.87" }, "devDependencies": { "@types/chai": "^4.3.4", - "@types/mocha": "^10.0.0", + "@types/mocha": "^10.0.1", "chai": "^4.3.7", - "mocha": "^10.1.0", + "mocha": "^10.2.0", "source-map-support": "^0.5.21", - "typescript": "^4.9.3", - "@types/node": "^18.11.9" + "typescript": "^4.9.4", + "@types/node": "^18.11.15" } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1ccd898..66e656d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,10 +62,18 @@ class Runner { if (t.status !== "SUCCESS") { output.status = "fail"; } - output.tests.push({ - name: t.method_name, - status: t.status === "SUCCESS" ? "pass" : "fail", - message: t.message}); + if (t.console && t.console !== "") { + output.tests.push({ + name: t.method_name, + status: t.status === "SUCCESS" ? "pass" : "fail", + output: t.console, + message: t.message}); + } else { + output.tests.push({ + name: t.method_name, + status: t.status === "SUCCESS" ? "pass" : "fail", + message: t.message}); + } } } @@ -113,6 +121,9 @@ class Runner { fs.writeFileSync(path.join(this.tmpDir, "abap_transpile.json"), JSON.stringify(config, null, 2)); execSync(`cp ${inputDir}/*.abap ${this.tmpDir}`, {stdio: 'pipe'}); fs.mkdirSync(`${this.tmpDir}/deps`); + + execSync(`cp extra/* ${this.tmpDir}/deps/`, {stdio: 'pipe'}); + execSync(`cp open-abap/src/unit/*.clas*.abap ${this.tmpDir}/deps/`, {stdio: 'pipe'}); execSync(`cp open-abap/src/exceptions/* ${this.tmpDir}/deps/`, {stdio: 'pipe'}); execSync(`cp open-abap/src/cl_abap_char_utilities.clas.abap ${this.tmpDir}/deps/`, {stdio: 'pipe'}); diff --git a/test/test.ts b/test/test.ts index 63a9e3f..e2a00aa 100644 --- a/test/test.ts +++ b/test/test.ts @@ -88,4 +88,8 @@ describe('abap-test-runner', async () => { it('implement-method-error', async () => { test("implement-method-error", "error"); }); + + it('console-log', async () => { + test("console-log", "pass"); + }); }); \ No newline at end of file diff --git a/tests/console-log/expected_results.json b/tests/console-log/expected_results.json new file mode 100644 index 0000000..13548ee --- /dev/null +++ b/tests/console-log/expected_results.json @@ -0,0 +1 @@ +{"version":2,"status":"pass","tests":[{"name":"TEST","status":"pass","output":"sdf","message":""}]} \ No newline at end of file diff --git a/tests/console-log/zcl_simple.clas.abap b/tests/console-log/zcl_simple.clas.abap new file mode 100644 index 0000000..5040fd1 --- /dev/null +++ b/tests/console-log/zcl_simple.clas.abap @@ -0,0 +1,13 @@ +CLASS zcl_simple DEFINITION PUBLIC. + PUBLIC SECTION. + METHODS run RETURNING VALUE(res) TYPE i. +ENDCLASS. + +CLASS zcl_simple IMPLEMENTATION. + + METHOD run. + res = 3. + console=>log( 'sdf' ). + ENDMETHOD. + +ENDCLASS. \ No newline at end of file diff --git a/tests/console-log/zcl_simple.clas.testclasses.abap b/tests/console-log/zcl_simple.clas.testclasses.abap new file mode 100644 index 0000000..4952095 --- /dev/null +++ b/tests/console-log/zcl_simple.clas.testclasses.abap @@ -0,0 +1,18 @@ +CLASS ltcl_simple DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL. + + PRIVATE SECTION. + METHODS test FOR TESTING RAISING cx_static_check. + +ENDCLASS. + +CLASS ltcl_simple IMPLEMENTATION. + + METHOD test. + DATA simple TYPE REF TO zcl_simple. + CREATE OBJECT simple. + cl_abap_unit_assert=>assert_equals( + act = simple->run( ) + exp = 3 ). + ENDMETHOD. + +ENDCLASS. \ No newline at end of file diff --git a/tests/implement-method-error/expected_results.json b/tests/implement-method-error/expected_results.json index 068ae7a..349570e 100644 --- a/tests/implement-method-error/expected_results.json +++ b/tests/implement-method-error/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"error","tests":[],"message":"Transpiler CLI\nUsing config: abap_transpile.json\n81 files added\n0 files skipped\n\nBuilding\nError: implement_methods, Implement method \"run\", zcl_simple.clas.abap:6"} \ No newline at end of file +{"version":2,"status":"error","tests":[],"message":"Transpiler CLI\nUsing config: abap_transpile.json\n83 files added\n0 files skipped\n\nBuilding\nError: implement_methods, Implement method \"run\", zcl_simple.clas.abap:6"} \ No newline at end of file