Open breautek opened 1 year ago
Thanks for the thorough explanation! I was looking into this as I thought it was new as a result of my recent pr.
I am a 👍 to remove the test, is that your recommendation?
I am a +1 to remove the test, is that your recommendation?
No, I don't think the test should be removed, the act of testing adding local folders as a platform target should be something that is tested as that is a supported way of using Cordova... and I believe that is the intended test scenario in Test#012. However, it should be testing a valid directory as a platform target (e.g. not the contents of an NPM packed tarball but rather a git cloned directory, for example).
I'm not sure what is involved on making that happen, so we could disable the test with a comment pointing to this ticket for context until we do find a proper solution.
Or if we decide that an unpacked tarball folder should be a valid target, then we will probably have to fix cordova-android
and potentially other platforms, but I'd rather call that an unsupported target (install the tarball itself instead).
@raphinesse what is your thoughts on this issue since them problems seems to be related to the new js build system.
I agree with @breautek that we should make sure we are testing the right thing. And if nobody has free cycles to do this, deactivating the test sounds reasonable.
Don't we have a minimal test platform fixture without dependencies in this repo already? I'm not sure, it's been some time.
Re the error issue: IIRC, CordovaError is an instance of Error, has a string message property and is nicely convertible to string (see the spec: https://github.com/apache/cordova-common/blob/b782a724f9fee6c483514ed9c23e4f20c8f9b8e6/spec/CordovaError/CordovaError.spec.js). Do you have a link to the jasmine code that throws the error?
Re the error issue: IIRC, CordovaError is an instance of Error, has a string message property and is nicely convertible to string (see the spec: https://github.com/apache/cordova-common/blob/b782a724f9fee6c483514ed9c23e4f20c8f9b8e6/spec/CordovaError/CordovaError.spec.js). Do you have a link to the jasmine code that throws the error?
No I don't and perhaps I'm wrong about that the cause here.. What I did was a .catch
the promise to obtain the error
and wrapped it in a new Error()
and threw that instead, and jasmine seemed to reported the actual error instead of the message.split
error. This is why I assumed that giving Jasmine a CordovaError
was the problem, but if it's an instance of Error
then I'd expect that it would work...
Perhaps we should create a new issue for this topic though.
Bug Report
Problem
Information
This is a two-part issue.
message.split
is an error inside of Jasmine because Jasmine expects either astring
or aError
type object to be passed as a rejection message. But some of our errors are aCordovaError
object. Jasmine doesn't know how to useCordovaError
and crashes when trying tosplit
it and results with a test failure by timeout (rather than reporting the actual error).This however, is not the focus of this ticket. The actual underlying error is:
The test has a folder structure built that has 2 folders,
android/
, acordova-android
installation andproject/
, a cordova project for the purpose of the test.There are two probems with
android/
cordova-android installation.cordova-android
has aprepare
lifecycle NPM script, primarily intended to trigger just before NPM "packs" the package. However NPM will triggerprepare
in some situations, including when installing from git or when doing local installs.Problem 1
Because this is a local directory, NPM is symlinking
android/
ascordova-android
install, without installing it's dependencies, thereforecordova-js
doesn't exists. If you enterandroid/
and run NPM install it will correct this issue, butcordova-js
will error leading into Problem 2Problem 2
Even if
cordova-js
was installed, theandroid/
structure is missingcordova-js-src
directory and therefore cannot build thecordova.js
file. The directory is missing becauseandroid/
gets populated via an npm install / copy fromnode_modules
.cordova-js-src
is in the GIT repository, but is.npmignore
'ed, because it's not required since thecordova.js
file will be built before the tarball is packed. This is also evident because thecordova.js
file does already exists.The Root of the Problem
The described problem are a side effect of the root problem, we aren't testing the right thing. Test#012 is testing a situation that looks something like:
User retrievies an NPM packed tarball file (e.g. cordova-android.tgz). User unpacks the tarball file. User tries to
cordova platform add cordova-android/tarballDirectory
This is a weird scenario to test and is likely unintentional. If the user has a tarball file, they should simply add the tarball file (e.g:
cordova platform add cordova-android.tgz
). They shouldn't manually extract the tarball and add the extracted directory. That doesn't make sense.Installing a platform from a directory is typically done if someone has a development version of a platform, most likely from SVC repository like Git. Therefore the
android/
test artefact should reflect that kind of situation instead.Command or Code
If the test cleanup code is commented out so that the temporary files remain in tact after attempting to run them, you can manually trigger the error by attempting to add the
android/
directory as a platform, e.g:cordova platform add ../android
(from within theproject/
folder)Environment, Platform, Device
Test Environment
Version information
cordova-lib master / v11.1.0 (prerelease)
Checklist