Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy workers when they are no longer needed in the unit tests #6904

Merged
merged 2 commits into from
Feb 3, 2016

Conversation

timvandermeij
Copy link
Contributor

Fixes #6877.

expect(pageLabels[2]).toEqual([]);
var promises = [loadingTask0.promise, loadingTask1.promise,
loadingTask2.promise];
Promise.all(promises).then(function (documents) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't removing waitsForPromiseResolved cause issues if one (or more) of the promises is rejected, since then the test will pass despite not actually testing anything?

You probably need to do something like this instead, to ensure that you catch every possible failure mode:

@@ -338,17 +338,20 @@ describe('api', function() {
     it('gets page labels', function () {
       // PageLabels with Roman/Arabic numerals.
       var url0 = combineUrl(window.location.href, '../pdfs/bug793632.pdf');
-      var promise0 = PDFJS.getDocument(url0).promise.then(function (pdfDoc) {
+      var loadingTask0 = PDFJS.getDocument(url0);
+      var promise0 = loadingTask0.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
       // PageLabels with only a label prefix.
       var url1 = combineUrl(window.location.href, '../pdfs/issue1453.pdf');
-      var promise1 = PDFJS.getDocument(url1).promise.then(function (pdfDoc) {
+      var loadingTask1 = PDFJS.getDocument(url1);
+      var promise1 = loadingTask1.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
       // PageLabels identical to standard page numbering.
       var url2 = combineUrl(window.location.href, '../pdfs/rotation.pdf');
-      var promise2 = PDFJS.getDocument(url2).promise.then(function (pdfDoc) {
+      var loadingTask2 = PDFJS.getDocument(url2);
+      var promise2 = loadingTask2.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });

@@ -357,6 +360,10 @@ describe('api', function() {
         expect(pageLabels[0]).toEqual(['i', 'ii', 'iii', '1']);
         expect(pageLabels[1]).toEqual(['Front Page1']);
         expect(pageLabels[2]).toEqual([]);
+
+        loadingTask0.destroy();
+        loadingTask1.destroy();
+        loadingTask2.destroy();
       });
     });
     it('gets attachments', function() {

Note that this might be an issue elsewhere in the patch too, I've not looked through all of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the new commit.

@Snuffleupagus
Copy link
Collaborator

Resolve the failures for the operator list tests. They might actually indicate a previously undiscovered bug in the destruction code.

Yes, this is actually a pre-existing issue, and I think that this should fix it: master...Snuffleupagus:oplist-destroy.
@timvandermeij Feel free to append that commit to this PR, if you think it's useful!

@timvandermeij timvandermeij force-pushed the cleanup-workers branch 2 times, most recently from 626bf23 to 5bcf4c1 Compare January 29, 2016 11:28
…ned the complete `OperatorList`, and prevent errors in `PDFPageProxy_destroy` for the 'oplist' rendering intent
@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/705927c8c8255fb/output.txt

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/09d74e2a81001a0/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/32e64e119a3cfe5/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/32e64e119a3cfe5/output.txt

Total script time: 20.13 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/09d74e2a81001a0/output.txt

Total script time: 21.40 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij
Copy link
Contributor Author

r? @yurydelendik

@yurydelendik
Copy link
Contributor

Thank you for the patch.

yurydelendik added a commit that referenced this pull request Feb 3, 2016
Destroy workers when they are no longer needed in the unit tests
@yurydelendik yurydelendik merged commit 4c59712 into mozilla:master Feb 3, 2016
@timvandermeij timvandermeij deleted the cleanup-workers branch February 3, 2016 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants