2021-11-25 09:38:50 +01:00
|
|
|
import { spawnSync } from 'child_process';
|
|
|
|
|
import { join, resolve } from 'path';
|
|
|
|
|
import {expect} from "chai";
|
|
|
|
|
import * as fs from "fs";
|
2021-11-24 06:48:56 +01:00
|
|
|
|
|
|
|
|
const root = resolve(__dirname, '../..');
|
2021-11-25 09:38:50 +01:00
|
|
|
const fixtures = resolve(root, 'tests');
|
2021-11-24 06:48:56 +01:00
|
|
|
const bin = resolve(root, 'bin');
|
|
|
|
|
const run = resolve(bin, 'run.sh');
|
2021-11-25 09:38:50 +01:00
|
|
|
const output = join(root, 'output');
|
|
|
|
|
const outputFile = join(output, "results.json");
|
|
|
|
|
|
|
|
|
|
function readResult(): any {
|
|
|
|
|
return JSON.parse(fs.readFileSync(outputFile, "utf-8"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkExpected(expectedFile: string): void {
|
|
|
|
|
const exp = fs.readFileSync(expectedFile, "utf-8");
|
|
|
|
|
const act = fs.readFileSync(outputFile, "utf-8");
|
|
|
|
|
expect(act).to.equal(exp);
|
|
|
|
|
}
|
2021-11-24 06:48:56 +01:00
|
|
|
|
2021-11-25 18:23:15 +01:00
|
|
|
function test(slug: string, expectedStatus: string) {
|
|
|
|
|
const path = join(fixtures, slug);
|
|
|
|
|
const res = spawnSync('bash', [run, slug, path, output], {cwd: root});
|
2022-01-05 10:52:07 +01:00
|
|
|
expect(res.status).to.equal(0, res.stdout.toString());
|
2021-11-25 18:23:15 +01:00
|
|
|
checkExpected(join(path, "expected_results.json"));
|
|
|
|
|
expect(readResult().status).to.equal(expectedStatus);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-24 06:48:56 +01:00
|
|
|
describe('abap-test-runner', async () => {
|
|
|
|
|
it('simple, pass', async () => {
|
2021-11-25 18:23:15 +01:00
|
|
|
test("simple-pass", "pass");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('simple-fail', async () => {
|
|
|
|
|
test("simple-fail", "fail");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('simple-error', async () => {
|
|
|
|
|
test("simple-error", "error");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('hello-world-pass', async () => {
|
|
|
|
|
test("hello-world-pass", "pass");
|
2021-11-25 09:38:50 +01:00
|
|
|
});
|
|
|
|
|
|
2021-11-25 18:23:15 +01:00
|
|
|
it('simple-all-fail', async () => {
|
|
|
|
|
test("simple-all-fail", "fail");
|
2021-11-25 09:38:50 +01:00
|
|
|
});
|
|
|
|
|
|
2021-11-25 18:23:15 +01:00
|
|
|
it('simple-some-fail', async () => {
|
|
|
|
|
test("simple-some-fail", "fail");
|
2021-11-25 09:38:50 +01:00
|
|
|
});
|
|
|
|
|
|
2021-11-25 18:23:15 +01:00
|
|
|
it('simple-downport-pass', async () => {
|
|
|
|
|
test("simple-downport-pass", "pass");
|
2021-11-24 06:48:56 +01:00
|
|
|
});
|
2021-11-27 10:14:13 +01:00
|
|
|
|
|
|
|
|
it('simple-downport-definitions_top-pass', async () => {
|
|
|
|
|
test("simple-downport-definitions_top-pass", "pass");
|
|
|
|
|
});
|
2022-01-05 10:52:07 +01:00
|
|
|
|
|
|
|
|
it('use-ddic-string-table', async () => {
|
|
|
|
|
test("use-ddic-string-table", "pass");
|
|
|
|
|
});
|
2022-09-19 17:28:33 +02:00
|
|
|
|
|
|
|
|
it('unknown-variable', async () => {
|
|
|
|
|
test("unknown-variable", "error");
|
|
|
|
|
});
|
2022-09-20 15:14:19 +02:00
|
|
|
|
|
|
|
|
it('escape-new-line', async () => {
|
|
|
|
|
test("escape-new-line", "fail");
|
|
|
|
|
});
|
|
|
|
|
|
2022-09-25 11:39:30 +02:00
|
|
|
it('chained-assignment', async () => {
|
|
|
|
|
test("chained-assignment", "fail");
|
2022-09-20 15:14:19 +02:00
|
|
|
});
|
2022-09-23 08:49:28 +02:00
|
|
|
|
|
|
|
|
it('structure-fail', async () => {
|
|
|
|
|
test("structure-fail", "fail");
|
|
|
|
|
});
|
2022-10-07 12:11:27 +02:00
|
|
|
|
|
|
|
|
it('break-point-error', async () => {
|
|
|
|
|
test("break-point-error", "error");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('implement-method-error', async () => {
|
|
|
|
|
test("implement-method-error", "error");
|
|
|
|
|
});
|
2022-12-15 14:12:01 +01:00
|
|
|
|
|
|
|
|
it('console-log', async () => {
|
|
|
|
|
test("console-log", "pass");
|
|
|
|
|
});
|
2023-01-24 15:21:46 +01:00
|
|
|
|
|
|
|
|
it('keyword-error', async () => {
|
|
|
|
|
test("keyword-error", "error");
|
|
|
|
|
});
|
2021-11-24 06:48:56 +01:00
|
|
|
});
|