Skip to content
Permalink
Browse files

Close #36

  • Loading branch information...
thiagodp committed Apr 20, 2019
1 parent b6f31e4 commit 059099e6a898f00e7bc3c695b99b7ff015a5c0ff
@@ -26,6 +26,7 @@ const TestResultAnalyzer_1 = require("../testscript/TestResultAnalyzer");
const GuidedConfig_1 = require("./GuidedConfig");
const fs_1 = require("fs");
const util_1 = require("util");
const path_1 = require("path");
/**
* Application controller
*
@@ -243,12 +244,20 @@ class AppController {
cli.newLine(cli.symbolInfo, 'Script execution disabled.');
}
if (options.analyzeResult) { // Requires a plugin
let reportFile;
if (!executionResult) {
cli.newLine(cli.symbolError, 'Could not retrieve execution results.');
return false;
const defaultReportFile = path_1.join(options.dirResult, yield plugin.defaultReportFile());
if (!fs_1.existsSync(defaultReportFile)) {
cli.newLine(cli.symbolError, 'Could not retrieve execution results.');
return false;
}
reportFile = defaultReportFile;
}
else {
reportFile = executionResult.sourceFile;
}
try {
let reportedResult = yield plugin.convertReportFile(executionResult.sourceFile);
let reportedResult = yield plugin.convertReportFile(reportFile);
(new TestResultAnalyzer_1.TestResultAnalyzer()).adjustResult(reportedResult, abstractTestScripts);
(new CliScriptExecutionReporter_1.CliScriptExecutionReporter(cli)).scriptExecuted(reportedResult);
}
@@ -66,6 +66,12 @@ class CodeceptJS {
return yield reportConverter.convertFrom(filePath, this._descriptorPath);
});
}
/** @inheritDoc */
defaultReportFile() {
return __awaiter(this, void 0, void 0, function* () {
return 'output.json';
});
}
/**
* Tries to generate a source code file from an abstract test script.
*
@@ -15,9 +15,16 @@ const TestScriptExecution_1 = require("../../modules/testscript/TestScriptExecut
* @author Thiago Delgado Pinto
*/
class Fake {
constructor() {
/** @inheritDoc */
this.executeCode = (options) => __awaiter(this, void 0, void 0, function* () {
/** @inheritDoc */
generateCode(abstractTestScripts, options, errors) {
return __awaiter(this, void 0, void 0, function* () {
return []; // No files
});
}
;
/** @inheritDoc */
executeCode(options) {
return __awaiter(this, void 0, void 0, function* () {
let r = new TestScriptExecution_1.TestScriptExecutionResult();
r.sourceFile = 'nofile.json';
r.schemaVersion = '1.0';
@@ -36,16 +43,18 @@ class Fake {
return r;
});
}
;
/** @inheritDoc */
generateCode(abstractTestScripts, options, errors) {
convertReportFile(filePath) {
return __awaiter(this, void 0, void 0, function* () {
return []; // No files
throw new Error("Method not implemented: convertReportFile.");
});
}
;
/** @inheritDoc */
convertReportFile(filePath) {
throw new Error("Method not implemented: convertReportFile.");
defaultReportFile() {
return __awaiter(this, void 0, void 0, function* () {
return 'fake-output.json';
});
}
}
exports.Fake = Fake;
@@ -20,8 +20,9 @@ import * as updateNotifier from 'update-notifier';
import { AbstractTestScript } from '../testscript/AbstractTestScript';
import { TestResultAnalyzer } from '../testscript/TestResultAnalyzer';
import { GuidedConfig } from './GuidedConfig';
import { writeFile } from 'fs';
import { writeFile, existsSync } from 'fs';
import { promisify } from 'util';
import { join } from 'path';

/**
* Application controller
@@ -276,12 +277,25 @@ export class AppController {
}

if ( options.analyzeResult ) { // Requires a plugin

let reportFile: string;
if ( ! executionResult ) {
cli.newLine( cli.symbolError, 'Could not retrieve execution results.' );
return false;

const defaultReportFile: string = join(
options.dirResult, await plugin.defaultReportFile() );

if ( ! existsSync( defaultReportFile ) ) {
cli.newLine( cli.symbolError, 'Could not retrieve execution results.' );
return false;
}

reportFile = defaultReportFile;
} else {
reportFile = executionResult.sourceFile;
}

try {
let reportedResult = await plugin.convertReportFile( executionResult.sourceFile );
let reportedResult = await plugin.convertReportFile( reportFile );
( new TestResultAnalyzer() ).adjustResult( reportedResult, abstractTestScripts );
( new CliScriptExecutionReporter( cli ) ).scriptExecuted( reportedResult );
} catch ( err ) {
@@ -39,4 +39,10 @@ export interface Plugin {
*/
convertReportFile( filePath: string ): Promise< TestScriptExecutionResult >;

/**
* Returns the default report file name. Concordia may look for it in the
* output/result directory when the parameter `--just-report` is given.
*/
defaultReportFile(): Promise< string >;

}
@@ -69,6 +69,11 @@ export class CodeceptJS implements Plugin {
return await reportConverter.convertFrom( filePath, this._descriptorPath );
}

/** @inheritDoc */
public async defaultReportFile(): Promise< string > {
return 'output.json';
}

/**
* Tries to generate a source code file from an abstract test script.
*
@@ -20,7 +20,7 @@ export class Fake implements Plugin {
};

/** @inheritDoc */
public executeCode = async (options: TestScriptExecutionOptions): Promise< TestScriptExecutionResult > => {
public async executeCode(options: TestScriptExecutionOptions): Promise< TestScriptExecutionResult > {

let r = new TestScriptExecutionResult();
r.sourceFile = 'nofile.json';
@@ -42,8 +42,13 @@ export class Fake implements Plugin {
};

/** @inheritDoc */
public convertReportFile(filePath: string): Promise< TestScriptExecutionResult > {
public async convertReportFile(filePath: string): Promise< TestScriptExecutionResult > {
throw new Error("Method not implemented: convertReportFile.");
}

/** @inheritDoc */
public async defaultReportFile(): Promise< string > {
return 'fake-output.json';
}

}

0 comments on commit 059099e

Please sign in to comment.
You can’t perform that action at this time.