From ed36c68cdbc2f606987a2948a34eee741cbb25f4 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 27 Nov 2018 13:33:58 -0800 Subject: [PATCH] test(ivy): add `obsoleteInIvy`, `modifiedInIvy`, and `ivyEnabled` test selectors (#27302) See inline docs for description of these functions. PR Close #27302 --- packages/private/testing/index.ts | 2 +- packages/private/testing/src/fixme.ts | 22 ----- .../private/testing/src/ivy_test_selectors.ts | 86 +++++++++++++++++++ 3 files changed, 87 insertions(+), 23 deletions(-) delete mode 100644 packages/private/testing/src/fixme.ts create mode 100644 packages/private/testing/src/ivy_test_selectors.ts diff --git a/packages/private/testing/index.ts b/packages/private/testing/index.ts index 692207570e..4b79966cfa 100644 --- a/packages/private/testing/index.ts +++ b/packages/private/testing/index.ts @@ -7,5 +7,5 @@ */ export * from './src/render3'; -export * from './src/fixme'; export * from './src/goog_get_msg'; +export * from './src/ivy_test_selectors'; diff --git a/packages/private/testing/src/fixme.ts b/packages/private/testing/src/fixme.ts deleted file mode 100644 index 222c648877..0000000000 --- a/packages/private/testing/src/fixme.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @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 - */ - -import {bazelDefineCompileValue} from './bazel_define_compile_value'; - -/** - * A global method which is used to conditionally block the execution of tests. - * - * ``` - * fixmeIvy('some reason') && describe(...); - * ``` - * - * The above will prevent the execution of the test(s) in Ivy mode, until they can be fixed. - */ -export function fixmeIvy(reason: string): boolean { - return 'aot' !== (bazelDefineCompileValue as string); -} \ No newline at end of file diff --git a/packages/private/testing/src/ivy_test_selectors.ts b/packages/private/testing/src/ivy_test_selectors.ts new file mode 100644 index 0000000000..dc39e42f52 --- /dev/null +++ b/packages/private/testing/src/ivy_test_selectors.ts @@ -0,0 +1,86 @@ +/** + * @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 + */ + +import {bazelDefineCompileValue} from './bazel_define_compile_value'; + + +/** + * A function to conditionally include a test or a block of tests only when tests run against Ivy. + * + * The modification of the behavior must be well justified, not affect common usage patterns, and + * documented as a breaking change. + * + * ``` + * ivyEnabled && describe(...); + * ``` + * + * or + * + * ``` + * ivyEnabled && it(...); + * ``` + */ +export const ivyEnabled = 'aot' === (bazelDefineCompileValue as string); + + +/** + * A function to conditionally skip the execution of tests that are yet to be fixed + * when running against Ivy. + * + * ``` + * fixmeIvy('some reason') && describe(...); + * ``` + * + * or + * + * ``` + * fixmeIvy('some reason') && it(...); + * ``` + */ +export function fixmeIvy(reason: string): boolean { + return !ivyEnabled; +} + + +/** + * A function to conditionally skip the execution of tests that are not relevant when + * running against Ivy. + * + * Any tests disabled using this switch should not be user-facing breaking changes. + * + * ``` + * obsoleteInIvy('some reason') && describe(...); + * ``` + * + * or + * + * ``` + * obsoleteInIvy('some reason') && it(...); + * ``` + */ +export const obsoleteInIvy = fixmeIvy; + + +/** + * A function to conditionally skip the execution of tests that have intentionally + * been broken when running against Ivy. + * + * The modification of the behavior must be well justified, not affect common usage patterns, and + * documented as a breaking change. + * + * ``` + * modifiedInIvy('some reason') && describe(...); + * ``` + * + * or + * + * ``` + * modifiedInIvy('some reason') && it(...); + * ``` + */ +export const modifiedInIvy = fixmeIvy;