Commit 72398a50 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Web UI Polymer 3: Add test for ignore, use for importHtml

- Add test for ignore comments for js_modulizer script
- Fix bug in the script, where an ignore starting at the very beginning
of the line did not get removed
- Remove dummy importHtml and instead use the new ignore comments to
remove these calls in tests.

Bug: 965770
Change-Id: I6f63861bef6e93ae918d54273f905c0cc372dbc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1793743Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695381}
parent 6cb96e83
......@@ -35,7 +35,6 @@ js_modulizer("modulize") {
"MockInteractions.pressAndReleaseKeyOn|pressAndReleaseKeyOn",
"MockInteractions.tap|tap",
"Polymer.dom.flush|flush",
"PolymerTest.importHtml|importHtml",
"test_util.eventToPromise|eventToPromise",
"test_util.flushTasks|flushTasks",
"test_util.isVisible|isVisible",
......
......@@ -6,7 +6,7 @@
// #import 'chrome://resources/cr_elements/cr_radio_group/cr_radio_group.m.js';
// #import 'chrome://resources/cr_elements/cr_radio_button/cr_radio_button.m.js';
//
// #import {eventToPromise, importHtml} from 'chrome://test/test_util.m.js';
// #import {eventToPromise} from 'chrome://test/test_util.m.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {pressAndReleaseKeyOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
// clang-format on
......@@ -16,8 +16,9 @@ suite('cr-radio-group', () => {
/** @override */
suiteSetup(() => {
return PolymerTest.importHtml(
'chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html');
/* #ignore */ return PolymerTest.importHtml(
/* #ignore */ 'chrome://resources/cr_elements/cr_radio_button/' +
/* #ignore */ 'cr_radio_button.html');
});
setup(() => {
......
......@@ -127,22 +127,11 @@ cr.define('test_util', function() {
return !!rect && rect.width * rect.height > 0;
}
/**
* Dummy importHtml() for Polymer 3 tests, that does nothing since Polymer 3
* doesn't use HTML imports. To use, import from test_util.m.js and set
* PolymerTest.importHtml|importHtml in namespace_rewrites.
* @return {!Promise}
*/
/* #export */ function importHtml() {
return Promise.resolve();
}
// #cr_define_end
return {
eventToPromise: eventToPromise,
fakeDataBind: fakeDataBind,
flushTasks: flushTasks,
importHtml: importHtml,
isVisible: isVisible,
waitAfterNextRender: waitAfterNextRender,
waitBeforeNextRender: waitBeforeNextRender,
......
......@@ -42,7 +42,7 @@ _CWD = os.getcwd()
IMPORT_LINE_REGEX = '// #import'
EXPORT_LINE_REGEX = '/* #export */'
IGNORE_LINE_REGEX = '\s+/\* #ignore \*/(\S|\s)*'
IGNORE_LINE_REGEX = '\s*/\* #ignore \*/(\S|\s)*'
# Ignore lines that contain <include> tags, (for example see util.js).
INCLUDE_LINE_REGEX = '^// <include '
......
......@@ -53,6 +53,8 @@ class JsModulizerTest(unittest.TestCase):
self._run_test_(
'with_rename.js', 'with_rename_expected.js', ['cr.foo.Bar|Bar'])
def testSuccess_WithIgnore(self):
self._run_test_('with_ignore.js', 'with_ignore_expected.js')
if __name__ == '__main__':
unittest.main()
/* #ignore */ console.log('Hello');
console.log('World');
// clang-format off
/* #ignore */ console.log('Goodbye');
// clang-format on
console.log('World');
// clang-format off
// clang-format on
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment