From 60471c092f23057e3fd4b4deebe190795f93ac9f Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Wed, 5 Feb 2020 09:39:29 -0800 Subject: [PATCH] refactor(benchpress): added tsconfig to ts_library rules and awaited floating promises (#35147) * Note: we specify our own tsconfig bc the default tsconfig we provide for ts_library disables the must-use-promises rule PR Close #35147 --- modules/benchmarks/src/class_bindings/BUILD.bazel | 1 + .../src/class_bindings/class_bindings.perf-spec.ts | 4 ++-- modules/benchmarks/src/expanding_rows/BUILD.bazel | 1 + .../src/expanding_rows/expanding_rows.perf-spec.ts | 2 +- modules/benchmarks/src/js-web-frameworks/BUILD.bazel | 1 + .../js-web-frameworks/js-web-frameworks.perf-spec.ts | 2 +- modules/benchmarks/src/largetable/BUILD.bazel | 2 ++ .../benchmarks/src/largetable/largetable.perf-spec.ts | 2 +- modules/benchmarks/src/tree/BUILD.bazel | 6 ++++++ modules/benchmarks/src/tree/tree.e2e-spec.ts | 10 +++++----- modules/benchmarks/src/tree/tree.perf-spec.ts | 8 ++++---- .../src/tree/tree_detect_changes.e2e-spec.ts | 2 +- 12 files changed, 26 insertions(+), 15 deletions(-) diff --git a/modules/benchmarks/src/class_bindings/BUILD.bazel b/modules/benchmarks/src/class_bindings/BUILD.bazel index da310ba857..3f69c4c2e8 100644 --- a/modules/benchmarks/src/class_bindings/BUILD.bazel +++ b/modules/benchmarks/src/class_bindings/BUILD.bazel @@ -23,6 +23,7 @@ ts_library( name = "perf_lib", testonly = 1, srcs = ["class_bindings.perf-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", "@npm//protractor", diff --git a/modules/benchmarks/src/class_bindings/class_bindings.perf-spec.ts b/modules/benchmarks/src/class_bindings/class_bindings.perf-spec.ts index 4d78e6177f..41486c5ce6 100644 --- a/modules/benchmarks/src/class_bindings/class_bindings.perf-spec.ts +++ b/modules/benchmarks/src/class_bindings/class_bindings.perf-spec.ts @@ -13,7 +13,7 @@ describe('class bindings perf', () => { it('should work for update', async() => { browser.rootEl = '#root'; - runBenchmark({ + await runBenchmark({ id: 'create', url: '', ignoreBrowserSynchronization: true, @@ -25,7 +25,7 @@ describe('class bindings perf', () => { it('should work for update', async() => { browser.rootEl = '#root'; - runBenchmark({ + await runBenchmark({ id: 'update', url: '', ignoreBrowserSynchronization: true, diff --git a/modules/benchmarks/src/expanding_rows/BUILD.bazel b/modules/benchmarks/src/expanding_rows/BUILD.bazel index 20f72503e8..1969ca038b 100644 --- a/modules/benchmarks/src/expanding_rows/BUILD.bazel +++ b/modules/benchmarks/src/expanding_rows/BUILD.bazel @@ -24,6 +24,7 @@ ts_library( name = "perf_lib", testonly = 1, srcs = ["expanding_rows.perf-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", "@npm//protractor", diff --git a/modules/benchmarks/src/expanding_rows/expanding_rows.perf-spec.ts b/modules/benchmarks/src/expanding_rows/expanding_rows.perf-spec.ts index af0866b081..ee4bab2193 100644 --- a/modules/benchmarks/src/expanding_rows/expanding_rows.perf-spec.ts +++ b/modules/benchmarks/src/expanding_rows/expanding_rows.perf-spec.ts @@ -13,7 +13,7 @@ describe('benchmarks', () => { it('should work for create', async() => { browser.rootEl = '#root'; - runBenchmark({ + await runBenchmark({ id: 'create', url: '', ignoreBrowserSynchronization: true, diff --git a/modules/benchmarks/src/js-web-frameworks/BUILD.bazel b/modules/benchmarks/src/js-web-frameworks/BUILD.bazel index 8ffae59af6..4889b86f71 100644 --- a/modules/benchmarks/src/js-web-frameworks/BUILD.bazel +++ b/modules/benchmarks/src/js-web-frameworks/BUILD.bazel @@ -6,6 +6,7 @@ ts_library( name = "perf_lib", testonly = True, srcs = ["js-web-frameworks.perf-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", "@npm//protractor", diff --git a/modules/benchmarks/src/js-web-frameworks/js-web-frameworks.perf-spec.ts b/modules/benchmarks/src/js-web-frameworks/js-web-frameworks.perf-spec.ts index cac361f166..0ed6859aa6 100644 --- a/modules/benchmarks/src/js-web-frameworks/js-web-frameworks.perf-spec.ts +++ b/modules/benchmarks/src/js-web-frameworks/js-web-frameworks.perf-spec.ts @@ -54,7 +54,7 @@ describe('js-web-frameworks benchmark perf', () => { [Create1KWorker, Delete1KWorker, UpdateWorker, SwapWorker].forEach((worker) => { describe(worker.id, () => { it(`should run benchmark for ${testPackageName}`, async() => { - runTableBenchmark({ + await runTableBenchmark({ id: `js-web-frameworks.${testPackageName}.${worker.id}`, url: '/', ignoreBrowserSynchronization: true, diff --git a/modules/benchmarks/src/largetable/BUILD.bazel b/modules/benchmarks/src/largetable/BUILD.bazel index 43be9bd533..766394d453 100644 --- a/modules/benchmarks/src/largetable/BUILD.bazel +++ b/modules/benchmarks/src/largetable/BUILD.bazel @@ -5,6 +5,7 @@ package(default_visibility = ["//visibility:public"]) ts_library( name = "util_lib", srcs = ["util.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = ["//modules/benchmarks/src:util_lib"], ) @@ -12,6 +13,7 @@ ts_library( name = "perf_tests_lib", testonly = 1, srcs = ["largetable.perf-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", "@npm//protractor", diff --git a/modules/benchmarks/src/largetable/largetable.perf-spec.ts b/modules/benchmarks/src/largetable/largetable.perf-spec.ts index 9c521c2562..b78931a009 100644 --- a/modules/benchmarks/src/largetable/largetable.perf-spec.ts +++ b/modules/benchmarks/src/largetable/largetable.perf-spec.ts @@ -49,7 +49,7 @@ describe('largetable benchmark perf', () => { [CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => { describe(worker.id, () => { it(`should run benchmark for ${testPackageName}`, async() => { - runTableBenchmark({ + await runTableBenchmark({ id: `largeTable.${testPackageName}.${worker.id}`, url: '/', ignoreBrowserSynchronization: true, diff --git a/modules/benchmarks/src/tree/BUILD.bazel b/modules/benchmarks/src/tree/BUILD.bazel index f8a0865772..2394677a61 100644 --- a/modules/benchmarks/src/tree/BUILD.bazel +++ b/modules/benchmarks/src/tree/BUILD.bazel @@ -5,6 +5,7 @@ package(default_visibility = ["//visibility:public"]) ts_library( name = "util_lib", srcs = ["util.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = ["//modules/benchmarks/src:util_lib"], ) @@ -12,6 +13,7 @@ ts_library( name = "test_utils_lib", testonly = 1, srcs = ["test_utils.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", "@npm//protractor", @@ -22,6 +24,7 @@ ts_library( name = "perf_tests_lib", testonly = 1, srcs = ["tree.perf-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ ":test_utils_lib", "@npm//protractor", @@ -32,6 +35,7 @@ ts_library( name = "e2e_tests_lib", testonly = 1, srcs = ["tree.e2e-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ ":test_utils_lib", "@npm//protractor", @@ -42,6 +46,7 @@ ts_library( name = "detect_changes_perf_tests_lib", testonly = 1, srcs = ["tree_detect_changes.perf-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ ":test_utils_lib", "@npm//protractor", @@ -52,6 +57,7 @@ ts_library( name = "detect_changes_e2e_tests_lib", testonly = 1, srcs = ["tree_detect_changes.e2e-spec.ts"], + tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ ":test_utils_lib", "@npm//protractor", diff --git a/modules/benchmarks/src/tree/tree.e2e-spec.ts b/modules/benchmarks/src/tree/tree.e2e-spec.ts index 2dc8534e92..f86a822568 100644 --- a/modules/benchmarks/src/tree/tree.e2e-spec.ts +++ b/modules/benchmarks/src/tree/tree.e2e-spec.ts @@ -13,16 +13,16 @@ import {openTreeBenchmark} from './test_utils'; describe('tree benchmark', () => { it('should work for createDestroy', async() => { openTreeBenchmark(); - $('#createDom').click(); + await $('#createDom').click(); expect($('#root').getText()).toContain('1'); - $('#destroyDom').click(); - expect($('#root').getText() as any).toEqual(''); + await $('#destroyDom').click(); + expect(await $('#root').getText()).toEqual(''); }); it('should work for update', async() => { openTreeBenchmark(); - $('#createDom').click(); - $('#createDom').click(); + await $('#createDom').click(); + await $('#createDom').click(); expect($('#root').getText()).toContain('A'); }); }); diff --git a/modules/benchmarks/src/tree/tree.perf-spec.ts b/modules/benchmarks/src/tree/tree.perf-spec.ts index 1dd15e3097..2e52a2fae8 100644 --- a/modules/benchmarks/src/tree/tree.perf-spec.ts +++ b/modules/benchmarks/src/tree/tree.perf-spec.ts @@ -11,7 +11,7 @@ import {runTreeBenchmark} from './test_utils'; describe('tree benchmark perf', () => { it('should work for createOnly', async() => { - runTreeBenchmark({ + await runTreeBenchmark({ // This cannot be called "createOnly" because the actual destroy benchmark // has the "createOnly" id already. See: https://github.com/angular/angular/pull/21503 id: 'createOnlyForReal', @@ -21,7 +21,7 @@ describe('tree benchmark perf', () => { }); it('should work for destroy', async() => { - runTreeBenchmark({ + await runTreeBenchmark({ // This is actually a benchmark for destroying the dom, but it has been accidentally // named "createOnly". See https://github.com/angular/angular/pull/21503. id: 'createOnly', @@ -31,7 +31,7 @@ describe('tree benchmark perf', () => { }); it('should work for createDestroy', async() => { - runTreeBenchmark({ + await runTreeBenchmark({ id: 'createDestroy', work: () => { $('#destroyDom').click(); @@ -41,7 +41,7 @@ describe('tree benchmark perf', () => { }); it('should work for update', async() => { - runTreeBenchmark({ + await runTreeBenchmark({ id: 'update', work: () => $('#createDom').click(), }); diff --git a/modules/benchmarks/src/tree/tree_detect_changes.e2e-spec.ts b/modules/benchmarks/src/tree/tree_detect_changes.e2e-spec.ts index cc3e7c0c8e..d75539af13 100644 --- a/modules/benchmarks/src/tree/tree_detect_changes.e2e-spec.ts +++ b/modules/benchmarks/src/tree/tree_detect_changes.e2e-spec.ts @@ -13,7 +13,7 @@ import {openTreeBenchmark} from './test_utils'; describe('tree benchmark detect changes', () => { it('should work for detectChanges', async() => { openTreeBenchmark(); - $('#detectChanges').click(); + await $('#detectChanges').click(); expect($('#numberOfChecks').getText()).toContain('10'); }); });