Closed
Bug 1132772
Opened 9 years ago
Closed 9 years ago
afterCache and afterCommit should return Promise
Categories
(Firefox :: Search, defect)
Firefox
Search
Tracking
()
RESOLVED
FIXED
Firefox 39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: hiro, Assigned: hiro)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 3 obsolete files)
6.63 KB,
patch
|
hiro
:
review+
|
Details | Diff | Splinter Review |
test_nocache.js can be failed because the test does not wait for afterCache() on search.init(). The failure can be easily reproduced with removing "firefox-appdir = browser" from toolkit/components/search/tests/xpcshell/xpcshell.ini. The result: ./mach xpcshell-test toolkit/components/search/tests/xpcshell/test_nocache.js <snip> 0:01.11 LOG: Thread-1 INFO "CONSOLE_MESSAGE: (info) NOTIFY: Engine: "Test search engine"; Verb: "engine-loaded"" 0:01.11 LOG: Thread-1 INFO "CONSOLE_MESSAGE: (info) nsSearchService::observe: Done installation of Test search engine." 0:01.11 LOG: Thread-1 INFO "CONSOLE_MESSAGE: (info) _addEngineToStore: Adding engine: "Test search engine"" 0:01.11 LOG: Thread-1 INFO "CONSOLE_MESSAGE: (info) NOTIFY: Engine: "Test search engine"; Verb: "engine-added"" 0:01.14 LOG: Thread-1 INFO "afterCache: write-cache-to-disk-complete" 0:01.14 LOG: Thread-1 INFO "afterCache: write-cache-to-disk-complete" 0:01.14 TEST_STATUS: Thread-1 test_nocache PASS [test_nocache : 31] true == true 0:01.14 LOG: Thread-1 INFO "Searching test engine in cache" 0:01.14 TEST_STATUS: Thread-1 test_nocache FAIL [test_nocache : 62] false == true /home/ikezoe/mozilla-central/obj-firefox/_tests/xpcshell/toolkit/components/search/tests/xpcshell/test_nocache.js:test_nocache:62 self-hosted:next:610 _run_next_test@/home/ikezoe/mozilla-central/testing/xpcshell/head.js:1375:9 do_execute_soon/<.run@/home/ikezoe/mozilla-central/testing/xpcshell/head.js:644:9 _do_main@/home/ikezoe/mozilla-central/testing/xpcshell/head.js:207:5 _execute_test@/home/ikezoe/mozilla-central/testing/xpcshell/head.js:504:5 @-e:1:1 0:01.14 LOG: Thread-1 INFO exiting test 0:01.14 LOG: Thread-1 ERROR Unexpected exception 2147500036
Attachment #8563839 -
Flags: review?(mak77)
Assignee | ||
Comment 1•9 years ago
|
||
Pushed a try now. https://treeherder.mozilla.org/#/jobs?repo=try&revision=a4a04691d886
Comment 2•9 years ago
|
||
Comment on attachment 8563839 [details] [diff] [review] wait_for_afterCache.patch Review of attachment 8563839 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/search/tests/xpcshell/test_nocache.js @@ +21,5 @@ > > add_task(function* test_nocache() { > let search = Services.search; > > + let cachePromise = new Promise(resolve => afterCache(resolve)); let's rather make afterCache return a Promise, and the call points using the callback can use .then()
Attachment #8563839 -
Flags: review?(mak77)
Assignee | ||
Updated•9 years ago
|
Summary: Should wait afterCache in test_nocache.js → afterCache and afterCommit should return Promise
Assignee | ||
Comment 3•9 years ago
|
||
Changed bug title. afterCommit() is also changed to return a Promise. https://treeherder.mozilla.org/#/jobs?repo=try&revision=f7984f66dde3
Assignee: nobody → hiikezoe
Attachment #8563839 -
Attachment is obsolete: true
Attachment #8564933 -
Flags: review?(mak77)
Comment 4•9 years ago
|
||
Comment on attachment 8564933 [details] [diff] [review] return_Promise.patch Review of attachment 8564933 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/search/tests/xpcshell/head_search.js @@ +142,5 @@ > return UTCOffset >= 150 && UTCOffset <= 600; > } > > /** > + * Waits for being metadata committed. s/being metadata/metadata being/ @@ +150,1 @@ > { while here please move brace in line with the function definition, per coding style @@ +152,4 @@ > } > > /** > + * Waits for saving cache file. Waits for the cache file to be saved. ::: toolkit/components/search/tests/xpcshell/test_nocache.js @@ +34,1 @@ > // Check that search.json has been created. I'd prefer a more readable: yield afterCachePromise; // Check that search.json has... ... @@ +43,5 @@ > { name: "Test search engine", xmlFileName: "engine.xml" }, > ]); > > do_print("Engine has been added, let's wait for the cache to be built"); > + yield afterCachePromise; Do we really need to store the promise in a temp var in this case? The notification we wait for is notified on a promise resolution, so basically it should run one tick after us... If that would not be true, the previous code would have failed already. I think this will just do: yield promiseAfterCache();
Attachment #8564933 -
Flags: review?(mak77) → feedback+
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Marco Bonardo [::mak] -- currently sick :( (delayed answers) from comment #4) > @@ +43,5 @@ > > { name: "Test search engine", xmlFileName: "engine.xml" }, > > ]); > > > > do_print("Engine has been added, let's wait for the cache to be built"); > > + yield afterCachePromise; > > Do we really need to store the promise in a temp var in this case? > > The notification we wait for is notified on a promise resolution, so > basically it should run one tick after us... If that would not be true, the > previous code would have failed already. Ah, right. My intention was to avoid waiting for wrong notification as the previous code did. Actually the notification received after addTestEngines() in the previous code came from search.init(). But unfortunately the temp var does not avoid the notification mismatch at all!. The mismatch can be fixed by the yield after search.init() as attachment 8564933 [details] [diff] [review] does, not the temp var! I will attach a revised patch. Thanks Marco! Take care!
Assignee | ||
Comment 6•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=4940a4a12f8a There are a few build bustages unrelated this patch.
Attachment #8564933 -
Attachment is obsolete: true
Attachment #8570267 -
Flags: review?(mak77)
Comment 7•9 years ago
|
||
Comment on attachment 8570267 [details] [diff] [review] return Promise v2 Review of attachment 8570267 [details] [diff] [review]: ----------------------------------------------------------------- Taking over for Marco. LGTM with the one comment corrected. Thanks! ::: toolkit/components/search/tests/xpcshell/test_nocache.js @@ +28,5 @@ > yield new Promise((resolve, reject) => search.init(rv => { > Components.isSuccessCode(rv) ? resolve() : reject(); > })); > > + // Check that cache is created at startup Nit: // Check that the cache is created at startup.
Attachment #8570267 -
Flags: review?(mak77) → review+
Assignee | ||
Comment 8•9 years ago
|
||
Thanks Tim! Carrying over review+.
Attachment #8570267 -
Attachment is obsolete: true
Attachment #8577796 -
Flags: review+
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 10•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/97f74a12b427
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 39
You need to log in
before you can comment on or make changes to this bug.
Description
•