Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions karma-js.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/

const browserProvidersConf = require('./browser-providers.conf');
const {generateSeed} = require('./tools/jasmine-seed-generator');
var browserProvidersConf = require('./browser-providers.conf.js');
var internalAngularReporter = require('./tools/karma/reporter.js');

// Karma configuration
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
Expand Down Expand Up @@ -85,6 +85,7 @@ module.exports = function(config) {
'karma-sauce-launcher',
'karma-chrome-launcher',
'karma-sourcemap-loader',
internalAngularReporter,
],

preprocessors: {
Expand All @@ -101,7 +102,7 @@ module.exports = function(config) {
'/base/angular/': '/base/',
},

reporters: ['dots'],
reporters: ['internal-angular'],
sauceLabs: {
testName: 'Angular2',
retryLimit: 3,
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/test-saucelabs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ source ${thisDir}/_travis-fold.sh
travisFoldStart "test.unit.saucelabs"
./scripts/sauce/sauce_connect_block.sh
SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`
$(npm bin)/karma start ./karma-js.conf.js --single-run --browsers=${KARMA_JS_BROWSERS} --reporters dots,saucelabs
$(npm bin)/karma start ./karma-js.conf.js --single-run --browsers=${KARMA_JS_BROWSERS} --reporters internal-angular,saucelabs
travisFoldEnd "test.unit.saucelabs"
67 changes: 67 additions & 0 deletions tools/karma/reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

var SourceMapConsumer = require('source-map').SourceMapConsumer;
var DotsReporter = require('karma/lib/reporters/dots_color');

var createErrorFormatter = function(basePath, emitter, SourceMapConsumer) {
var lastServedFiles = [];
emitter.on('file_list_modified', function(files) { lastServedFiles = files.served; });
function findFile(path) { return lastServedFiles.filter(_ => _.path === path)[0]; }

var URL_REGEXP = new RegExp(
'(?:https?:\\/\\/[^\\/]*)?\\/?' +
'(base|absolute)' + // prefix
'((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path
'(\\?\\w*)?' + // sha
'(\\:(\\d+))?' + // line
'(\\:(\\d+))?' + // column
'',
'g');

return function(msg, indentation) {
msg = (msg || '').replace(URL_REGEXP, function(_, prefix, path, __, ___, line, ____, column) {
if (prefix === 'base') {
path = basePath + path;
}
line = parseInt(line || '0', 10);
column = parseInt(column || '0', 10);

var file = findFile(path);
if (file && file.sourceMap) {
try {
var original = new SourceMapConsumer(file.sourceMap)
.originalPositionFor({line: line, column: column});
return process.cwd() + '/modules/' + original.source + ':' + original.line + ':' +
original.column;
} catch (e) {
console.warn('SourceMap position not found for trace: %s', msg);
}
}
return path + ':' + line + ':' + column;
});

// indent every line
if (indentation) {
msg = indentation + msg.replace(/\n/g, '\n' + indentation);
}
return msg + '\n';
};
};


var InternalAngularReporter = function(config, emitter) {
var formatter = createErrorFormatter(config.basePath, emitter, SourceMapConsumer);
DotsReporter.call(this, formatter, false, config.colors);
};

InternalAngularReporter.$inject = ['config', 'emitter'];

module.exports = {
'reporter:internal-angular': ['type', InternalAngularReporter]
};
5 changes: 3 additions & 2 deletions tools/tsc-watch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
*/

/* tslint:disable:no-console */
import {existsSync, mkdirSync} from 'fs';
import {spawn} from 'child_process';
import {existsSync, mkdirSync, writeFileSync} from 'fs';

import {TscWatch} from './tsc_watch';
import {TSC, TscWatch, reportError} from './tsc_watch';

export * from './tsc_watch';
import 'reflect-metadata';
Expand Down
1 change: 1 addition & 0 deletions tools/tsc-watch/tsc_watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import {spawn} from 'child_process';
import {platform} from 'os';
import {normalize} from 'path';
import {resolve} from 'url';

enum State {
idle,
Expand Down