@abaplint/transpiler 2.10.39 → 2.10.41

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.
@@ -88,7 +88,8 @@ run().then(() => {
88
88
  }
89
89
  tests.push({
90
90
  obj,
91
- localClass: def.name,
91
+ filename: `./${(0, initialization_1.escapeNamespaceFilename)(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs`,
92
+ localClass: def.name.toLowerCase(),
92
93
  riskLevel: def.riskLevel,
93
94
  duration: def.duration,
94
95
  methods: methods,
@@ -144,41 +145,65 @@ run().then(() => {
144
145
  return tests;
145
146
  }
146
147
  unitTestScript(reg, skip) {
148
+ const callSpecial = (name) => {
149
+ let ret = "";
150
+ ret += `if (test.${name}) await test.${name}();\n`;
151
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.${name}) await test.FRIENDS_ACCESS_INSTANCE.${name}();\n`;
152
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.SUPER && test.FRIENDS_ACCESS_INSTANCE.SUPER.${name}) await test.FRIENDS_ACCESS_INSTANCE.SUPER.${name}();`;
153
+ return ret;
154
+ };
147
155
  let ret = `/* eslint-disable curly */
156
+ /* eslint-disable max-len */
148
157
  import {initializeABAP} from "./init.mjs";
149
158
 
150
- async function run() {
151
- await initializeABAP();\n`;
159
+ function getData() {
160
+ const ret = [];\n`;
152
161
  for (const st of this.getSortedTests(reg)) {
153
- ret += `// --------------------------------------------\n`;
154
- const lc = st.localClass.toLowerCase();
155
- ret += ` {
156
- const {${lc}} = await import("./${(0, initialization_1.escapeNamespaceFilename)(st.obj.getName().toLowerCase())}.${st.obj.getType().toLowerCase()}.testclasses.mjs");
157
- if (${lc}.class_setup) await ${lc}.class_setup();\n`;
162
+ const methods = [];
158
163
  for (const m of st.methods) {
159
- const skipThis = (skip || []).some(a => a.object === st.obj.getName() && a.class === lc && a.method === m);
160
- if (skipThis) {
161
- ret += ` console.log('${st.obj.getName()}: running ${lc}->${m}, skipped');\n`;
162
- continue;
163
- }
164
- const callSpecial = (name) => {
165
- let ret = "";
166
- ret += ` if (test.${name}) await test.${name}();\n`;
167
- ret += ` if (test.FRIENDS_ACCESS_INSTANCE.${name}) await test.FRIENDS_ACCESS_INSTANCE.${name}();\n`;
168
- ret += ` if (test.FRIENDS_ACCESS_INSTANCE.SUPER && test.FRIENDS_ACCESS_INSTANCE.SUPER.${name}) await test.FRIENDS_ACCESS_INSTANCE.SUPER.${name}();\n`;
169
- return ret;
170
- };
171
- ret += ` {\n const test = await (new ${lc}()).constructor_();\n`;
172
- ret += callSpecial("setup");
173
- ret += ` console.log("${st.obj.getName()}: running ${lc}->${m}");\n`;
174
- ret += ` await test.FRIENDS_ACCESS_INSTANCE.${m}();\n`;
175
- ret += callSpecial("teardown");
176
- ret += ` }\n`;
164
+ const skipThis = (skip || []).some(a => a.object.toUpperCase() === st.obj.getName().toUpperCase()
165
+ && a.class.toUpperCase() === st.localClass.toUpperCase()
166
+ && a.method.toUpperCase() === m.toUpperCase());
167
+ methods.push({
168
+ name: m,
169
+ skip: skipThis,
170
+ });
177
171
  }
178
- ret += ` if (${lc}.class_teardown) await ${lc}.class_teardown();\n`;
179
- ret += ` }\n`;
172
+ ret += ` ret.push({objectName: "${st.obj.getName()}",
173
+ localClass: "${st.localClass}",
174
+ methods: ${JSON.stringify(methods)},
175
+ riskLevel: "${st.riskLevel}",
176
+ filename: "${st.filename}"});\n`;
180
177
  }
181
- ret += `// -------------------END-------------------
178
+ ret += ` return ret;
179
+ }
180
+
181
+ async function run() {
182
+ const skipCritical = process.argv[2] === "--skip-critical";
183
+ const onlyCritical = process.argv[2] === "--only-critical";
184
+ await initializeABAP();
185
+ for (const st of getData()) {
186
+ const imported = await import(st.filename);
187
+ const localClass = imported[st.localClass];
188
+ if (localClass.class_setup) await localClass.class_setup();
189
+ for (const m of st.methods) {
190
+ const prefix = st.objectName + ": running " + st.localClass + "->" + m.name;
191
+ if (m.skip) {
192
+ console.log(prefix + ", skipped due to configuration");
193
+ } else if (skipCritical && st.riskLevel === "CRITICAL") {
194
+ console.log(prefix + ", skipped due to risk level " + st.riskLevel);
195
+ } else if (onlyCritical && st.riskLevel !== "CRITICAL") {
196
+ console.log(prefix + ", skipped due to risk level " + st.riskLevel);
197
+ } else {
198
+ const test = await (new localClass()).constructor_();
199
+ ${callSpecial("setup")}
200
+ console.log(prefix);
201
+ await test.FRIENDS_ACCESS_INSTANCE[m.name]();
202
+ ${callSpecial("teardown")}
203
+ }
204
+ }
205
+ if (localClass.class_teardown) await localClass.class_teardown();
206
+ }
182
207
  }
183
208
 
184
209
  run().then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.10.39",
3
+ "version": "2.10.41",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",