Skip to content

Commit

Permalink
Speed up tests by about 250%
Browse files Browse the repository at this point in the history
- Add local git fixture repo to speed up test ~50s to ~5s
- Reduce run time of longest test from ~60s to ~25s
- Reduce amount of git tests for double fetch tests
  • Loading branch information
raphinesse committed Jun 16, 2018
1 parent 896b9d4 commit 36ecb8c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"file-url": "^2.0.2",
"jasmine": "^2.4.1",
"rewire": "^4.0.1"
},
Expand Down
32 changes: 14 additions & 18 deletions spec/fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var uninstall = fetch.uninstall;

var path = require('path');
var fs = require('fs-extra');
var fileUrl = require('file-url');
var helpers = require('./helpers.js');

var tmpDir, opts;
Expand Down Expand Up @@ -69,12 +70,10 @@ describe('fetch/uninstall tests via npm & git', function () {
.then(_ => uninstall('cordova-android', tmpDir, opts))
.then(_ => expectNotToBeInstalled('cordova-android'))

.then(_ => fetchAndMatch('https://github.com/apache/cordova-ios.git', { name: 'cordova-ios' }))
.then(_ => uninstall('cordova-ios', tmpDir, opts))
.then(_ => expectNotToBeInstalled('cordova-ios'))

.then(_ => fetchAndMatch('https://github.com/apache/cordova-browser.git', { name: 'cordova-browser' }));
}, 120000);
.then(_ => fetchAndMatch('https://github.com/apache/cordova-browser.git', { name: 'cordova-browser' }))
.then(_ => uninstall('cordova-browser', tmpDir, opts))
.then(_ => expectNotToBeInstalled('cordova-browser'));
}, 60000);

it('should fetch a scoped plugin from npm', function () {
return fetchAndMatch('@stevegill/cordova-plugin-device');
Expand Down Expand Up @@ -143,18 +142,15 @@ describe('fetching already installed packages', function () {
it('should return package path for registry packages', function () {
return Promise.resolve()
.then(_ => fetchAndMatch('cordova-plugin-device'))
.then(_ => fetchAndMatch('https://github.com/apache/cordova-plugin-media.git', { name: 'cordova-plugin-media' }))
.then(_ => fetchAndMatch('cordova-plugin-device'))
.then(_ => fetchAndMatch('github:apache/cordova-plugin-media', { name: 'cordova-plugin-media' }))
.then(_ => fetchAndMatch('https://github.com/apache/cordova-plugin-media', { name: 'cordova-plugin-media' }));
.then(_ => fetchAndMatch('cordova-plugin-device'));
}, 40000);

it('should return package path if git repo name differs from plugin id', function () {
const TARGET = 'https://github.com/AzureAD/azure-activedirectory-library-for-cordova.git';
const TARGET = 'git+' + fileUrl(path.resolve(__dirname, 'support/repo-name-neq-plugin-id.git'));
return Promise.resolve()
.then(_ => fetchAndMatch(TARGET, { name: 'cordova-plugin-ms-adal' }))
.then(_ => fetchAndMatch(TARGET, { name: 'cordova-plugin-ms-adal' }));
}, 120000);
.then(_ => fetchAndMatch(TARGET, { name: 'test-plugin' }))
.then(_ => fetchAndMatch(TARGET, { name: 'test-plugin' }));
}, 40000);

it('should return package path if using a relative path', function () {
const TARGET = 'file:support/dummy-local-plugin';
Expand All @@ -164,11 +160,11 @@ describe('fetching already installed packages', function () {
}, 60000);

it('should return package path for git+http variants', function () {
const TARGET = 'git+http://gitbox.apache.org/repos/asf/cordova-plugin-dialogs.git';
return Promise.resolve()
.then(_ => fetchAndMatch(TARGET, { name: 'cordova-plugin-dialogs' }))
.then(_ => fetchAndMatch(TARGET, { name: 'cordova-plugin-dialogs' }));
}, 30000);
.then(_ => fetchAndMatch('github:apache/cordova-plugin-device', { name: 'cordova-plugin-device' }))
.then(_ => fetchAndMatch('https://github.com/apache/cordova-plugin-device', { name: 'cordova-plugin-device' }))
.then(_ => fetchAndMatch('git+https://github.com/apache/cordova-plugin-device', { name: 'cordova-plugin-device' }));
}, 60000);
});

describe('negative tests', function () {
Expand Down
1 change: 1 addition & 0 deletions spec/support/repo-name-neq-plugin-id.git/HEAD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref: refs/heads/master
4 changes: 4 additions & 0 deletions spec/support/repo-name-neq-plugin-id.git/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
x-�1�0 E�s
�C'�1ѝ0viC��$�ST ��$
�����?��]O_�nX ;�D�.a�^��\����w��궦�d�ҟ<f�7@���V�!Oe���]���U� ������F���{�>v�|]�@?�l��4@;'0��C�'�:�
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x+)JMU0�`040031Q(HL�NLO��*��c�Ũ������lǽS��x������T� �4=3O�"7���������r/��n��g/�d#9cq#�
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xM�M� �ݖS�25��1@w�@�-����0����şy�Ǜ��ʫr�Q�s������Rp��o{촸�Oۃ�S���zdE�HZ��y:��67'}����$X�)�-�������d�e��w�����D̎��������X�Ў�$_}
�J9���H�7O3-rc�[��J���
�$Sy'�^^cU
Expand Down
1 change: 1 addition & 0 deletions spec/support/repo-name-neq-plugin-id.git/refs/heads/master
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
72d6e1a6f842add9a34f15ae0392c76f4d872e4e

0 comments on commit 36ecb8c

Please sign in to comment.