Skip to content

Commit fe2a09b

Browse files
committed
refactor(perf): e2e tests and benchpress should be written in es6
1 parent 373fd7d commit fe2a09b

File tree

17 files changed

+96
-20
lines changed

17 files changed

+96
-20
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
1. `npm install`
88
2. `npm install -g gulp karma karma-cli`
9+
3. `npm install -g protractor`
10+
4. `webdriver-manager update`
911
3. Optionally install Dart SDK (only if you plan on building Dart applications)
1012
1. [Install the Dart SDK](https://www.dartlang.org/tools/sdk/)
1113
2. [Add the Dart SDK's `bin` directory to your system path](https://www.dartlang.org/tools/pub/installing.html)
@@ -34,18 +36,24 @@
3436

3537
2. `gulp clean` -> cleans the `dist` folder
3638

37-
### Tests:
39+
### Unit tests:
3840

3941
1. `karma start karma-js.conf.js`: JS tests
4042
2. `karma start karma-dart.conf.js`: Dart tests
4143

42-
Notes for all tests:
44+
Notes for transpiler tests:
4345

4446
The karma preprocessor is setup in a way so that after every test run
4547
the transpiler is reloaded. With that it is possible to make changes
4648
to the preprocessor and run the tests without exiting karma
4749
(just touch a test file that you would like to run).
4850

51+
### Performance tests
52+
53+
1. `gulp build.cjs` (builds benchpress and tests into `dist/cjs` folder)
54+
2. `protractor protractor-perf-js.conf.js`: JS performance tests
55+
3. `protractor protractor-perf-dart2js.conf.js`: Dart2JS performance tests
56+
4957
### Examples:
5058

5159
To see the examples, first build the project as described above.

gulpfile.js

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ var _COMPILER_CONFIG_JS_DEFAULT = {
2727
modules: 'instantiate'
2828
};
2929

30+
var CJS_COMPILER_OPTIONS = {
31+
sourceMaps: true,
32+
annotations: false, // parse annotations
33+
types: false, // parse types
34+
// TODO(tbosch): Right now, traceur generates imports that
35+
// rely on absolute paths. This is why we are not using this...
36+
script: true, // parse as a script
37+
memberVariables: false, // parse class fields
38+
typeAssertions: false,
39+
modules: null // not needed
40+
};
41+
3042
var _HTLM_DEFAULT_SCRIPTS_JS = [
3143
{src: '/deps/traceur-runtime.js', mimeType: 'text/javascript'},
3244
{src: '/rtts_assert/lib/rtts_assert.js', mimeType: 'text/javascript'},
@@ -51,7 +63,12 @@ var CONFIG = {
5163
prod: 'dist/js/prod',
5264
dart2js: 'dist/js/dart2js'
5365
},
54-
dart: 'dist/dart'
66+
dart: 'dist/dart',
67+
cjs: {
68+
all: 'dist/cjs',
69+
tools: 'dist/cjs/tools',
70+
e2eTest: 'dist/cjs/e2e_test'
71+
}
5572
},
5673
srcFolderMapping: {
5774
'default': 'lib',
@@ -72,12 +89,20 @@ var CONFIG = {
7289
},
7390
transpile: {
7491
src: {
75-
js: ['modules/**/*.js', 'modules/**/*.es6', '!modules/**/perf/**/*'],
76-
dart: ['modules/**/*.js', '!modules/**/perf/**/*']
92+
js: ['modules/**/*.js', 'modules/**/*.es6', '!modules/**/e2e_test/**'],
93+
dart: ['modules/**/*.js', '!modules/**/e2e_test/**'],
94+
cjs: {
95+
tools: ['tools/**/*.es6', '!tools/transpiler/**'],
96+
e2eTest: ['modules/**/e2e_test/**/*.es6']
97+
}
7798
},
7899
copy: {
79-
js: ['modules/**/*.es5', '!modules/**/perf/**/*'],
80-
dart: ['modules/**/*.dart', '!modules/**/perf/**/*']
100+
js: ['modules/**/*.es5', '!modules/**/e2e_test/**'],
101+
dart: ['modules/**/*.dart', '!modules/**/e2e_test/**'],
102+
cjs: {
103+
tools: ['tools/**/*.es5', '!tools/transpiler/**'],
104+
e2eTest: ['modules/**/e2e_test/**/*.es5']
105+
}
81106
},
82107
options: {
83108
js: {
@@ -96,7 +121,8 @@ var CONFIG = {
96121
script: false, // parse as a module
97122
memberVariables: true, // parse class fields
98123
outputLanguage: 'dart'
99-
}
124+
},
125+
cjs: CJS_COMPILER_OPTIONS
100126
}
101127
},
102128
html: {
@@ -134,6 +160,11 @@ gulp.task('build/clean.dart', clean(gulp, gulpPlugins, {
134160
path: CONFIG.dest.dart
135161
}));
136162

163+
gulp.task('build/clean.cjs', clean(gulp, gulpPlugins, {
164+
path: CONFIG.dest.cjs.all
165+
}));
166+
167+
137168
// ------------
138169
// deps
139170

@@ -177,6 +208,28 @@ gulp.task('build/transpile.dart', transpile(gulp, gulpPlugins, {
177208
srcFolderMapping: CONFIG.srcFolderMapping
178209
}));
179210

211+
gulp.task('build/transpile/tools.cjs', transpile(gulp, gulpPlugins, {
212+
src: CONFIG.transpile.src.cjs.tools,
213+
copy: CONFIG.transpile.copy.cjs.tools,
214+
dest: CONFIG.dest.cjs.tools,
215+
outputExt: 'js',
216+
options: CONFIG.transpile.options.cjs,
217+
srcFolderMapping: {
218+
'default': 'src'
219+
}
220+
}));
221+
222+
gulp.task('build/transpile/e2eTest.cjs', transpile(gulp, gulpPlugins, {
223+
src: CONFIG.transpile.src.cjs.e2eTest,
224+
copy: CONFIG.transpile.copy.cjs.e2eTest,
225+
dest: CONFIG.dest.cjs.e2eTest,
226+
outputExt: 'js',
227+
options: CONFIG.transpile.options.cjs,
228+
srcFolderMapping: {
229+
'default': 'src'
230+
}
231+
}));
232+
180233
// ------------
181234
// html
182235

@@ -339,8 +392,14 @@ gulp.task('build.js.prod', function() {
339392
);
340393
});
341394

395+
gulp.task('build.cjs', function() {
396+
return runSequence(
397+
['build/transpile/tools.cjs', 'build/transpile/e2eTest.cjs']
398+
);
399+
});
400+
342401
gulp.task('build.js', ['build.js.dev', 'build.js.prod']);
343402

344-
gulp.task('clean', ['build/clean.js', 'build/clean.dart']);
403+
gulp.task('clean', ['build/clean.js', 'build/clean.dart', 'build/clean.cjs']);
345404

346-
gulp.task('build', ['build.js', 'build.dart']);
405+
gulp.task('build', ['build.js', 'build.dart', 'build.cjs']);

modules/benchmarks/test/perf/change_detection_perf.js renamed to modules/benchmarks/e2e_test/change_detection_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng2 change detection benchmark', function () {
55

modules/benchmarks/test/perf/compiler_perf.js renamed to modules/benchmarks/e2e_test/compiler_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng2 compiler benchmark', function () {
55

modules/benchmarks/test/perf/di_perf.js renamed to modules/benchmarks/e2e_test/di_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng2 di benchmark', function () {
55

modules/benchmarks/test/perf/element_injector_perf.js renamed to modules/benchmarks/e2e_test/element_injector_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng2 element injector benchmark', function () {
55

modules/benchmarks/test/perf/tree_perf.js renamed to modules/benchmarks/e2e_test/tree_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng2 tree benchmark', function () {
55

modules/benchmarks_external/test/perf/compiler_perf.js renamed to modules/benchmarks_external/e2e_test/compiler_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng1.x compiler benchmark', function () {
55

modules/benchmarks_external/test/perf/tree_perf.js renamed to modules/benchmarks_external/e2e_test/tree_perf.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var benchpress = require('../../../../tools/benchpress/benchpress.js');
2+
var benchpress = require('../../../tools/benchpress/index.js');
33

44
describe('ng1.x tree benchmark', function () {
55

protractor-perf-shared.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
// load traceur runtime as our tests are written in es6
2+
require('traceur/bin/traceur-runtime.js');
3+
14
var config = exports.config = {
25

3-
specs: ['modules/*/test/**/*_perf.js'],
6+
specs: ['dist/cjs/**/*_perf.js'],
47

58
params: {
69
timeBenchmark: {

0 commit comments

Comments
 (0)