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AC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACvD,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;iBACrB,GAAG,CAAC,UAAA,GAAG,IAAI,OAAG,GAAG,UAAK,KAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAG,EAAnD,CAAmD,CAAC;iBAC/D,IAAI,CAAC,GAAG,CAAC,CAAC;YAEb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAc,IAAI,SAAI,IAAI,QAAK,CAAC,CAAC;QACrD,CAAC;QA7ID;YADC,uBAAY,EAAE;gDAGd;QAGD;YADC,uBAAY,EAAE;iDAMd;QAGD;YADC,uBAAY,EAAE;+CA4Bd;QAGD;YADC,uBAAY,EAAE;kDAOd;QAGD;YADC,uBAAY,EAAE;gDAmBd;QAwEH,eAAC;KAAA,AApJD,CAAsC,kBAAQ,GAoJ7C;sBApJoB,QAAQ","sourcesContent":["import Reporter, { eventHandler } from './Reporter';\nimport Test from '../Test';\nimport Suite, { isSuite } from '../Suite';\n\n/**\n * This reporter enables Intern to interact with TeamCity.\n * http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity\n *\n * Portions of this module are based on functions from\n * teamcity-service-messages:\n * https://github.com/pifantastic/teamcity-service-messages.\n */\nexport default class TeamCity extends Reporter {\n _ignoredTestIds:\n | { [sessionId: string]: { [testId: string]: boolean } }\n | undefined;\n\n @eventHandler()\n runStart() {\n this._ignoredTestIds = {};\n }\n\n @eventHandler()\n testStart(test: Test) {\n this._sendMessage('testStarted', {\n name: test.name,\n flowId: test.sessionId\n });\n }\n\n @eventHandler()\n testEnd(test: Test) {\n if (test.error) {\n const message: any = {\n name: test.name,\n message: this.formatError(test.error),\n flowId: test.sessionId\n };\n\n if (test.error.actual && test.error.expected) {\n message.type = 'comparisonFailure';\n message.expected = test.error.expected;\n message.actual = test.error.actual;\n }\n\n this._sendMessage('testFailed', message);\n } else if (test.skipped) {\n this._sendMessage('testIgnored', {\n name: test.name,\n flowId: test.sessionId\n });\n } else {\n this._sendMessage('testFinished', {\n name: test.name,\n duration: test.timeElapsed,\n flowId: test.sessionId\n });\n }\n }\n\n @eventHandler()\n suiteStart(suite: Suite) {\n this._sendMessage('testSuiteStarted', {\n name: suite.name,\n startDate: new Date(),\n flowId: suite.sessionId\n });\n }\n\n @eventHandler()\n suiteEnd(suite: Suite) {\n if (suite.error) {\n this._sendMessage('message', {\n name: suite.name,\n flowId: suite.sessionId,\n text: 'SUITE ERROR',\n errorDetails: this.formatError(suite.error),\n status: 'ERROR'\n });\n\n this._notifyUnrunTests(suite);\n } else {\n this._sendMessage('testSuiteFinished', {\n name: suite.name,\n duration: suite.timeElapsed,\n flowId: suite.sessionId\n });\n }\n }\n\n /**\n * Escape a string for TeamCity output.\n *\n * @param {string} string\n * @return {string}\n *\n * Based on Message.prototype.escape from teamcity-service-messages\n */\n private _escapeString(str: string): string {\n const replacer = /['\\n\\r\\|\\[\\]\\u0100-\\uffff]/g;\n const map = {\n \"'\": \"|'\",\n '|': '||',\n '\\n': '|n',\n '\\r': '|r',\n '[': '|[',\n ']': '|]'\n };\n\n return str.replace(replacer, function(character: string): string {\n if (character in map) {\n return (<{ [key: string]: any }>map)[character];\n }\n if (/[^\\u0000-\\u00ff]/.test(character)) {\n return '|0x' + character.charCodeAt(0).toString(16);\n }\n return '';\n });\n }\n\n private _notifyUnrunTests(suite: Suite) {\n // Keep track of test IDs that have already been ignored for a given\n // session. This prevents the reporter from emitting duplicate\n // testIgnored messages for unrun tests in nested suites as parent\n // suites are finished.\n const ignoredTestIds = this._ignoredTestIds!;\n let ignoredTests = ignoredTestIds![suite.sessionId];\n if (!ignoredTests) {\n ignoredTests = ignoredTestIds![suite.sessionId] = {};\n }\n\n suite.tests.forEach(test => {\n if (isSuite(test)) {\n this._notifyUnrunTests(test);\n } else if (!ignoredTests[test.id]) {\n this._sendMessage('testIgnored', {\n name: test.name,\n flowId: test.sessionId\n });\n ignoredTests[test.id] = true;\n }\n });\n }\n\n /**\n * Output a TeamCity message.\n *\n * @param {string} type\n * @param {Object} args\n *\n * Based on Message.prototype.formatArgs from teamcity-service-messages\n */\n private _sendMessage(type: string, args: any): void {\n args.timestamp = new Date().toISOString().slice(0, -1);\n args = Object.keys(args)\n .map(key => `${key}='${this._escapeString(String(args[key]))}'`)\n .join(' ');\n\n this.output.write(`##teamcity[${type} ${args}]\\n`);\n }\n}\n"]}
\No newline at end of file