You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/06/04 19:36:21 UTC
[5/8] cordova-lib git commit: Fix four failing tests on Windows.
Fix four failing tests on Windows.
Two tests fail in a non-admin command window because they rely on creating symlinks. Since creating the symlinks isn't the purpose of the test but just setup for the test, if that fails and the platform is win32, we now just bail on the test.
Another test failed because a folder unexpectedly exists when run from a non-admin prompt. I'm not 100% sure why the folder exists, but the test was actually bogus... the test was actually ends up testing that we throw if src does not exist (something that we verify in an earlier test), while the intent was to verify we throw if dest *already* exists. It is copyNewFile() that throws in that scenario, so I updated the test to check for that.
Finally, a fourth test failed on Windows (admin or non-admin) because of different line endings. Changed that to handle any line ending.
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/87780903
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/87780903
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/87780903
Branch: refs/heads/5.1.x
Commit: 877809032fccff6869f1006f7e732ae74c5e43d6
Parents: d26a3cf
Author: Tim Barham <ti...@microsoft.com>
Authored: Tue Jun 2 16:22:11 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Thu Jun 4 10:25:05 2015 -0700
----------------------------------------------------------------------
.../spec-plugman/platforms/android.spec.js | 2 +-
.../spec-plugman/platforms/common.spec.js | 42 ++++++++++++++++----
2 files changed, 35 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/87780903/cordova-lib/spec-plugman/platforms/android.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/android.spec.js b/cordova-lib/spec-plugman/platforms/android.spec.js
index 4fabc80..2af8fc5 100644
--- a/cordova-lib/spec-plugman/platforms/android.spec.js
+++ b/cordova-lib/spec-plugman/platforms/android.spec.js
@@ -137,7 +137,7 @@ describe('android project handler', function() {
var finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
expect(finalProjectProperties).toMatch('\nandroid.library.reference.3='+dummy_id+'/'+packageIdSuffix+'-plugin-lib', 'Reference to library not added');
var subProjectProperties = fs.readFileSync(subProjectPropsFile, 'utf8');
- expect(subProjectProperties).toMatch(/\btarget=android-19\n/, 'target SDK version not copied to library');
+ expect(subProjectProperties).toMatch(/\btarget=android-19$/m, 'target SDK version not copied to library');
expect(exec).toHaveBeenCalledWith('android update lib-project --path "' + subDir + '"');
// Now test uninstall
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/87780903/cordova-lib/spec-plugman/platforms/common.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/common.spec.js b/cordova-lib/spec-plugman/platforms/common.spec.js
index 408f070..8b8ed18 100644
--- a/cordova-lib/spec-plugman/platforms/common.spec.js
+++ b/cordova-lib/spec-plugman/platforms/common.spec.js
@@ -72,7 +72,12 @@ describe('common platform handler', function() {
it('should allow symlink src, if inside plugin', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(java_file, 'contents', 'utf-8');
- fs.symlinkSync(java_file, symlink_file);
+
+ // This will fail on windows if not admin - ignore the error in that case.
+ if (ignoreEPERMonWin32(java_file, symlink_file)) {
+ return;
+ }
+
common.copyFile(test_dir, symlink_file, project_dir, dest);
shell.rm('-rf', project_dir);
});
@@ -80,18 +85,17 @@ describe('common platform handler', function() {
it('should throw if symlink is linked to a file outside the plugin', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(non_plugin_file, 'contents', 'utf-8');
- fs.symlinkSync(non_plugin_file, symlink_file);
+
+ // This will fail on windows if not admin - ignore the error in that case.
+ if (ignoreEPERMonWin32(non_plugin_file, symlink_file)) {
+ return;
+ }
+
expect(function(){common.copyFile(test_dir, symlink_file, project_dir, dest);}).
toThrow(new Error('"' + symlink_file + '" not located within plugin!'));
shell.rm('-rf', project_dir);
});
- it('should throw if target path exists', function(){
- shell.mkdir('-p', dest);
- expect(function(){common.copyFile(test_dir, src, project_dir, dest);}).toThrow();
- shell.rm('-rf', dest);
- });
-
it('should throw if dest is outside the project directory', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(java_file, 'contents', 'utf-8');
@@ -131,6 +135,16 @@ describe('common platform handler', function() {
});
+ describe('copyNewFile', function () {
+ it('should throw if target path exists', function(){
+ shell.mkdir('-p', dest);
+ expect(function(){common.copyNewFile(test_dir, src, project_dir, dest);}).
+ toThrow(new Error('"' + dest + '" already exists!'));
+ shell.rm('-rf', dest);
+ });
+
+ });
+
describe('deleteJava', function() {
it('should call fs.unlinkSync on the provided paths', function(){
shell.mkdir('-p', java_dir);
@@ -167,3 +181,15 @@ describe('common platform handler', function() {
});
});
});
+
+function ignoreEPERMonWin32(symlink_src, symlink_dest) {
+ try {
+ fs.symlinkSync(symlink_src, symlink_dest);
+ } catch (e) {
+ if (process.platform === 'win32' && e.message.indexOf('Error: EPERM, operation not permitted' > -1)) {
+ return true;
+ }
+ throw e;
+ }
+ return false;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org