@abaplint/transpiler 1.7.42 → 1.7.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ class Transpiler {
28
28
  return new Transpiler().run(reg);
29
29
  }
30
30
  async run(reg, progress) {
31
- var _a, _b;
31
+ var _a, _b, _c, _d;
32
32
  reg.parse();
33
33
  new keywords_1.Keywords().handle(reg);
34
34
  this.validate(reg);
@@ -36,6 +36,7 @@ class Transpiler {
36
36
  const output = {
37
37
  objects: [],
38
38
  unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip, (_b = this.options) === null || _b === void 0 ? void 0 : _b.only),
39
+ unitTestScriptKernel: new unit_test_1.UnitTest().unitTestScriptKernel(reg, (_c = this.options) === null || _c === void 0 ? void 0 : _c.skip, (_d = this.options) === null || _d === void 0 ? void 0 : _d.only),
39
40
  initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup),
40
41
  databaseSetup: dbSetup,
41
42
  reg: reg,
@@ -14,6 +14,7 @@ export interface IOutput {
14
14
  objects: IOutputFile[];
15
15
  reg: abaplint.IRegistry;
16
16
  unitTestScript: string;
17
+ unitTestScriptKernel: string;
17
18
  initializationScript: string;
18
19
  databaseSetup: string;
19
20
  }
@@ -6,6 +6,7 @@ export declare type TestMethodList = {
6
6
  }[];
7
7
  export declare class UnitTest {
8
8
  initializationScript(reg: abaplint.IRegistry, dbSetup: string): string;
9
+ unitTestScriptKernel(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
9
10
  unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
10
11
  private buildImports;
11
12
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnitTest = void 0;
4
+ /* eslint-disable max-len */
4
5
  const abaplint = require("@abaplint/core");
5
6
  class UnitTest {
6
7
  // todo, move this somewhere else, its much more than just unit test relevant
@@ -18,6 +19,59 @@ export async function initializeABAP(settings) {\n`;
18
19
  ret += `}`;
19
20
  return ret;
20
21
  }
22
+ unitTestScriptKernel(reg, _skip, _only) {
23
+ let ret = `/* eslint-disable curly */
24
+ import fs from "fs";
25
+ import path from "path";
26
+ import {fileURLToPath} from "url";
27
+ import {initializeABAP} from "./init.mjs";
28
+
29
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
30
+
31
+ async function run() {
32
+ await initializeABAP();
33
+ let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
34
+ let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});
35
+ let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
36
+ `;
37
+ for (const obj of reg.getObjects()) {
38
+ if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
39
+ continue;
40
+ }
41
+ for (const file of obj.getABAPFiles()) {
42
+ for (const def of file.getInfo().listClassDefinitions()) {
43
+ if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {
44
+ // todo, fix, there might be global test methods
45
+ continue;
46
+ }
47
+ for (const m of def.methods) {
48
+ if (m.isForTesting === false) {
49
+ continue;
50
+ }
51
+ ret += `
52
+ ls_input.get().class_name.set("${obj.getName()}");
53
+ ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
54
+ ls_input.get().method_name.set("${m.name.toUpperCase()}");
55
+ abap.statements.append({source: ls_input, target: lt_input});`;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ret += `
61
+
62
+ ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
63
+ console.dir(ls_result);
64
+ fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
65
+ }
66
+
67
+ run().then(() => {
68
+ process.exit(0);
69
+ }).catch((err) => {
70
+ console.log(err);
71
+ process.exit(1);
72
+ });`;
73
+ return ret;
74
+ }
21
75
  unitTestScript(reg, skip, _only) {
22
76
  let ret = `/* eslint-disable curly */
23
77
  import fs from "fs";
@@ -43,9 +97,8 @@ async function run() {
43
97
  ret += ` clas = unit.addObject("${obj.getName()}");\n`;
44
98
  for (const file of obj.getABAPFiles()) {
45
99
  for (const def of file.getInfo().listClassDefinitions()) {
46
- if (def.isForTesting === false
47
- || def.isGlobal === true // todo, fix, there might be global test methods
48
- || def.methods.length === 0) {
100
+ if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {
101
+ // todo, fix, there might be global test methods
49
102
  continue;
50
103
  }
51
104
  ret += ` {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "1.7.42",
3
+ "version": "1.7.43",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",