CB-11679 Speed up save/restore tests clone platform repos with --depth 1
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/780439cd Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/780439cd Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/780439cd Branch: refs/heads/common-1.4.x Commit: 780439cd1167160000641cd2831236d2c416564e Parents: d1c63d6 Author: Vladimir Kotikov <v-vlk...@microsoft.com> Authored: Tue Apr 19 16:27:32 2016 +0300 Committer: Vladimir Kotikov <v-vlk...@microsoft.com> Committed: Tue Aug 9 12:58:18 2016 +0300 ---------------------------------------------------------------------- cordova-lib/spec-cordova/save.spec.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/780439cd/cordova-lib/spec-cordova/save.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/save.spec.js b/cordova-lib/spec-cordova/save.spec.js index b5ece83..31f7e96 100644 --- a/cordova-lib/spec-cordova/save.spec.js +++ b/cordova-lib/spec-cordova/save.spec.js @@ -26,6 +26,7 @@ describe('(save flag)', function () { fs = require('fs'), shell = require('shelljs'), util = require('../src/cordova/util'), + node_util = require('util'), prepare = require('../src/cordova/prepare'), registry = require('../src/plugman/registry/registry'), PlatformApi = require('../src/platforms/PlatformApiPoly'), @@ -126,12 +127,16 @@ describe('(save flag)', function () { revertInstallPluginsForNewPlatform(); }); + function gitClone(repo, dir, ref, cb) { + var gitTemplate = 'git clone --branch %s --depth=1 %s %s'; + var gitCommand = node_util.format(gitTemplate, ref, repo, dir); + shell.exec(gitCommand, { silent: true }, cb); + } + describe('preparing fixtures', function () { it('cloning "old" platform', function (done) { shell.rm('-rf', platformLocalPathOld); - shell.exec('git clone ' + platformGitUrl + ' ' + platformLocalPathOld + - ' && cd ' + platformLocalPathOld + - ' && git reset --hard ' + platformVersionOld, { silent: true }, function (err) { + gitClone(platformGitUrl, platformLocalPathOld, platformVersionOld, function (err) { expect(err).toBe(0); done(); }); @@ -139,9 +144,7 @@ describe('(save flag)', function () { it('cloning "new" platform', function (done) { shell.rm('-rf', platformLocalPathNew); - shell.exec('git clone ' + platformGitUrl + ' ' + platformLocalPathNew + - ' && cd ' + platformLocalPathNew + - ' && git reset --hard ' + platformVersionNew, { silent: true }, function (err) { + gitClone(platformGitUrl, platformLocalPathNew, platformVersionNew, function (err) { expect(err).toBe(0); done(); }); @@ -149,9 +152,7 @@ describe('(save flag)', function () { it('cloning "newer" platform', function (done) { shell.rm('-rf', platformLocalPathNewer); - shell.exec('git clone ' + platformGitUrl + ' ' + platformLocalPathNewer + - ' && cd ' + platformLocalPathNewer + - ' && git reset --hard ' + platformVersionNewer, { silent: true }, function (err) { + gitClone(platformGitUrl, platformLocalPathNewer, platformVersionNewer, function (err) { expect(err).toBe(0); done(); }); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org