Fix test logging for Windows

This commit is contained in:
Ilya Goncharov
2019-10-04 13:55:20 +03:00
parent f950a0246c
commit d2c2128aad
3 changed files with 29 additions and 8 deletions
@@ -105,14 +105,29 @@ const KarmaKotlinReporter = function (baseReporterDecorator, config, emitter) {
this.TEST_STD_OUT = "##teamcity[testStdOut name='%s' out='%s' flowId='']";
const END_KOTLIN_TEST = "'--END_KOTLIN_TEST--";
const tcOnBrowserStart = this.onBrowserStart;
this.onBrowserStart = function (browser) {
tcOnBrowserStart.call(this, browser);
this.browserResults[browser.id].consoleCollector = [];
this.browserResults[browser.id].consoleResultCollector = {};
};
const concatenateFqn = function (result) {
return `${result.suite.join(".")}.${result.description}`
};
this.onBrowserLog = (browser, log, type) => {
const browserResult = this.browserResults[browser.id];
if (log.startsWith(END_KOTLIN_TEST)) {
var result = JSON.parse(log.substring(END_KOTLIN_TEST.length, log.length - 1));
browserResult.consoleResultCollector[concatenateFqn(result)] = browserResult.consoleCollector;
browserResult.consoleCollector = [];
return
}
if (browserResult) {
browserResult.consoleCollector.push(`[${type}] ${log}\n`)
}
@@ -126,14 +141,12 @@ const KarmaKotlinReporter = function (baseReporterDecorator, config, emitter) {
const testName = result.description;
const endMessage = log.pop();
this.browserResults[browser.id].consoleCollector.forEach(item => {
this.browserResults[browser.id].consoleResultCollector[concatenateFqn(result)].forEach(item => {
log.push(
formatMessage(this.TEST_STD_OUT, testName, item)
)
});
log.push(endMessage);
this.browserResults[browser.id].consoleCollector = []
};
this.specFailure = function (browser, result) {
@@ -141,7 +154,7 @@ const KarmaKotlinReporter = function (baseReporterDecorator, config, emitter) {
const testName = result.description;
log.push(formatMessage(this.TEST_START, testName));
this.browserResults[browser.id].consoleCollector.forEach(item => {
this.browserResults[browser.id].consoleResultCollector[concatenateFqn(result)].forEach(item => {
log.push(
formatMessage(this.TEST_STD_OUT, testName, item)
)
@@ -153,8 +166,6 @@ const KarmaKotlinReporter = function (baseReporterDecorator, config, emitter) {
.join('\n\n')
));
log.push(formatMessage(this.TEST_END, testName, result.time));
this.browserResults[browser.id].consoleCollector = []
};
this.flushLogs = function (browserResult) {
@@ -20,4 +20,10 @@ const parser = new CliArgsParser(cliDescription);
const untypedArgs = parser.parse(processArgs);
const initialAdapter = kotlin_test.kotlin.test.detectAdapter_8be2vx$();
kotlin_test.setAdapter(getFilteringAdapter(initialAdapter, untypedArgs));
kotlin_test.setAdapter(getFilteringAdapter(initialAdapter, untypedArgs));
const resultFun = window.__karma__.result;
window.__karma__.result = function (result) {
console.log(`--END_KOTLIN_TEST--\n${JSON.stringify(result)}`);
resultFun(result)
};
+5 -1
View File
@@ -7,6 +7,10 @@ interface Window {
__karma__: {
config: {
args: string[]
}
},
result: (result: BrowserResult) => void
}
}
interface BrowserResult {
}