You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by alsorokin <gi...@git.apache.org> on 2016/10/03 17:17:07 UTC

[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

GitHub user alsorokin opened a pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159

    CB-11926 Tests can use local server

    <!--
    Please make sure the checklist boxes are all checked before submitting the PR. The checklist
    is intended as a quick reference, for complete details please see our Contributor Guidelines:
    
    http://cordova.apache.org/contribute/contribute_guidelines.html
    
    Thanks!
    -->
    
    ### Platforms affected
    All
    
    ### What does this PR do?
    Allows tests to use a locally deployed server. You can specify its address via `--variable FILETRANSFER_SERVER_ADDRESS=http://your.address.here:5000` upon plugin installation.
    The server itself can be found at:
    https://github.com/apache/cordova-labs/tree/cordova-filetransfer
    However, it's easier to just use paramedic, which can deploy this server and patch the tests to use it automatically:
    https://github.com/apache/cordova-paramedic/pull/17
    
    ### What testing has been done on this change?
    Tested w/ and w/o paramedic on Android and Windows platforms.
    
    ### Checklist
    - [x] [ICLA](http://www.apache.org/licenses/icla.txt) has been signed and submitted to secretary@apache.org.
    - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
    - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
    - [x] Added automated test coverage as appropriate for this change.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/alsorokin/cordova-plugin-file-transfer local-server

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #159
    
----
commit ca293bd3f29dc74f628721a552ff91593380d81e
Author: Alexander Sorokin <al...@akvelon.com>
Date:   2016-09-30T16:20:41Z

    CB-11926 Tests can use local server

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by vladimir-kotikov <gi...@git.apache.org>.
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159#discussion_r81697360
  
    --- Diff: tests/hooks/after_prepare.js ---
    @@ -0,0 +1,71 @@
    +#!/usr/bin/env node
    +
    +/*
    +*
    +* Licensed to the Apache Software Foundation (ASF) under one
    +* or more contributor license agreements.  See the NOTICE file
    +* distributed with this work for additional information
    +* regarding copyright ownership.  The ASF licenses this file
    +* to you under the Apache License, Version 2.0 (the
    +* "License"); you may not use this file except in compliance
    +* with the License.  You may obtain a copy of the License at
    +*
    +*   http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing,
    +* software distributed under the License is distributed on an
    +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +* KIND, either express or implied.  See the License for the
    +* specific language governing permissions and limitations
    +* under the License.
    +*
    +*/
    +
    +var path = require('path');
    +var fs = require('fs');
    +
    +module.exports = function(context) {
    +    function main() {
    +        // get the file transfer server address from the specified variables
    +        var defaultFileTransferServerAddress = getDefaultFileTransferServerAddress(context);
    --- End diff --
    
    I think you can optimize this a bit by calling `getDefaultFileTransferServerAddress()` only when server address is not set explicitly:
    
    ```js
    var fileTransferServerAddress = getFileTransferServerAddress(context) ||
                                    getDefaultFileTransferServerAddress(context);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by vladimir-kotikov <gi...@git.apache.org>.
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159#discussion_r81698327
  
    --- Diff: tests/hooks/after_prepare.js ---
    @@ -0,0 +1,71 @@
    +#!/usr/bin/env node
    +
    +/*
    +*
    +* Licensed to the Apache Software Foundation (ASF) under one
    +* or more contributor license agreements.  See the NOTICE file
    +* distributed with this work for additional information
    +* regarding copyright ownership.  The ASF licenses this file
    +* to you under the Apache License, Version 2.0 (the
    +* "License"); you may not use this file except in compliance
    +* with the License.  You may obtain a copy of the License at
    +*
    +*   http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing,
    +* software distributed under the License is distributed on an
    +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +* KIND, either express or implied.  See the License for the
    +* specific language governing permissions and limitations
    +* under the License.
    +*
    +*/
    +
    +var path = require('path');
    +var fs = require('fs');
    +
    +module.exports = function(context) {
    +    function main() {
    +        // get the file transfer server address from the specified variables
    +        var defaultFileTransferServerAddress = getDefaultFileTransferServerAddress(context);
    +        var fileTransferServerAddress = getFileTransferServerAddress(context) || defaultFileTransferServerAddress;
    +        console.log('Tests will use the following file transfer server address: ' + fileTransferServerAddress);
    +
    +        // pass it to the tests
    +        writeFileTransferOptions(fileTransferServerAddress, context);
    +    }
    +
    +    function getDefaultFileTransferServerAddress(context) {
    +        var address = null;
    +        var configNodes = context.opts.plugin.pluginInfo._et._root._children;
    +
    +        for (var node in configNodes) {
    +            if (configNodes[node].attrib.name == 'FILETRANSFER_SERVER_ADDRESS') {
    +                address = configNodes[node].attrib.default;
    +            }
    +        }
    +
    +        return address;
    +    }
    +
    +    function getFileTransferServerAddress(context) {
    +        var platformJsonFile = path.join(context.opts.projectRoot, 'plugins', context.opts.platforms[0] + '.json');
    --- End diff --
    
    I think you need to use `<project_root>/<platform>/<platform>.json` rather than one in the 'plugins' folder


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by vladimir-kotikov <gi...@git.apache.org>.
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159#discussion_r81697958
  
    --- Diff: tests/hooks/after_prepare.js ---
    @@ -0,0 +1,71 @@
    +#!/usr/bin/env node
    +
    +/*
    +*
    +* Licensed to the Apache Software Foundation (ASF) under one
    +* or more contributor license agreements.  See the NOTICE file
    +* distributed with this work for additional information
    +* regarding copyright ownership.  The ASF licenses this file
    +* to you under the Apache License, Version 2.0 (the
    +* "License"); you may not use this file except in compliance
    +* with the License.  You may obtain a copy of the License at
    +*
    +*   http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing,
    +* software distributed under the License is distributed on an
    +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +* KIND, either express or implied.  See the License for the
    +* specific language governing permissions and limitations
    +* under the License.
    +*
    +*/
    +
    +var path = require('path');
    +var fs = require('fs');
    +
    +module.exports = function(context) {
    +    function main() {
    +        // get the file transfer server address from the specified variables
    +        var defaultFileTransferServerAddress = getDefaultFileTransferServerAddress(context);
    +        var fileTransferServerAddress = getFileTransferServerAddress(context) || defaultFileTransferServerAddress;
    +        console.log('Tests will use the following file transfer server address: ' + fileTransferServerAddress);
    +
    +        // pass it to the tests
    +        writeFileTransferOptions(fileTransferServerAddress, context);
    +    }
    +
    +    function getDefaultFileTransferServerAddress(context) {
    --- End diff --
    
    I'm curious whether this function is needed. If there is a default value for variable and user didn't override it via CLI parameter, isn't the default value being written to `<platform>.json` file?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by vladimir-kotikov <gi...@git.apache.org>.
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159#discussion_r81722419
  
    --- Diff: tests/hooks/after_prepare.js ---
    @@ -0,0 +1,71 @@
    +#!/usr/bin/env node
    +
    +/*
    +*
    +* Licensed to the Apache Software Foundation (ASF) under one
    +* or more contributor license agreements.  See the NOTICE file
    +* distributed with this work for additional information
    +* regarding copyright ownership.  The ASF licenses this file
    +* to you under the Apache License, Version 2.0 (the
    +* "License"); you may not use this file except in compliance
    +* with the License.  You may obtain a copy of the License at
    +*
    +*   http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing,
    +* software distributed under the License is distributed on an
    +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +* KIND, either express or implied.  See the License for the
    +* specific language governing permissions and limitations
    +* under the License.
    +*
    +*/
    +
    +var path = require('path');
    +var fs = require('fs');
    +
    +module.exports = function(context) {
    +    function main() {
    +        // get the file transfer server address from the specified variables
    +        var defaultFileTransferServerAddress = getDefaultFileTransferServerAddress(context);
    +        var fileTransferServerAddress = getFileTransferServerAddress(context) || defaultFileTransferServerAddress;
    +        console.log('Tests will use the following file transfer server address: ' + fileTransferServerAddress);
    +
    +        // pass it to the tests
    +        writeFileTransferOptions(fileTransferServerAddress, context);
    +    }
    +
    +    function getDefaultFileTransferServerAddress(context) {
    --- End diff --
    
    This is odd, because after running this: `cordova plugin add https://github.com/alsorokin/cordova-plugin-file-transfer#ca293bd3f29dc74f628721a552ff91593380d81e:tests` _(notice that i didn't specify any variables)_, i can see these lines in `platforms/windows/windows.json`:
    ```json
            "cordova-plugin-file-transfer-tests": {
                "FILETRANSFER_SERVER_ADDRESS": "http://cordova-vm.apache.org:5000",
                "PACKAGE_NAME": "HelloCordova"
            }
    ```
    
    Could you please double-check


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by alsorokin <gi...@git.apache.org>.
Github user alsorokin commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159#discussion_r81722427
  
    --- Diff: tests/hooks/after_prepare.js ---
    @@ -0,0 +1,71 @@
    +#!/usr/bin/env node
    +
    +/*
    +*
    +* Licensed to the Apache Software Foundation (ASF) under one
    +* or more contributor license agreements.  See the NOTICE file
    +* distributed with this work for additional information
    +* regarding copyright ownership.  The ASF licenses this file
    +* to you under the Apache License, Version 2.0 (the
    +* "License"); you may not use this file except in compliance
    +* with the License.  You may obtain a copy of the License at
    +*
    +*   http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing,
    +* software distributed under the License is distributed on an
    +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +* KIND, either express or implied.  See the License for the
    +* specific language governing permissions and limitations
    +* under the License.
    +*
    +*/
    +
    +var path = require('path');
    +var fs = require('fs');
    +
    +module.exports = function(context) {
    +    function main() {
    +        // get the file transfer server address from the specified variables
    +        var defaultFileTransferServerAddress = getDefaultFileTransferServerAddress(context);
    +        var fileTransferServerAddress = getFileTransferServerAddress(context) || defaultFileTransferServerAddress;
    +        console.log('Tests will use the following file transfer server address: ' + fileTransferServerAddress);
    +
    +        // pass it to the tests
    +        writeFileTransferOptions(fileTransferServerAddress, context);
    +    }
    +
    +    function getDefaultFileTransferServerAddress(context) {
    +        var address = null;
    +        var configNodes = context.opts.plugin.pluginInfo._et._root._children;
    +
    +        for (var node in configNodes) {
    +            if (configNodes[node].attrib.name == 'FILETRANSFER_SERVER_ADDRESS') {
    +                address = configNodes[node].attrib.default;
    +            }
    +        }
    +
    +        return address;
    +    }
    +
    +    function getFileTransferServerAddress(context) {
    +        var platformJsonFile = path.join(context.opts.projectRoot, 'plugins', context.opts.platforms[0] + '.json');
    --- End diff --
    
    Well, I don't see a way to get the path to it from the context.
    Here's what I got:
    https://gist.github.com/alsorokin/45f16a4c098a21082ee457157407ac8a


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-plugin-file-transfer pull request #159: CB-11926 Tests can use local...

Posted by alsorokin <gi...@git.apache.org>.
Github user alsorokin commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/159#discussion_r81716605
  
    --- Diff: tests/hooks/after_prepare.js ---
    @@ -0,0 +1,71 @@
    +#!/usr/bin/env node
    +
    +/*
    +*
    +* Licensed to the Apache Software Foundation (ASF) under one
    +* or more contributor license agreements.  See the NOTICE file
    +* distributed with this work for additional information
    +* regarding copyright ownership.  The ASF licenses this file
    +* to you under the Apache License, Version 2.0 (the
    +* "License"); you may not use this file except in compliance
    +* with the License.  You may obtain a copy of the License at
    +*
    +*   http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing,
    +* software distributed under the License is distributed on an
    +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +* KIND, either express or implied.  See the License for the
    +* specific language governing permissions and limitations
    +* under the License.
    +*
    +*/
    +
    +var path = require('path');
    +var fs = require('fs');
    +
    +module.exports = function(context) {
    +    function main() {
    +        // get the file transfer server address from the specified variables
    +        var defaultFileTransferServerAddress = getDefaultFileTransferServerAddress(context);
    +        var fileTransferServerAddress = getFileTransferServerAddress(context) || defaultFileTransferServerAddress;
    +        console.log('Tests will use the following file transfer server address: ' + fileTransferServerAddress);
    +
    +        // pass it to the tests
    +        writeFileTransferOptions(fileTransferServerAddress, context);
    +    }
    +
    +    function getDefaultFileTransferServerAddress(context) {
    --- End diff --
    
    No it isn't


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org