[
https://issues.apache.org/jira/browse/CB-11174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15264918#comment-15264918
]
ASF GitHub Bot commented on CB-11174:
-------------------------------------
Github user vladimir-kotikov commented on a diff in the pull request:
https://github.com/apache/cordova-lib/pull/433#discussion_r61655336
--- Diff: cordova-lib/spec-cordova/platforms/platforms.spec.js ---
@@ -17,19 +17,25 @@
under the License.
*/
+var fs = require('fs');
+var os = require('os');
var path = require('path');
var rewire = require('rewire');
+var shell = require('shelljs');
var util = require('../../src/cordova/util');
var platforms = rewire('../../src/platforms/platforms');
var CORDOVA_ROOT = path.join(__dirname,
'../fixtures/projects/platformApi');
var PLATFORM_WITH_API = path.join(CORDOVA_ROOT, 'platforms/windows');
var PLATFORM_WOUT_API = path.join(CORDOVA_ROOT, 'platforms/android');
+var PLATFORM_SYMLINK = path.join(os.tmpdir(), 'cordova_windows_symlink');
-var MockPlatformApi = require(path.join(PLATFORM_WITH_API, 'cordova',
'Api'));
+var MockPlatformApi = require(fs.realpathSync(path.join(PLATFORM_WITH_API,
'cordova/Api.js')));
var PlatformApiPoly = require('../../src/platforms/PlatformApiPoly');
+shell.ln('-sf', PLATFORM_WITH_API, PLATFORM_SYMLINK);
+
--- End diff --
I've tested this on both OS X and Windows. Tests are passing in both cases.
> cordova platformApi cache isn't dealing correctly with symlinked project dirs
> -----------------------------------------------------------------------------
>
> Key: CB-11174
> URL: https://issues.apache.org/jira/browse/CB-11174
> Project: Apache Cordova
> Issue Type: Bug
> Components: CordovaLib
> Affects Versions: 6.1.1
> Reporter: Vladimir Kotikov
> Assignee: Vladimir Kotikov
>
> When project dir is inside of symlinked directory (say {{/var}} on OS X),
> {{getPlatformApi}} method in cordova-lib doesn't resolve real path before
> dealing with cache and uses provided path as-is. This causes returning two
> separate instances of {{PlatformApi}} class when {{getPlatformApi}} is first
> called with symlinked path and then with real one, despite of the fact that
> both paths are pointing to the same project.
> In the real life this issue causes the following 'npm test' failures for
> cordova-lib on OS X, caused by mocking methods for one PlatformApi instance
> and using another one:
> {noformat}
> 1) plugin end-to-end should not run prepare after plugin
> installation/removal if platform return non-falsy value
> Message:
> Expected spy preparePlatforms not to have been called.
> Stacktrace:
> Error: Expected spy preparePlatforms not to have been called.
> at
> /Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/spec-cordova/plugin.spec.js:175:50
> at _fulfilled
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:787:54)
> at self.promiseDispatch.done
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:816:30)
> at Promise.promise.promiseDispatch
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:749:13)
> at
> /Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:557:44
> at flush
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:108:17)
> at nextTickCallbackWith0Args (node.js:419:9)
> at process._tickCallback (node.js:348:13)
>
> 2) plugin end-to-end should not run prepare after plugin
> installation/removal if platform return non-falsy value
> Message:
> Expected spy preparePlatforms not to have been called.
> Stacktrace:
> Error: Expected spy preparePlatforms not to have been called.
> at
> /Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/spec-cordova/plugin.spec.js:179:50
> at _fulfilled
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:787:54)
> at self.promiseDispatch.done
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:816:30)
> at Promise.promise.promiseDispatch
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:749:13)
> at
> /Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:557:44
> at flush
> (/Users/csantana23/Documents/dev/cordova/cordova-lib/cordova-lib/node_modules/q/q.js:108:17)
> at nextTickCallbackWith0Args (node.js:419:9)
> at process._tickCallback (node.js:348:13)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]