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

npm test fails on Node 12 #767

Closed
3 tasks done
breautek opened this issue Jul 11, 2019 · 1 comment · Fixed by #779
Closed
3 tasks done

npm test fails on Node 12 #767

breautek opened this issue Jul 11, 2019 · 1 comment · Fixed by #779
Labels

Comments

@breautek
Copy link
Contributor

breautek commented Jul 11, 2019

Bug Report

Problem

running npm test currently has 1 test failling.

What is expected to happen?

  • The test to pass.

What does actually happen?

Failures:
1) ProjectBuilder apkSorter should sort APKs from most recent to oldest, deprioritising unsigned arch-specific builds
  Message:
    Expected $[3] = 'app-debug-x86.apk' to equal 'app-release-arm.apk'.
    Expected $[4] = 'app-release-x86.apk' to equal 'app-debug-arm.apk'.
    Expected $[5] = 'app-debug-arm.apk' to equal 'app-release-x86.apk'.
    Expected $[6] = 'app-release-arm.apk' to equal 'app-debug-x86.apk'.
  Stack:
    Error: Expected $[3] = 'app-debug-x86.apk' to equal 'app-release-arm.apk'.
    Expected $[4] = 'app-release-x86.apk' to equal 'app-debug-arm.apk'.
    Expected $[5] = 'app-debug-arm.apk' to equal 'app-release-x86.apk'.
    Expected $[6] = 'app-release-arm.apk' to equal 'app-debug-x86.apk'.
        at <Jasmine>
        at UserContext.<anonymous> (/home/norman/development/cordova-android/spec/unit/builders/ProjectBuilder.spec.js:262:32)
        at <Jasmine>

292 specs, 1 failure
Finished in 5.982 seconds

Information

This currently only happens when running Node 12. Running Node 10 works ok.

Command or Code

npm test

Environment, Platform, Device & Versions

Node 12.4.0
Node 12.6.0
Linux Ubuntu 18.04
cordova-android@8.1.0-dev (master at the time of writing)
9.0.0 (cordova-lib@9.0.1)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
brody4hire pushed a commit to brody4hire/cordova-android that referenced this issue Jul 14, 2019
This function used to give a different order depending on the behavior
of Array.prototype.sort(), which led to a test failure on Node.js 12
(see apache#767).

This update gives a consistent sort order, regardless of the
JavaScript engine implementation, now succeeds on Node.js
versions 6, 8, 10, and 12.

Resolves apache#767

For reference:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
@brody4hire
Copy link

The explanation is that the following lines will lead to different results depending on what order Array.prototype.sort() follows when comparing the elements: https://github.com/apache/cordova-android/blob/rel/8.0.0/bin/templates/cordova/lib/builders/ProjectBuilder.js#L304-L318

I just raised PR #779 which gives consistent order on Node.js versions 6, 8, 10, and 12.

Thanks to @breautek for reporting this one.

brody4hire pushed a commit that referenced this issue Jul 14, 2019
This function used to give a different order depending on the behavior
of Array.prototype.sort(), which led to a test failure on Node.js 12
(see #767).

This update gives a consistent sort order, regardless of the
JavaScript engine implementation, now succeeds on Node.js
versions 6, 8, 10, and 12.

Resolves #767

For reference:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants