├── .github └── workflows │ └── tests-all.yml ├── .gitignore ├── CONTRIBUTIONS ├── COPYING ├── README.md ├── cmdtests ├── bug-build-with-spaces.script ├── bug-build-with-spaces.stdout ├── bug-commit-builder-not-available.script ├── bug-commit-builder-not-available.stdout ├── bug-control-d.script ├── bug-control-d.stdout ├── cmd-branch.script ├── cmd-branch.stdout ├── cmd-build.script ├── cmd-build.stdout ├── cmd-commit-build-failure-accept.script ├── cmd-commit-build-failure-accept.stdout ├── cmd-commit-build-failure.script ├── cmd-commit-build-failure.stdout ├── cmd-commit-build-warnings-accept.script ├── cmd-commit-build-warnings-accept.stdout ├── cmd-commit-conflict.script ├── cmd-commit-conflict.stdout ├── cmd-commit-errors.script ├── cmd-commit-errors.stdout ├── cmd-commit-multiple-failure.script ├── cmd-commit-multiple-failure.stdout ├── cmd-commit-multiple-patches.script ├── cmd-commit-multiple-patches.stdout ├── cmd-commit.script ├── cmd-commit.stdout ├── cmd-download.script ├── cmd-download.stdout ├── cmd-edit.script ├── cmd-edit.stdout ├── cmd-info.script ├── cmd-info.stdout ├── cmd-list.script ├── cmd-list.stdout ├── cmd-reply-resend.script ├── cmd-reply-resend.stdout ├── cmd-reply.script ├── cmd-reply.stdout ├── cmd-review-changes-requested-single.script ├── cmd-review-changes-requested-single.stdout ├── cmd-review-reject-multiple.script ├── cmd-review-reject-multiple.stdout ├── cmd-review-stg-build-failure-accept.script ├── cmd-review-stg-build-failure-accept.stdout ├── cmd-review-stg-conflict.script ├── cmd-review-stg-conflict.stdout ├── cmd-review-stg-multiple-abort.script ├── cmd-review-stg-multiple-abort.stdout ├── cmd-review-stg-multiple-fail.script ├── cmd-review-stg-multiple-fail.stdout ├── cmd-review-stg-single.script ├── cmd-review-stg-single.stdout ├── cmd-review.script ├── cmd-review.stdout ├── cmd-show-stg.script ├── cmd-show-stg.stdout ├── cmd-show.script ├── cmd-show.stdout ├── cmdtestlib.py ├── utf-8.script └── utf-8.stdout ├── pwcli ├── pwcli.conf ├── run_stub ├── run_tests ├── stubs ├── builder ├── cmdtests │ ├── builder.script │ ├── builder.stderr │ ├── builder.stdout │ ├── git.script │ ├── git.stdout │ ├── patchwork-load-patches.script │ ├── patchwork-load-patches.stdout │ ├── patchwork-rest.script │ ├── patchwork-rest.stdout │ ├── pwcli-wrapper.script │ ├── pwcli-wrapper.stdout │ ├── smtpd.script │ ├── smtpd.stdout │ ├── stg.script │ ├── stg.stderr │ └── stg.stdout ├── create_fake_patches ├── data │ └── patches │ │ ├── 1001-review-foo-test-1.patch │ │ ├── 1002-review-foo-test-2.patch │ │ ├── 1003-review-foo-test-3.patch │ │ ├── 1004-review-foo-test-4.patch │ │ ├── 1005-review-foo-test-5.patch │ │ ├── 1006-review-foo-test-6.patch │ │ ├── 1007-review-foo-test-7.patch │ │ ├── 1020-deferred-foo-small-cleanup.patch │ │ ├── 1021-utf8-test.patch │ │ ├── 1030-new-foo-new-patch.patch │ │ ├── 1031-new-foo-minor-change-with-cc.patch │ │ ├── 1032-new-foo-another-minor-change-with-multiple-to.patch │ │ ├── 1040-new-bar-blah-blah-blah-1.patch │ │ ├── 1041-new-bar-blah-blah-blah-2.patch │ │ ├── 1042-new-bar-blah-blah-blah-3.patch │ │ ├── 1043-new-bar-blah-blah-blah-4.patch │ │ ├── 1044-new-bar-blah-blah-blah-5.patch │ │ ├── 1045-new-bar-blah-blah-blah-6.patch │ │ ├── 1046-new-bar-blah-blah-blah-7.patch │ │ ├── 1047-new-bar-blah-blah-blah-8.patch │ │ ├── 1048-new-bar-blah-blah-blah-9.patch │ │ ├── 1049-new-bar-blah-blah-blah-10.patch │ │ ├── 1050-new-bar-blah-blah-blah-11.patch │ │ ├── 1051-new-bar-blah-blah-blah-12.patch │ │ ├── 1052-new-bar-blah-blah-blah-13.patch │ │ ├── 1053-new-bar-blah-blah-blah-14.patch │ │ ├── 1054-new-bar-blah-blah-blah-15.patch │ │ ├── 1060-deferred-koo-yyy-bbb-cc-1.patch │ │ ├── 1061-deferred-koo-yyy-bbb-cc-2.patch │ │ ├── 1062-deferred-koo-yyy-bbb-cc-3.patch │ │ ├── 1063-deferred-koo-yyy-bbb-cc-4.patch │ │ └── 123456789-new-patch-with-a-really-long-name-and-id.patch ├── git ├── gui-mock ├── patchwork ├── rest-test-1.py ├── smtpclient ├── smtpd ├── stg ├── stubs.py └── stubslib.py ├── tests.ini └── unittests ├── .gitignore ├── __init__.py ├── git-show-simple-1.data ├── run ├── stg-show-1.data ├── test_git.py ├── test_patch.py ├── test_runprocess.py └── test_utils.py /.github/workflows/tests-all.yml: -------------------------------------------------------------------------------- 1 | name: tests-all 2 | on: [push] 3 | jobs: 4 | run-tests: 5 | runs-on: ubuntu-22.04 6 | steps: 7 | - uses: actions/checkout@v4 8 | - run: sudo apt update 9 | - run: sudo apt install pycodestyle pyflakes3 cmdtest figlet python3-flask-restful python3-pexpect python3-aiosmtpd python3-mock diffstat 10 | - run: ./run_tests 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.pyc 3 | *.std???-actual 4 | *.std???-diff 5 | -------------------------------------------------------------------------------- /CONTRIBUTIONS: -------------------------------------------------------------------------------- 1 | Contributions to pwcli.git 2 | -------------------------- 3 | 4 | This software is distributed under a permissive open source license to 5 | allow it to be used in any projects, whether open source or proprietary. 6 | Contributions to the project are welcome and it is important to maintain 7 | clear record of contributions and terms under which they are licensed. 8 | To help with this, following procedure is used to allow acceptance and 9 | recording of the terms. 10 | 11 | All contributions are expected to be licensed under the 3-clause BSD 12 | license (see below). Acknowledgment of the terms is tracked through 13 | inclusion of Signed-off-by tag in the contributions at the end of the 14 | commit log message. This tag indicates that the contributor agrees with 15 | the Developer Certificate of Origin (DCO) version 1.1 terms (see below; 16 | also available from http://developercertificate.org/). 17 | 18 | 19 | The current requirements for contributions to pwcli.git 20 | ------------------------------------------------------- 21 | 22 | To indicate your acceptance of Developer's Certificate of Origin 1.1 23 | terms, please add the following line to the end of the commit message 24 | for each contribution you make to the project: 25 | 26 | Signed-off-by: Your Name 27 | 28 | using your real name. Pseudonyms or anonymous contributions cannot 29 | unfortunately be accepted. 30 | 31 | ===[ start quote from http://developercertificate.org/ ]======================= 32 | 33 | Developer Certificate of Origin 34 | Version 1.1 35 | 36 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 37 | 660 York Street, Suite 102, 38 | San Francisco, CA 94110 USA 39 | 40 | Everyone is permitted to copy and distribute verbatim copies of this 41 | license document, but changing it is not allowed. 42 | 43 | 44 | Developer's Certificate of Origin 1.1 45 | 46 | By making a contribution to this project, I certify that: 47 | 48 | (a) The contribution was created in whole or in part by me and I 49 | have the right to submit it under the open source license 50 | indicated in the file; or 51 | 52 | (b) The contribution is based upon previous work that, to the best 53 | of my knowledge, is covered under an appropriate open source 54 | license and I have the right under that license to submit that 55 | work with modifications, whether created in whole or in part 56 | by me, under the same open source license (unless I am 57 | permitted to submit under a different license), as indicated 58 | in the file; or 59 | 60 | (c) The contribution was provided directly to me by some other 61 | person who certified (a), (b) or (c) and I have not modified 62 | it. 63 | 64 | (d) I understand and agree that this project and the contribution 65 | are public and that a record of the contribution (including all 66 | personal information I submit with it, including my sign-off) is 67 | maintained indefinitely and may be redistributed consistent with 68 | this project or the open source license(s) involved. 69 | 70 | ===[ end quote from http://developercertificate.org/ ]========================= 71 | 72 | 73 | The license terms used for pwcli.git files 74 | ------------------------------------------- 75 | 76 | Copyright (c) 2015, The Linux Foundation. 77 | All rights reserved. 78 | 79 | Redistribution and use in source and binary forms, with or without 80 | modification, are permitted provided that the following conditions are 81 | met: 82 | 83 | 1. Redistributions of source code must retain the above copyright 84 | notice, this list of conditions and the following disclaimer. 85 | 86 | 2. Redistributions in binary form must reproduce the above copyright 87 | notice, this list of conditions and the following disclaimer in the 88 | documentation and/or other materials provided with the distribution. 89 | 90 | 3. Neither the name of the copyright holder nor the names of its 91 | contributors may be used to endorse or promote products derived from 92 | this software without specific prior written permission. 93 | 94 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 95 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 96 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 97 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 98 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 99 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 100 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 101 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 102 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 103 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 104 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 105 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, The Linux Foundation. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /cmdtests/bug-build-with-spaces.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_build(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('build') 39 | 40 | pwcli.expect_prompt() 41 | pwcli.sendline('quit') 42 | 43 | if __name__ == "__main__": 44 | cmdtestlib.StubContext.run_test(test_build, 45 | builder='/bin/echo this is a build script with spaces') 46 | 47 | -------------------------------------------------------------------------------- /cmdtests/bug-build-with-spaces.stdout: -------------------------------------------------------------------------------- 1 | Starting build: /bin/echo this is a build script with spaces 2 | Connecting to http://localhost:8105/ 3 | Downloading patches from the server 4 | Build successful 5 | User : test 6 | Project : stub-test 7 | Tree : data 8 | Branch : master 9 | New : 19 10 | Review : 7 11 | Upstream : 0 12 | Deferred : 6 13 | Total : 32 14 | master@data > build 15 | build 16 | this is a build script with spaces Build successful 17 | master@data > quit 18 | -------------------------------------------------------------------------------- /cmdtests/bug-commit-builder-not-available.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_build(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('commit 1') 41 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 42 | pwcli.sendline('a') 43 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 44 | pwcli.sendline('a') 45 | 46 | pwcli.expect_prompt() 47 | pwcli.sendline('quit') 48 | 49 | if __name__ == "__main__": 50 | cmdtestlib.StubContext.run_test(test_build, builder=None) 51 | 52 | -------------------------------------------------------------------------------- /cmdtests/bug-commit-builder-not-available.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list review 13 | list review 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | master@data > commit 1 22 | commit 1 23 | Retrieving patches (1/1) 24 | [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 25 | ------------------------------------------------------------ 26 | 1 patches 27 | commit All/aBort? a 28 | a 29 | Committing patches (1/1) 30 | ============================================================ 31 | 1 patches applied: 32 | 33 | b50b875961e9 foo: test 1 34 | 35 | Accepted/Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? a 36 | a 37 | Setting patch state (1/1) 38 | Patch set to Accepted 39 | master@data > quit 40 | -------------------------------------------------------------------------------- /cmdtests/bug-control-d.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | import pexpect 36 | 37 | def test_control_d(ctxt, pwcli): 38 | pwcli.expect_prompt() 39 | 40 | # first just send a return 41 | pwcli.sendline('') 42 | pwcli.expect_prompt() 43 | 44 | # then send CTRL-d 45 | pwcli.sendcontrol('d') 46 | 47 | # wait for EOF from pwcli 48 | pwcli.expect(pexpect.EOF) 49 | 50 | if __name__ == "__main__": 51 | cmdtestlib.StubContext.run_test(test_control_d) 52 | -------------------------------------------------------------------------------- /cmdtests/bug-control-d.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > 13 | 14 | usage: {help,quit,q,list,commit,delegate,pull,review,show,reply,branch,info,build,stg,download,edit} ... 15 | : error: the following arguments are required: cmd 16 | master@data >  17 | -------------------------------------------------------------------------------- /cmdtests/cmd-branch.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2020, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_branch(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | 39 | pwcli.sendline('branch') 40 | pwcli.expect_prompt() 41 | 42 | pwcli.sendline('quit') 43 | 44 | if __name__ == "__main__": 45 | cmdtestlib.StubContext.run_test(test_branch) 46 | -------------------------------------------------------------------------------- /cmdtests/cmd-branch.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > branch 13 | branch 14 | not enabled: general.main-branches config option not set 15 | master@data > quit 16 | -------------------------------------------------------------------------------- /cmdtests/cmd-build.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_build(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('build') 39 | 40 | pwcli.expect_prompt() 41 | pwcli.sendline('quit') 42 | 43 | if __name__ == "__main__": 44 | cmdtestlib.StubContext.run_test(test_build, builder='builder') 45 | 46 | -------------------------------------------------------------------------------- /cmdtests/cmd-build.stdout: -------------------------------------------------------------------------------- 1 | Starting build: builder 2 | Connecting to http://localhost:8105/ 3 | Downloading patches from the server 4 | Build successful 5 | User : test 6 | Project : stub-test 7 | Tree : data 8 | Branch : master 9 | New : 19 10 | Review : 7 11 | Upstream : 0 12 | Deferred : 6 13 | Total : 32 14 | master@data > build 15 | build 16 | 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 CC foo.c CC bar.c CC aaa.c CC bbb.c Build successful 17 | master@data > quit 18 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-build-failure-accept.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | 41 | ctxt.builder.set_return_value(1) 42 | 43 | pwcli.sendline('commit 1') 44 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 45 | pwcli.sendline('a') 46 | 47 | # Accept patches 48 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 49 | pwcli.sendline('a') 50 | 51 | # Yes, we are sure 52 | pwcli.expect_exact(cmdtestlib.PROMPT_ACCEPT_CONFIRM) 53 | pwcli.sendline('y') 54 | 55 | pwcli.expect_prompt() 56 | pwcli.sendline('quit') 57 | 58 | print(ctxt.smtpd.get_mails_as_string()) 59 | 60 | if __name__ == "__main__": 61 | cmdtestlib.StubContext.run_test(test_commit, builder='builder') 62 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-build-failure-accept.stdout: -------------------------------------------------------------------------------- 1 | Starting build: builder 2 | Connecting to http://localhost:8105/ 3 | Downloading patches from the server 4 | Build successful 5 | User : test 6 | Project : stub-test 7 | Tree : data 8 | Branch : master 9 | New : 19 10 | Review : 7 11 | Upstream : 0 12 | Deferred : 6 13 | Total : 32 14 | master@data > list review 15 | list review 16 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 17 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 18 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 19 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 20 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 21 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 22 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 23 | master@data > commit 1 24 | commit 1 25 | Retrieving patches (1/1) 26 | [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 27 | ------------------------------------------------------------ 28 | 1 patches 29 | commit All/aBort? a 30 | a 31 | Committing patches (1/1) 32 | 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 CC foo.c CC bar.c CC aaa.c CC bbb.c 33 | Build failed: 1 34 | ============================================================ 35 | 1 patches applied: 36 | 37 | b50b875961e9 foo: test 1 38 | 39 | Accepted/Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? a 40 | a 41 | Build FAILED! 42 | Are you sure want to ACCEPT these patches [y/N]: y 43 | y 44 | Setting patch state (1/1) 45 | Patch set to Accepted 46 | master@data > quit 47 | mail 0: 48 | ---------------------------------------------------------------------- 49 | test@example.com -> dino@example.com, list@example.com 50 | Content-Type: text/plain; charset="utf-8" 51 | MIME-Version: 1.0 52 | Content-Transfer-Encoding: 7bit 53 | Subject: Re: [1/7] foo: test 1 54 | From: Timo Testi 55 | In-Reply-To: <11111@example.com> 56 | References: <11111@example.com> 57 | To: Dino Dinosaurus 58 | Cc: list@example.com 59 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) 60 | Python/ 61 | Message-ID: 1-2-3-hardcoded@example.com 62 | 63 | Dino Dinosaurus wrote: 64 | 65 | > Foo commit log. Ignore this text 66 | > 67 | > Signed-off-by: Dino Dinosaurus 68 | 69 | Patch applied to data.git, thanks. 70 | 71 | b50b875961e9 foo: test 1 72 | 73 | -- 74 | Sent by pwcli 75 | http://localhost/fixme/12345 76 | ---------------------------------------------------------------------- 77 | 78 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-build-failure.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | 41 | ctxt.builder.set_warning_count(5) 42 | ctxt.builder.set_return_value(1) 43 | 44 | pwcli.sendline('commit 1') 45 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 46 | pwcli.sendline('a') 47 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 48 | pwcli.sendline('c') 49 | 50 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 51 | pwcli.sendline('Compile errors') 52 | 53 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 54 | pwcli.sendline('s') 55 | 56 | pwcli.expect_prompt() 57 | pwcli.sendline('quit') 58 | 59 | print(ctxt.smtpd.get_mails_as_string()) 60 | 61 | if __name__ == "__main__": 62 | cmdtestlib.StubContext.run_test(test_commit, builder='builder') 63 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-build-warnings-accept.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016-2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | 41 | ctxt.builder.set_warning_count(10) 42 | 43 | pwcli.sendline('commit 1') 44 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 45 | pwcli.sendline('a') 46 | 47 | # Accept patches 48 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 49 | pwcli.sendline('a') 50 | 51 | # No, first time not sure 52 | pwcli.expect_exact(cmdtestlib.PROMPT_ACCEPT_CONFIRM) 53 | pwcli.sendline('n') 54 | 55 | # Accept patches 56 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 57 | pwcli.sendline('a') 58 | 59 | # Yes, now we are sure 60 | pwcli.expect_exact(cmdtestlib.PROMPT_ACCEPT_CONFIRM) 61 | pwcli.sendline('Y') 62 | 63 | pwcli.expect_prompt() 64 | pwcli.sendline('quit') 65 | 66 | print(ctxt.smtpd.get_mails_as_string()) 67 | 68 | if __name__ == "__main__": 69 | cmdtestlib.StubContext.run_test(test_commit, builder='builder') 70 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-conflict.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | 41 | # the next git am command must fail 42 | ctxt.git.set_commit_failure(1) 43 | 44 | pwcli.sendline('commit 1') 45 | 46 | # commit all 47 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 48 | pwcli.sendline('a') 49 | 50 | # changes requested 51 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 52 | pwcli.sendline('c') 53 | 54 | # reason 55 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 56 | pwcli.sendline('Failed to apply') 57 | 58 | # send mail 59 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 60 | pwcli.sendline('s') 61 | 62 | pwcli.expect_prompt() 63 | pwcli.sendline('quit') 64 | 65 | print(ctxt.smtpd.get_mails_as_string()) 66 | 67 | if __name__ == "__main__": 68 | cmdtestlib.StubContext.run_test(test_commit) 69 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-conflict.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list review 13 | list review 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | master@data > commit 1 22 | commit 1 23 | Retrieving patches (1/1) 24 | [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 25 | ------------------------------------------------------------ 26 | 1 patches 27 | commit All/aBort? a 28 | a 29 | Committing patches (1/1) 30 | Failed to apply the patch: ['git', 'am', '-s', '-3'] failed: 1 31 | Applying: foo: conflict patch 32 | Using index info to reconstruct a base tree... 33 | Falling back to patching base and 3-way merge... 34 | Auto-merging foo/bar.c 35 | CONFLICT (content): Merge conflict in drivers/net/wireless/ath/foo/core.h 36 | Failed to merge in the changes. 37 | Patch failed at 0001 foo: conflict patch 38 | 39 | Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? c 40 | c 41 | Setting patch state (1/1) 42 | Patch set to Changes Requested 43 | Reason (RET for no mail): Failed to apply 44 | Failed to apply 45 | ============================================================ 46 | Content-Type: text/plain; charset="utf-8" 47 | MIME-Version: 1.0 48 | Content-Transfer-Encoding: 7bit 49 | Subject: Re: [1/7] foo: test 1 50 | From: Timo Testi 51 | In-Reply-To: <11111@example.com> 52 | References: <11111@example.com> 53 | To: Dino Dinosaurus 54 | Cc: list@example.com 55 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) Python/ 56 | 57 | Dino Dinosaurus wrote: 58 | 59 | > Foo commit log. Ignore this text 60 | > 61 | > Signed-off-by: Dino Dinosaurus 62 | 63 | Failed to apply 64 | 65 | Applying: foo: conflict patch 66 | Using index info to reconstruct a base tree... 67 | Falling back to patching base and 3-way merge... 68 | Auto-merging foo/bar.c 69 | CONFLICT (content): Merge conflict in drivers/net/wireless/ath/foo/core.h 70 | Failed to merge in the changes. 71 | Patch failed at 0001 foo: conflict patch 72 | 73 | Patch set to Changes Requested. 74 | 75 | -- 76 | Sent by pwcli 77 | http://localhost/fixme/12345 78 | 79 | 80 | ============================================================ 81 | Envelope From: Timo Testi 82 | Envelope To: ['Dino Dinosaurus ', 'list@example.com'] 83 | Send/Edit/aBort? s 84 | s 85 | master@data > quit 86 | mail 0: 87 | ---------------------------------------------------------------------- 88 | test@example.com -> dino@example.com, list@example.com 89 | Content-Type: text/plain; charset="utf-8" 90 | MIME-Version: 1.0 91 | Content-Transfer-Encoding: 7bit 92 | Subject: Re: [1/7] foo: test 1 93 | From: Timo Testi 94 | In-Reply-To: <11111@example.com> 95 | References: <11111@example.com> 96 | To: Dino Dinosaurus 97 | Cc: list@example.com 98 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) 99 | Python/ 100 | Message-ID: 1-2-3-hardcoded@example.com 101 | 102 | Dino Dinosaurus wrote: 103 | 104 | > Foo commit log. Ignore this text 105 | > 106 | > Signed-off-by: Dino Dinosaurus 107 | 108 | Failed to apply 109 | 110 | Applying: foo: conflict patch 111 | Using index info to reconstruct a base tree... 112 | Falling back to patching base and 3-way merge... 113 | Auto-merging foo/bar.c 114 | CONFLICT (content): Merge conflict in drivers/net/wireless/ath/foo/core.h 115 | Failed to merge in the changes. 116 | Patch failed at 0001 foo: conflict patch 117 | 118 | Patch set to Changes Requested. 119 | 120 | -- 121 | Sent by pwcli 122 | http://localhost/fixme/12345 123 | ---------------------------------------------------------------------- 124 | 125 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-errors.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | 39 | pwcli.sendline('list review') 40 | pwcli.expect_prompt() 41 | 42 | pwcli.sendline('commit foo') 43 | pwcli.expect_prompt() 44 | 45 | pwcli.sendline('commit 1 2') 46 | pwcli.expect_prompt() 47 | 48 | pwcli.sendline('quit') 49 | 50 | if __name__ == "__main__": 51 | cmdtestlib.StubContext.run_test(test_commit) 52 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-errors.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list review 13 | list review 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | master@data > commit foo 22 | commit foo 23 | command failed: Not a digit: foo 24 | master@data > commit 1 2 25 | commit 1 2 26 | usage: {help,quit,q,list,commit,delegate,pull,review,show,reply,branch,info,build,stg,download,edit} ... 27 | : error: unrecognized arguments: 2 28 | master@data > quit 29 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-multiple-failure.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | 38 | # first apply one commit to the repository as the baseline 39 | pwcli.expect_prompt() 40 | pwcli.sendline('list new') 41 | 42 | pwcli.expect_prompt() 43 | pwcli.sendline('commit 1') 44 | 45 | # all 46 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 47 | pwcli.sendline('a') 48 | 49 | # accept 50 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 51 | pwcli.sendline('a') 52 | 53 | # now apply apply a bigger patch which fails in patch 5 54 | pwcli.expect_prompt() 55 | pwcli.sendline('list review') 56 | 57 | ctxt.git.set_commit_failure(5) 58 | 59 | pwcli.expect_prompt() 60 | pwcli.sendline('commit 1-7') 61 | 62 | # all 63 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 64 | pwcli.sendline('a') 65 | 66 | # changes requested 67 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 68 | pwcli.sendline('c') 69 | 70 | # reason 71 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 72 | pwcli.sendline('Patch 5 failed to apply.') 73 | 74 | # send mail 75 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 76 | pwcli.sendline('s') 77 | 78 | pwcli.expect_prompt() 79 | pwcli.sendline('quit') 80 | 81 | print(ctxt.smtpd.get_mails_as_string()) 82 | 83 | # print the top commit 84 | print(ctxt.git.get_commits_oneline(1)) 85 | 86 | if __name__ == "__main__": 87 | cmdtestlib.StubContext.run_test(test_commit) 88 | 89 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit-multiple-patches.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016,2019, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('commit 1-2') 41 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 42 | pwcli.sendline('a') 43 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 44 | pwcli.sendline('a') 45 | 46 | # test magic patch index 'all' 47 | pwcli.expect_prompt() 48 | pwcli.sendline('list -s deferred') 49 | pwcli.expect_prompt() 50 | pwcli.sendline('commit all') 51 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 52 | pwcli.sendline('a') 53 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 54 | pwcli.sendline('a') 55 | 56 | pwcli.expect_prompt() 57 | pwcli.sendline('quit') 58 | 59 | print(ctxt.smtpd.get_mails_as_string()) 60 | 61 | if __name__ == "__main__": 62 | cmdtestlib.StubContext.run_test(test_commit) 63 | 64 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_commit(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('commit 1') 41 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 42 | pwcli.sendline('a') 43 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 44 | pwcli.sendline('a') 45 | 46 | pwcli.expect_prompt() 47 | pwcli.sendline('quit') 48 | 49 | print(ctxt.smtpd.get_mails_as_string()) 50 | 51 | if __name__ == "__main__": 52 | cmdtestlib.StubContext.run_test(test_commit) 53 | -------------------------------------------------------------------------------- /cmdtests/cmd-commit.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list review 13 | list review 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | master@data > commit 1 22 | commit 1 23 | Retrieving patches (1/1) 24 | [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 25 | ------------------------------------------------------------ 26 | 1 patches 27 | commit All/aBort? a 28 | a 29 | Committing patches (1/1) 30 | ============================================================ 31 | 1 patches applied: 32 | 33 | b50b875961e9 foo: test 1 34 | 35 | Accepted/Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? a 36 | a 37 | Setting patch state (1/1) 38 | Patch set to Accepted 39 | master@data > quit 40 | mail 0: 41 | ---------------------------------------------------------------------- 42 | test@example.com -> dino@example.com, list@example.com 43 | Content-Type: text/plain; charset="utf-8" 44 | MIME-Version: 1.0 45 | Content-Transfer-Encoding: 7bit 46 | Subject: Re: [1/7] foo: test 1 47 | From: Timo Testi 48 | In-Reply-To: <11111@example.com> 49 | References: <11111@example.com> 50 | To: Dino Dinosaurus 51 | Cc: list@example.com 52 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) 53 | Python/ 54 | Message-ID: 1-2-3-hardcoded@example.com 55 | 56 | Dino Dinosaurus wrote: 57 | 58 | > Foo commit log. Ignore this text 59 | > 60 | > Signed-off-by: Dino Dinosaurus 61 | 62 | Patch applied to data.git, thanks. 63 | 64 | b50b875961e9 foo: test 1 65 | 66 | -- 67 | Sent by pwcli 68 | http://localhost/fixme/12345 69 | ---------------------------------------------------------------------- 70 | 71 | -------------------------------------------------------------------------------- /cmdtests/cmd-download.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | import mailbox 36 | 37 | def test_info(ctxt, pwcli): 38 | pwcli.expect_prompt() 39 | 40 | pwcli.sendline('list') 41 | pwcli.expect_prompt() 42 | 43 | pwcli.sendline('download 10-12') 44 | pwcli.expect_prompt() 45 | 46 | pwcli.sendline('quit') 47 | 48 | path = '1030.mbox' 49 | mbox = mailbox.mbox(path) 50 | 51 | print('%d messages found from %s:' % (len(mbox), path)) 52 | for msg in mbox: 53 | print(msg['Subject']) 54 | mbox.close() 55 | 56 | if __name__ == "__main__": 57 | cmdtestlib.StubContext.run_test(test_info) 58 | -------------------------------------------------------------------------------- /cmdtests/cmd-download.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list 13 | list 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | [ 8] foo: small cleanup - - - - 3d Timo Tiger Deferred 22 | [ 9] foo: utf-8 tèst - - - - 3d Èd Examplè Deferred 23 | [ 10] foo: new patch - - - - 3d Timo Tiger New 24 | [ 11] foo: minor change with CC - - - - 2d Timo Tiger New 25 | [ 12] foo: another minor change with multiple To - - - - 2d Timo Tiger New 26 | [ 13] [1/15] bar: blah blah blah 1 - - - - 2d Dino Dinosau New 27 | [ 14] [2/15] bar: blah blah blah 2 - - - - 2d Dino Dinosau New 28 | [ 15] [3/15] bar: blah blah blah 3 - - - - 2d Dino Dinosau New 29 | [ 16] [4/15] bar: blah blah blah 4 - - - - 2d Dino Dinosau New 30 | [ 17] [5/15] bar: blah blah blah 5 - - - - 2d Dino Dinosau New 31 | [ 18] [6/15] bar: blah blah blah 6 - - - - 2d Dino Dinosau New 32 | [ 19] [7/15] bar: blah blah blah 7 - - - - 2d Dino Dinosau New 33 | [ 20] [8/15] bar: blah blah blah 8 - - - - 2d Dino Dinosau New 34 | [ 21] [9/15] bar: blah blah blah 9 - - - - 2d Dino Dinosau New 35 | [ 22] [10/15] bar: blah blah blah 10 - - - - 2d Dino Dinosau New 36 | [ 23] [11/15] bar: blah blah blah 11 - - - - 2d Dino Dinosau New 37 | [ 24] [12/15] bar: blah blah blah 12 - - - - 2d Dino Dinosau New 38 | [ 25] [13/15] bar: blah blah blah 13 - - - - 2d Dino Dinosau New 39 | [ 26] [14/15] bar: blah blah blah 14 - - - - 2d Dino Dinosau New 40 | [ 27] [15/15] bar: blah blah blah 15 - - - - 2d Dino Dinosau New 41 | [ 28] [1/4] koo: yyy bbb cc 1 - - - - 2d Dino Dinosau Deferred 42 | [ 29] [2/4] koo: yyy bbb cc 2 - - - - 2d Dino Dinosau Deferred 43 | [ 30] [3/4] koo: yyy bbb cc 3 - - - - 2d Dino Dinosau Deferred 44 | [ 31] [4/4] koo: yyy bbb cc 4 - - - - 2d Dino Dinosau Deferred 45 | [ 32] foo: patch with a really long a name and id so I just need to keep.... - - - - 11h Lasse Really New 46 | master@data > download 10-12 47 | download 10-12 48 | 3 patches written to 1030.mbox 49 | master@data > quit 50 | 3 messages found from 1030.mbox: 51 | foo: new patch 52 | foo: minor change with CC 53 | foo: another minor change with multiple To 54 | -------------------------------------------------------------------------------- /cmdtests/cmd-edit.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2020, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_info(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | 39 | pwcli.sendline('list') 40 | pwcli.expect_prompt() 41 | 42 | # TODO: change something in the patch, now EDITOR is just /bin/true 43 | # so nothing changed 44 | pwcli.sendline('edit 32') 45 | pwcli.expect_prompt() 46 | 47 | pwcli.sendline('show 32') 48 | pwcli.expect_prompt() 49 | 50 | pwcli.sendline('quit') 51 | 52 | if __name__ == "__main__": 53 | cmdtestlib.StubContext.run_test(test_info) 54 | -------------------------------------------------------------------------------- /cmdtests/cmd-edit.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list 13 | list 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | [ 8] foo: small cleanup - - - - 3d Timo Tiger Deferred 22 | [ 9] foo: utf-8 tèst - - - - 3d Èd Examplè Deferred 23 | [ 10] foo: new patch - - - - 3d Timo Tiger New 24 | [ 11] foo: minor change with CC - - - - 2d Timo Tiger New 25 | [ 12] foo: another minor change with multiple To - - - - 2d Timo Tiger New 26 | [ 13] [1/15] bar: blah blah blah 1 - - - - 2d Dino Dinosau New 27 | [ 14] [2/15] bar: blah blah blah 2 - - - - 2d Dino Dinosau New 28 | [ 15] [3/15] bar: blah blah blah 3 - - - - 2d Dino Dinosau New 29 | [ 16] [4/15] bar: blah blah blah 4 - - - - 2d Dino Dinosau New 30 | [ 17] [5/15] bar: blah blah blah 5 - - - - 2d Dino Dinosau New 31 | [ 18] [6/15] bar: blah blah blah 6 - - - - 2d Dino Dinosau New 32 | [ 19] [7/15] bar: blah blah blah 7 - - - - 2d Dino Dinosau New 33 | [ 20] [8/15] bar: blah blah blah 8 - - - - 2d Dino Dinosau New 34 | [ 21] [9/15] bar: blah blah blah 9 - - - - 2d Dino Dinosau New 35 | [ 22] [10/15] bar: blah blah blah 10 - - - - 2d Dino Dinosau New 36 | [ 23] [11/15] bar: blah blah blah 11 - - - - 2d Dino Dinosau New 37 | [ 24] [12/15] bar: blah blah blah 12 - - - - 2d Dino Dinosau New 38 | [ 25] [13/15] bar: blah blah blah 13 - - - - 2d Dino Dinosau New 39 | [ 26] [14/15] bar: blah blah blah 14 - - - - 2d Dino Dinosau New 40 | [ 27] [15/15] bar: blah blah blah 15 - - - - 2d Dino Dinosau New 41 | [ 28] [1/4] koo: yyy bbb cc 1 - - - - 2d Dino Dinosau Deferred 42 | [ 29] [2/4] koo: yyy bbb cc 2 - - - - 2d Dino Dinosau Deferred 43 | [ 30] [3/4] koo: yyy bbb cc 3 - - - - 2d Dino Dinosau Deferred 44 | [ 31] [4/4] koo: yyy bbb cc 4 - - - - 2d Dino Dinosau Deferred 45 | [ 32] foo: patch with a really long a name and id so I just need to keep.... - - - - 11h Lasse Really New 46 | master@data > edit 32 47 | edit 32 48 | master@data > show 32 49 | show 32 50 | Delegate: test 51 | State: New 52 | From: Lasse Really Surpringly Long And Complicated Name 53 | Date: 2011-02-20 13:13:13 54 | Patchwork-Id: 123456789 55 | Patchwork-URL: http://localhost/fixme/12345 56 | PendingCommit: None 57 | FinalCommit: None 58 | CommitRef: 59 | PatchIndex: None 60 | StgIndex: None 61 | ============================================================ 62 | foo: patch with a really long a name and id so I just need to keep typing and come up with something clever, I'm just not good with that 63 | 64 | Foo commit log. Ignore this text 65 | 66 | Signed-off-by: Dino Dinosaurus 67 | --- 68 | 0 files changed 69 | ============================================================ 70 | master@data > quit 71 | -------------------------------------------------------------------------------- /cmdtests/cmd-info.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_info(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('info') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('quit') 41 | 42 | if __name__ == "__main__": 43 | cmdtestlib.StubContext.run_test(test_info) 44 | -------------------------------------------------------------------------------- /cmdtests/cmd-info.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > info 13 | info 14 | User : test 15 | Project : stub-test 16 | Tree : data 17 | Branch : master 18 | New : 19 19 | Review : 7 20 | Upstream : 0 21 | Deferred : 6 22 | Total : 32 23 | master@data > quit 24 | -------------------------------------------------------------------------------- /cmdtests/cmd-list.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_list(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('list review') 41 | pwcli.expect_prompt() 42 | pwcli.sendline('list new') 43 | pwcli.expect_prompt() 44 | pwcli.sendline('list deferred') 45 | pwcli.expect_prompt() 46 | 47 | # --state switch 48 | pwcli.sendline('list --state deferred') 49 | pwcli.expect_prompt() 50 | 51 | # --title switch 52 | pwcli.sendline('list --title foo:.*2') 53 | pwcli.expect_prompt() 54 | 55 | # --from switch 56 | pwcli.sendline('list --from timo new') 57 | pwcli.expect_prompt() 58 | 59 | # show only patches which 'blah' in title 60 | pwcli.sendline('list blah') 61 | pwcli.expect_prompt() 62 | 63 | # from 'D.no and in review state 64 | pwcli.sendline('list -f D.no review') 65 | pwcli.expect_prompt() 66 | 67 | # from 'D.no and in review state, but with -s switch 68 | pwcli.sendline('list -f D.no -s review') 69 | pwcli.expect_prompt() 70 | 71 | # from timo, in review state and with "6" in title 72 | pwcli.sendline('list --from Timo --state review --title 6') 73 | pwcli.expect_prompt() 74 | 75 | # from timo, in review state and with "6" in title but with general filter 76 | pwcli.sendline('list --from Timo --title 6 review') 77 | pwcli.expect_prompt() 78 | 79 | pwcli.sendline('quit') 80 | 81 | if __name__ == "__main__": 82 | cmdtestlib.StubContext.run_test(test_list) 83 | -------------------------------------------------------------------------------- /cmdtests/cmd-reply-resend.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_reply(ctxt, pwcli): 37 | print('* make sure that the list is also CCed') 38 | pwcli.expect_prompt() 39 | pwcli.sendline('list new') 40 | pwcli.expect_prompt() 41 | pwcli.sendline('reply 1') 42 | 43 | # stop the smtpd stub so that the mail fails to send 44 | ctxt.smtpd.stop() 45 | 46 | # try to send the message 47 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 48 | pwcli.sendline('s') 49 | 50 | ctxt.smtpd.start() 51 | 52 | # retry the message 53 | pwcli.expect(cmdtestlib.PROMPT_REPLY_RETRY) 54 | pwcli.sendline('r') 55 | 56 | pwcli.expect_prompt() 57 | pwcli.sendline('quit') 58 | 59 | # to avoid any races print the mails only after pwcli has stopped 60 | print(ctxt.smtpd.get_mails_as_string()) 61 | 62 | if __name__ == "__main__": 63 | cmdtestlib.StubContext.run_test(test_reply) 64 | -------------------------------------------------------------------------------- /cmdtests/cmd-reply-resend.stdout: -------------------------------------------------------------------------------- 1 | * make sure that the list is also CCed 2 | Connecting to http://localhost:8105/ 3 | Downloading patches from the server 4 | User : test 5 | Project : stub-test 6 | Tree : data 7 | Branch : master 8 | New : 19 9 | Review : 7 10 | Upstream : 0 11 | Deferred : 6 12 | Total : 32 13 | master@data > list new 14 | list new 15 | [ 1] foo: new patch - - - - 3d Timo Tiger New 16 | [ 2] foo: minor change with CC - - - - 2d Timo Tiger New 17 | [ 3] foo: another minor change with multiple To - - - - 2d Timo Tiger New 18 | [ 4] [1/15] bar: blah blah blah 1 - - - - 2d Dino Dinosau New 19 | [ 5] [2/15] bar: blah blah blah 2 - - - - 2d Dino Dinosau New 20 | [ 6] [3/15] bar: blah blah blah 3 - - - - 2d Dino Dinosau New 21 | [ 7] [4/15] bar: blah blah blah 4 - - - - 2d Dino Dinosau New 22 | [ 8] [5/15] bar: blah blah blah 5 - - - - 2d Dino Dinosau New 23 | [ 9] [6/15] bar: blah blah blah 6 - - - - 2d Dino Dinosau New 24 | [ 10] [7/15] bar: blah blah blah 7 - - - - 2d Dino Dinosau New 25 | [ 11] [8/15] bar: blah blah blah 8 - - - - 2d Dino Dinosau New 26 | [ 12] [9/15] bar: blah blah blah 9 - - - - 2d Dino Dinosau New 27 | [ 13] [10/15] bar: blah blah blah 10 - - - - 2d Dino Dinosau New 28 | [ 14] [11/15] bar: blah blah blah 11 - - - - 2d Dino Dinosau New 29 | [ 15] [12/15] bar: blah blah blah 12 - - - - 2d Dino Dinosau New 30 | [ 16] [13/15] bar: blah blah blah 13 - - - - 2d Dino Dinosau New 31 | [ 17] [14/15] bar: blah blah blah 14 - - - - 2d Dino Dinosau New 32 | [ 18] [15/15] bar: blah blah blah 15 - - - - 2d Dino Dinosau New 33 | [ 19] foo: patch with a really long a name and id so I just need to keep.... - - - - 11h Lasse Really New 34 | master@data > reply 1 35 | reply 1 36 | ============================================================ 37 | Content-Type: text/plain; charset="utf-8" 38 | MIME-Version: 1.0 39 | Content-Transfer-Encoding: 7bit 40 | Subject: Re: foo: new patch 41 | From: Timo Testi 42 | In-Reply-To: <22222@example.com> 43 | References: <22222@example.com> 44 | To: Timo Tiger 45 | Cc: list@example.com 46 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) Python/ 47 | 48 | Timo Tiger wrote: 49 | 50 | > Foo commit log. Ignore this text 51 | > 52 | > Signed-off-by: Dino Dinosaurus 53 | 54 | -- 55 | Sent by pwcli 56 | http://localhost/fixme/12345 57 | 58 | 59 | ============================================================ 60 | Envelope From: Timo Testi 61 | Envelope To: ['Timo Tiger ', 'list@example.com'] 62 | Send/Edit/aBort? s 63 | s 64 | Failed to send email via localhost: [Errno 111] Connection refused 65 | Retry/aBort? r 66 | r 67 | master@data > quit 68 | mail 0: 69 | ---------------------------------------------------------------------- 70 | test@example.com -> timo@example.com, list@example.com 71 | Content-Type: text/plain; charset="utf-8" 72 | MIME-Version: 1.0 73 | Content-Transfer-Encoding: 7bit 74 | Subject: Re: foo: new patch 75 | From: Timo Testi 76 | In-Reply-To: <22222@example.com> 77 | References: <22222@example.com> 78 | To: Timo Tiger 79 | Cc: list@example.com 80 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) 81 | Python/ 82 | Message-ID: 1-2-3-hardcoded@example.com 83 | 84 | Timo Tiger wrote: 85 | 86 | > Foo commit log. Ignore this text 87 | > 88 | > Signed-off-by: Dino Dinosaurus 89 | 90 | -- 91 | Sent by pwcli 92 | http://localhost/fixme/12345 93 | ---------------------------------------------------------------------- 94 | 95 | -------------------------------------------------------------------------------- /cmdtests/cmd-reply.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | import os 36 | 37 | def send_mail(pwcli): 38 | # Edit 39 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 40 | pwcli.sendline('e') 41 | 42 | # Send 43 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 44 | pwcli.sendline('s') 45 | 46 | def test_reply(ctxt, pwcli): 47 | print('* make sure that the list is also CCed') 48 | pwcli.expect_prompt() 49 | pwcli.sendline('list new') 50 | pwcli.expect_prompt() 51 | pwcli.sendline('reply 1') 52 | send_mail(pwcli) 53 | 54 | print('* list and two persons CCed') 55 | pwcli.expect_prompt() 56 | pwcli.sendline('list new') 57 | pwcli.expect_prompt() 58 | pwcli.sendline('reply 2') 59 | send_mail(pwcli) 60 | 61 | print('* two lists CCed') 62 | pwcli.expect_prompt() 63 | pwcli.sendline('list new') 64 | pwcli.expect_prompt() 65 | pwcli.sendline('reply 3') 66 | send_mail(pwcli) 67 | 68 | pwcli.expect_prompt() 69 | pwcli.sendline('quit') 70 | 71 | # to avoid any races print the mails only after pwcli has stopped 72 | print(ctxt.smtpd.get_mails_as_string()) 73 | 74 | if __name__ == "__main__": 75 | cmdtestlib.StubContext.run_test(test_reply) 76 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-changes-requested-single.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_review(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | 40 | pwcli.expect_prompt() 41 | pwcli.sendline('review 1') 42 | 43 | # Changes Requested 44 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 45 | pwcli.sendline('c') 46 | 47 | # Reason 48 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 49 | pwcli.sendline('Needs more work.') 50 | 51 | # Send 52 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 53 | pwcli.sendline('s') 54 | 55 | pwcli.expect_prompt() 56 | pwcli.sendline('info') 57 | 58 | pwcli.expect_prompt() 59 | pwcli.sendline('quit') 60 | 61 | print(ctxt.smtpd.get_mails_as_string()) 62 | 63 | if __name__ == "__main__": 64 | cmdtestlib.StubContext.run_test(test_review) 65 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-changes-requested-single.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list review 13 | list review 14 | [ 1] [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 15 | [ 2] [2/7] foo: test 2 - - - - 3d Timo Tiger Under Review 16 | [ 3] [3/7] foo: test 3 - - - - 3d Timo Tiger Under Review 17 | [ 4] [4/7] foo: test 4 - - - - 3d Timo Tiger Under Review 18 | [ 5] [5/7] foo: test 5 - - - - 3d Timo Tiger Under Review 19 | [ 6] [6/7] foo: test 6 - - - - 3d Timo Tiger Under Review 20 | [ 7] [7/7] foo: test 7 - - - - 3d Timo Tiger Under Review 21 | master@data > review 1 22 | review 1 23 | Retrieving patches (1/1) 24 | [1/7] foo: test 1 - - - - 3d Dino Dinosau Under Review 25 | ------------------------------------------------------------ 26 | Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? c 27 | c 28 | Setting patch state (1/1) 29 | Patch set to Changes Requested 30 | Reason (RET for no mail): Needs more work. 31 | Needs more work. 32 | ============================================================ 33 | Content-Type: text/plain; charset="utf-8" 34 | MIME-Version: 1.0 35 | Content-Transfer-Encoding: 7bit 36 | Subject: Re: [1/7] foo: test 1 37 | From: Timo Testi 38 | In-Reply-To: <11111@example.com> 39 | References: <11111@example.com> 40 | To: Dino Dinosaurus 41 | Cc: list@example.com 42 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) Python/ 43 | 44 | Dino Dinosaurus wrote: 45 | 46 | > Foo commit log. Ignore this text 47 | > 48 | > Signed-off-by: Dino Dinosaurus 49 | 50 | Needs more work. 51 | 52 | Patch set to Changes Requested. 53 | 54 | -- 55 | Sent by pwcli 56 | http://localhost/fixme/12345 57 | 58 | 59 | ============================================================ 60 | Envelope From: Timo Testi 61 | Envelope To: ['Dino Dinosaurus ', 'list@example.com'] 62 | Send/Edit/aBort? s 63 | s 64 | master@data > info 65 | info 66 | User : test 67 | Project : stub-test 68 | Tree : data 69 | Branch : master 70 | New : 19 71 | Review : 6 72 | Upstream : 0 73 | Deferred : 6 74 | Total : 31 75 | master@data > quit 76 | mail 0: 77 | ---------------------------------------------------------------------- 78 | test@example.com -> dino@example.com, list@example.com 79 | Content-Type: text/plain; charset="utf-8" 80 | MIME-Version: 1.0 81 | Content-Transfer-Encoding: 7bit 82 | Subject: Re: [1/7] foo: test 1 83 | From: Timo Testi 84 | In-Reply-To: <11111@example.com> 85 | References: <11111@example.com> 86 | To: Dino Dinosaurus 87 | Cc: list@example.com 88 | User-Agent: pwcli/ (https://github.com/kvalo/pwcli/) 89 | Python/ 90 | Message-ID: 1-2-3-hardcoded@example.com 91 | 92 | Dino Dinosaurus wrote: 93 | 94 | > Foo commit log. Ignore this text 95 | > 96 | > Signed-off-by: Dino Dinosaurus 97 | 98 | Needs more work. 99 | 100 | Patch set to Changes Requested. 101 | 102 | -- 103 | Sent by pwcli 104 | http://localhost/fixme/12345 105 | ---------------------------------------------------------------------- 106 | 107 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-reject-multiple.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_review(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list review') 39 | 40 | pwcli.expect_prompt() 41 | pwcli.sendline('review 1-2') 42 | 43 | # Rejected 44 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 45 | pwcli.sendline('r') 46 | 47 | # Reason 48 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 49 | pwcli.sendline('I will never take these.') 50 | 51 | # Send 52 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 53 | pwcli.sendline('s') 54 | 55 | pwcli.expect_prompt() 56 | pwcli.sendline('info') 57 | 58 | pwcli.expect_prompt() 59 | pwcli.sendline('list -s new') 60 | 61 | # review all patches, including 'foo: patch with a really long a 62 | # name and id...' to test how the mails with a really long id and 63 | # name look like 64 | pwcli.expect_prompt() 65 | pwcli.sendline('review 1-19') 66 | 67 | # Changes requested 68 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 69 | pwcli.sendline('c') 70 | 71 | # Reason 72 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 73 | pwcli.sendline('Please fix your name.') 74 | 75 | # Send 76 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 77 | pwcli.sendline('s') 78 | 79 | pwcli.expect_prompt() 80 | pwcli.sendline('info') 81 | 82 | pwcli.expect_prompt() 83 | pwcli.sendline('quit') 84 | 85 | print(ctxt.smtpd.get_mails_as_string()) 86 | 87 | if __name__ == "__main__": 88 | cmdtestlib.StubContext.run_test(test_review) 89 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-stg-build-failure-accept.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_review(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list new') 39 | 40 | ctxt.builder.set_return_value(1) 41 | 42 | pwcli.expect_prompt() 43 | pwcli.sendline('review 1') 44 | 45 | # Apply 46 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_ACCEPT) 47 | pwcli.sendline('a') 48 | 49 | # set patch to Under Review 50 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 51 | pwcli.sendline('u') 52 | 53 | # Yes, we are sure 54 | pwcli.expect_exact(cmdtestlib.PROMPT_UNDER_REVIEW_CONFIRM) 55 | pwcli.sendline('y') 56 | 57 | pwcli.expect_prompt() 58 | pwcli.sendline('quit') 59 | 60 | print(ctxt.smtpd.get_mails_as_string()) 61 | 62 | if __name__ == "__main__": 63 | cmdtestlib.StubContext.run_test(test_review, stgit=True, builder='builder') 64 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-stg-conflict.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_stg(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list new') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('review 1') 41 | 42 | # the next stg import must fail 43 | ctxt.stgit.set_import_failure(1) 44 | 45 | # Apply 46 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_ACCEPT) 47 | pwcli.sendline('a') 48 | 49 | # Changes requested 50 | #pwcli.expect_exact('Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort?') 51 | pwcli.expect_exact('Changes') 52 | pwcli.sendline('c') 53 | 54 | # # Changes requested 55 | # pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 56 | # pwcli.sendline('c') 57 | 58 | # # reason 59 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 60 | pwcli.sendline('Failed to import') 61 | 62 | # send mail 63 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 64 | pwcli.sendline('s') 65 | 66 | pwcli.expect_prompt() 67 | pwcli.sendline('quit') 68 | 69 | if __name__ == "__main__": 70 | cmdtestlib.StubContext.run_test(test_stg, stgit=True) 71 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-stg-multiple-abort.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_stg(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | 39 | pwcli.sendline('list new') 40 | pwcli.expect_prompt() 41 | 42 | pwcli.sendline('review 1-5') 43 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_ACCEPT) 44 | 45 | # Apply 46 | pwcli.sendline('a') 47 | pwcli.expect('/rFc/aBort\? ') 48 | 49 | # Abort 50 | pwcli.sendline('b') 51 | pwcli.expect_prompt() 52 | 53 | # all the patches should be deleted and the pending branch should 54 | # be empty 55 | pwcli.sendline('stg list') 56 | pwcli.expect_prompt() 57 | 58 | pwcli.sendline('quit') 59 | 60 | if __name__ == "__main__": 61 | cmdtestlib.StubContext.run_test(test_stg, stgit=True, builder='builder') 62 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-stg-multiple-fail.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_stg(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list new') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('review 1-5') 41 | 42 | # import of patch 3 must fail 43 | ctxt.stgit.set_import_failure(3) 44 | 45 | # Apply 46 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_ACCEPT) 47 | pwcli.sendline('a') 48 | 49 | # Changes Requested 50 | pwcli.expect('/rFc/aBort\? ') 51 | pwcli.sendline('c') 52 | 53 | # reason 54 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_REASON) 55 | pwcli.sendline('Patch 3 did not apply:') 56 | 57 | # send mail 58 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 59 | pwcli.sendline('s') 60 | 61 | # patches 1 and 2 should be deleted and the pending branch should 62 | # be empty 63 | pwcli.expect_prompt() 64 | pwcli.sendline('list pending') 65 | 66 | pwcli.expect_prompt() 67 | pwcli.sendline('quit') 68 | 69 | print(ctxt.smtpd.get_mails_as_string()) 70 | 71 | if __name__ == "__main__": 72 | cmdtestlib.StubContext.run_test(test_stg, stgit=True) 73 | -------------------------------------------------------------------------------- /cmdtests/cmd-review-stg-single.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_stg(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list new') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('review 1') 41 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_ACCEPT) 42 | pwcli.sendline('a') 43 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 44 | pwcli.sendline('u') 45 | 46 | pwcli.expect_prompt() 47 | pwcli.sendline('list pending') 48 | 49 | pwcli.expect_prompt() 50 | pwcli.sendline('commit 1') 51 | 52 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 53 | pwcli.sendline('a') 54 | 55 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 56 | pwcli.sendline('a') 57 | 58 | pwcli.expect_prompt() 59 | pwcli.sendline('quit') 60 | 61 | print(ctxt.smtpd.get_mails_as_string()) 62 | 63 | if __name__ == "__main__": 64 | cmdtestlib.StubContext.run_test(test_stg, stgit=True) 65 | -------------------------------------------------------------------------------- /cmdtests/cmd-review.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_review(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list new') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('review 1') 41 | 42 | # abort 43 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 44 | pwcli.sendline('b') 45 | 46 | pwcli.expect_prompt() 47 | pwcli.sendline('review 1') 48 | 49 | # Under review 50 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 51 | pwcli.sendline('u') 52 | 53 | pwcli.expect_prompt() 54 | pwcli.sendline('info') 55 | 56 | pwcli.expect_prompt() 57 | pwcli.sendline('quit') 58 | 59 | if __name__ == "__main__": 60 | cmdtestlib.StubContext.run_test(test_review) 61 | -------------------------------------------------------------------------------- /cmdtests/cmd-review.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Branch : master 7 | New : 19 8 | Review : 7 9 | Upstream : 0 10 | Deferred : 6 11 | Total : 32 12 | master@data > list new 13 | list new 14 | [ 1] foo: new patch - - - - 3d Timo Tiger New 15 | [ 2] foo: minor change with CC - - - - 2d Timo Tiger New 16 | [ 3] foo: another minor change with multiple To - - - - 2d Timo Tiger New 17 | [ 4] [1/15] bar: blah blah blah 1 - - - - 2d Dino Dinosau New 18 | [ 5] [2/15] bar: blah blah blah 2 - - - - 2d Dino Dinosau New 19 | [ 6] [3/15] bar: blah blah blah 3 - - - - 2d Dino Dinosau New 20 | [ 7] [4/15] bar: blah blah blah 4 - - - - 2d Dino Dinosau New 21 | [ 8] [5/15] bar: blah blah blah 5 - - - - 2d Dino Dinosau New 22 | [ 9] [6/15] bar: blah blah blah 6 - - - - 2d Dino Dinosau New 23 | [ 10] [7/15] bar: blah blah blah 7 - - - - 2d Dino Dinosau New 24 | [ 11] [8/15] bar: blah blah blah 8 - - - - 2d Dino Dinosau New 25 | [ 12] [9/15] bar: blah blah blah 9 - - - - 2d Dino Dinosau New 26 | [ 13] [10/15] bar: blah blah blah 10 - - - - 2d Dino Dinosau New 27 | [ 14] [11/15] bar: blah blah blah 11 - - - - 2d Dino Dinosau New 28 | [ 15] [12/15] bar: blah blah blah 12 - - - - 2d Dino Dinosau New 29 | [ 16] [13/15] bar: blah blah blah 13 - - - - 2d Dino Dinosau New 30 | [ 17] [14/15] bar: blah blah blah 14 - - - - 2d Dino Dinosau New 31 | [ 18] [15/15] bar: blah blah blah 15 - - - - 2d Dino Dinosau New 32 | [ 19] foo: patch with a really long a name and id so I just need to keep.... - - - - 11h Lasse Really New 33 | master@data > review 1 34 | review 1 35 | Retrieving patches (1/1) 36 | foo: new patch - - - - 3d Timo Tiger New 37 | ------------------------------------------------------------ 38 | Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? b 39 | b 40 | Aborted. 41 | master@data > review 1 42 | review 1 43 | Retrieving patches (1/1) 44 | foo: new patch - - - - 3d Timo Tiger New 45 | ------------------------------------------------------------ 46 | Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? u 47 | u 48 | Setting patch state (1/1) 49 | Patch set to Under Review 50 | master@data > info 51 | info 52 | User : test 53 | Project : stub-test 54 | Tree : data 55 | Branch : master 56 | New : 18 57 | Review : 8 58 | Upstream : 0 59 | Deferred : 6 60 | Total : 32 61 | master@data > quit 62 | -------------------------------------------------------------------------------- /cmdtests/cmd-show-stg.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_stg(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | pwcli.sendline('list new') 39 | pwcli.expect_prompt() 40 | pwcli.sendline('review 1') 41 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_ACCEPT) 42 | pwcli.sendline('a') 43 | pwcli.expect(cmdtestlib.PROMPT_REVIEW_STATE) 44 | pwcli.sendline('u') 45 | 46 | pwcli.expect_prompt() 47 | pwcli.sendline('list pending') 48 | 49 | pwcli.expect_prompt() 50 | pwcli.sendline('show 1') 51 | 52 | pwcli.expect_prompt() 53 | pwcli.sendline('quit') 54 | 55 | print(ctxt.smtpd.get_mails_as_string()) 56 | 57 | if __name__ == "__main__": 58 | cmdtestlib.StubContext.run_test(test_stg, stgit=True) 59 | -------------------------------------------------------------------------------- /cmdtests/cmd-show-stg.stdout: -------------------------------------------------------------------------------- 1 | Connecting to http://localhost:8105/ 2 | Downloading patches from the server 3 | User : test 4 | Project : stub-test 5 | Tree : data 6 | Main branches : master 7 | Pending branch: pending 8 | New : 19 9 | Review : 0 10 | Upstream : 0 11 | Deferred : 6 12 | Total : 25 13 | master@data > list new 14 | list new 15 | [ 1] foo: new patch - - - - 3d Timo Tiger New 16 | [ 2] foo: minor change with CC - - - - 2d Timo Tiger New 17 | [ 3] foo: another minor change with multiple To - - - - 2d Timo Tiger New 18 | [ 4] [1/15] bar: blah blah blah 1 - - - - 2d Dino Dinosau New 19 | [ 5] [2/15] bar: blah blah blah 2 - - - - 2d Dino Dinosau New 20 | [ 6] [3/15] bar: blah blah blah 3 - - - - 2d Dino Dinosau New 21 | [ 7] [4/15] bar: blah blah blah 4 - - - - 2d Dino Dinosau New 22 | [ 8] [5/15] bar: blah blah blah 5 - - - - 2d Dino Dinosau New 23 | [ 9] [6/15] bar: blah blah blah 6 - - - - 2d Dino Dinosau New 24 | [ 10] [7/15] bar: blah blah blah 7 - - - - 2d Dino Dinosau New 25 | [ 11] [8/15] bar: blah blah blah 8 - - - - 2d Dino Dinosau New 26 | [ 12] [9/15] bar: blah blah blah 9 - - - - 2d Dino Dinosau New 27 | [ 13] [10/15] bar: blah blah blah 10 - - - - 2d Dino Dinosau New 28 | [ 14] [11/15] bar: blah blah blah 11 - - - - 2d Dino Dinosau New 29 | [ 15] [12/15] bar: blah blah blah 12 - - - - 2d Dino Dinosau New 30 | [ 16] [13/15] bar: blah blah blah 13 - - - - 2d Dino Dinosau New 31 | [ 17] [14/15] bar: blah blah blah 14 - - - - 2d Dino Dinosau New 32 | [ 18] [15/15] bar: blah blah blah 15 - - - - 2d Dino Dinosau New 33 | [ 19] foo: patch with a really long a name and id so I just need to keep.... - - - - 11h Lasse Really New 34 | master@data > review 1 35 | review 1 36 | Retrieving patches (1/1) 37 | foo: new patch - - - - 3d Timo Tiger New 38 | ------------------------------------------------------------ 39 | Apply 1 patches to the pending branch? [Apply/Skip/aBort] a 40 | a 41 | Importing patches (1/1) 42 | Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? u 43 | u 44 | Setting patch state (1/1) 45 | Patch set to Under Review 46 | master@data > list pending 47 | list pending 48 | *[ 1] foo: new patch - - - - 3d Timo Tiger Under Review 49 | master@data > show 1 50 | show 1 51 | Delegate: test 52 | State: Under Review 53 | From: Timo Tiger 54 | Date: 2011-02-11 18:40:01 55 | Patchwork-Id: 1030 56 | Patchwork-URL: http://localhost/fixme/12345 57 | PendingCommit: 2a279250478669e4865a77ffc7d16ad4920c1e2d 58 | FinalCommit: None 59 | CommitRef: None 60 | PatchIndex: None 61 | StgIndex: 0 62 | ============================================================ 63 | foo: new patch 64 | 65 | Foo commit log. Ignore this text 66 | 67 | Signed-off-by: Dino Dinosaurus 68 | --- 69 | FIXME: add the patch here 70 | --- 71 | 0 files changed 72 | ============================================================ 73 | master@data > quit 74 | 75 | -------------------------------------------------------------------------------- /cmdtests/cmd-show.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2017, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | 36 | def test_info(ctxt, pwcli): 37 | pwcli.expect_prompt() 38 | 39 | pwcli.sendline('list') 40 | pwcli.expect_prompt() 41 | 42 | pwcli.sendline('show 1-10') 43 | pwcli.expect_prompt() 44 | 45 | pwcli.sendline('show 9') 46 | pwcli.expect_prompt() 47 | 48 | pwcli.sendline('show #1020') 49 | pwcli.expect_prompt() 50 | 51 | pwcli.sendline('show #1030,#1031,#1032') 52 | pwcli.expect_prompt() 53 | 54 | # this id doesn't exist 55 | pwcli.sendline('show #777777') 56 | pwcli.expect_prompt() 57 | 58 | pwcli.sendline('show #1030,#1031,#1032,#777777') 59 | pwcli.expect_prompt() 60 | 61 | # invalid id 62 | pwcli.sendline('show #foobar') 63 | pwcli.expect_prompt() 64 | 65 | pwcli.sendline('show #1030,#foobar') 66 | pwcli.expect_prompt() 67 | 68 | # this is not supported 69 | pwcli.sendline('show #1030-#1032') 70 | pwcli.expect_prompt() 71 | 72 | pwcli.sendline('quit') 73 | 74 | if __name__ == "__main__": 75 | cmdtestlib.StubContext.run_test(test_info) 76 | -------------------------------------------------------------------------------- /cmdtests/utf-8.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2020, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import cmdtestlib 35 | import mailbox 36 | 37 | def test_utf8(ctxt, pwcli): 38 | pwcli.expect_prompt() 39 | 40 | pwcli.sendline('list -f Examplè') 41 | pwcli.expect_prompt() 42 | 43 | pwcli.sendline('reply 1') 44 | 45 | # Edit mail 46 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 47 | pwcli.sendline('e') 48 | 49 | # Send mail 50 | pwcli.expect(cmdtestlib.PROMPT_REPLY) 51 | pwcli.sendline('s') 52 | 53 | # download 'foo: utf-8 test' patch 54 | pwcli.expect_prompt() 55 | pwcli.sendline('download 1') 56 | pwcli.expect_prompt() 57 | 58 | # commit 'foo: utf-8 test' patch 59 | # 60 | # FIXME: the "applied message" uses MIME encoded words still, most 61 | # likely a problem with stubs 62 | pwcli.sendline('commit 1') 63 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ALL) 64 | 65 | pwcli.sendline('a') 66 | pwcli.expect(cmdtestlib.PROMPT_COMMIT_ACCEPT) 67 | 68 | pwcli.sendline('a') 69 | pwcli.expect_prompt() 70 | 71 | pwcli.sendline('quit') 72 | 73 | # open utf-8 file using mailbox 74 | path = '1021.mbox' 75 | mbox = mailbox.mbox(path) 76 | print('%d messages found from %s:' % (len(mbox), path)) 77 | for msg in mbox: 78 | print('%s: %s' % (cmdtestlib.decode_mime_encoded_words(msg['From']), 79 | cmdtestlib.decode_mime_encoded_words(msg['Subject']))) 80 | 81 | # print file the directly 82 | f = open(path, 'r') 83 | print('----------------------------------------------------------------------') 84 | print('\n'.join(f.read().splitlines()[1:])) 85 | print('----------------------------------------------------------------------') 86 | f.close() 87 | 88 | print(ctxt.smtpd.get_mails_as_string()) 89 | 90 | if __name__ == "__main__": 91 | cmdtestlib.StubContext.run_test(test_utf8) 92 | -------------------------------------------------------------------------------- /pwcli.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Example configuration file for pwcli. 3 | # 4 | # Copy this to .git/pwcli/config and edit to match your settings 5 | # 6 | 7 | [general] 8 | 9 | # Patchwork server's main URL. 10 | # 11 | server-url = https://patchwork.example.com/ 12 | 13 | # Name of the patchwork project. 14 | # 15 | project = linux-wireless 16 | 17 | # (Optional) Patchwork username. If not set, patches are not filtered 18 | # based on user name and instead all patches from the project are 19 | # shown. 20 | # 21 | #username = edward 22 | 23 | # (Optional) Patchwork token which can be retrieved from your 24 | # patchwork profile page, e.g. https://patchwork.example.com/user. 25 | # Needed when changing patches in the server. No need to set this when 26 | # just downloading patches from the server. 27 | # 28 | # Requires username also to be set. 29 | # 30 | #token = abcd123456789890 31 | 32 | # (Optional) Command to open patch URL's from patchwork. 33 | # 34 | #browser = xdg-open 35 | 36 | # (Optional) The command used to build the software after a patch is 37 | # applied. If not set build testing is skipped. 38 | # 39 | #build-command = make -j 8 40 | 41 | # (Optional) Send automatic emails ("thank you" or the reason comment 42 | # when rejecting) after commiting or reviewing a patch to all address 43 | # in TO and Cc fields. The reply command will send an email even if 44 | # this setting is disabled. 45 | # 46 | # Valid options: false (default), true 47 | # 48 | #automatic-emails = true 49 | 50 | # (Optional) When commiting a patch add a tag to the end of commit log 51 | # with email's Message-id. This is to link the patch to the actual 52 | # email containing the patch. Example: 53 | # 54 | # Link: https://lore.kernel.org/r/1587495512-29813-1-git-send-email-mkenna@codeaurora.org 55 | # 56 | # Valid options: string with %s marking the location of actual msgid 57 | # 58 | #msgid-tag = Link: https://lore.kernel.org/r/%s 59 | 60 | # (Optional) Enable pending mode which means that the review command 61 | # applies the patch to a pending branch for more testing and editing. 62 | # This makes it possible for easy to test and improve patches before 63 | # they are applied. The commit command then cherry picks the patch 64 | # from pending branch (instead of downloading the original from 65 | # patchwork as is done normally). 66 | # 67 | # Requires pending-branch and main-branches to be set. 68 | # 69 | # Valid options: disabled (default), stgit 70 | # 71 | #pending-mode = stgit 72 | 73 | # (Optional) The name of the pending branch review command applies 74 | # patches to. 75 | # 76 | #pending-branch = pending 77 | 78 | # (Optional) The name of the git branch(es) where the patch is 79 | # commited when commit command is issued. Multiple branches are 80 | # separated with a command and chosen with the branch command in pwcli 81 | # shell. This way bugfixes (-current) and new features (-next) can 82 | # have separate branches even when using pending-branch mode. 83 | # 84 | #main-branches = ath-next ath-current 85 | 86 | # (Optional) Log level to use with the .git/pwcli/log file. 87 | # 88 | # Valid options: info (default), debug 89 | # 90 | #log-level = debug 91 | 92 | # (Optional) Maximum width of the terminal. If the terminal is very wide 93 | # it reduce readibility of the list command output, this makes it 94 | # possible to limit the width (columns size). 95 | # 96 | # Valid options: integer > 0 97 | # 98 | #max-terminal-width = 50 99 | 100 | # (Optional) Download all active series information, cover letters and 101 | # comments to both cover letters during startup. pwcli uses this data 102 | # for example providing statistics (Acked-by, comments etc) in list 103 | # command. If this is disabled pwcli acts as there are no cover 104 | # letters nor any comments, ie. everything is just zero. This at least 105 | # doubles pwcli startup time, with 300 patches it can take even over a 106 | # minute to download all comments. 107 | # 108 | # Valid options: false (default), true 109 | # 110 | #download-series = false 111 | 112 | # (Optional) Maximum number of parallel REST requests to the patchwork 113 | # server. Increasing the thread pool will decrease the time to 114 | # download comments. No effect if download-series is false. 115 | # 116 | # Valid options: integer > 0, default 8 117 | # 118 | #download-threads = 8 119 | -------------------------------------------------------------------------------- /run_stub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import os 35 | import os.path 36 | import sys 37 | import tempfile 38 | import shutil 39 | import argparse 40 | import logging 41 | 42 | # logging 43 | logging.basicConfig() 44 | logger = logging.getLogger('run_stub') 45 | 46 | # uncomment to get debug logs 47 | # logger.setLevel(logging.DEBUG) 48 | 49 | # these below must be initialised before importing stubs module 50 | srcdir = os.getcwd() 51 | os.environ['SRCDIR'] = srcdir 52 | 53 | datadir = tempfile.mkdtemp(prefix='pwcli-stub-') 54 | os.environ['DATADIR'] = datadir 55 | 56 | stubsdir = os.path.join(srcdir, 'stubs') 57 | sys.path.insert(0, stubsdir) 58 | 59 | import stubs # noqa: E402 60 | 61 | logger.debug('srcdir=%r' % (srcdir)) 62 | logger.debug('datadir=%r' % (datadir)) 63 | logger.debug('stubsdir=%r' % (stubsdir)) 64 | 65 | # separate port numbers for run_stub so that it can be run 66 | # concurrently with tests 67 | PATCHWORK_PORT = 8106 68 | SMTP_PORT = 5871 69 | 70 | 71 | def main(): 72 | parser = argparse.ArgumentParser(description='run_stub') 73 | 74 | parser.add_argument('--keep', action='store_true', 75 | help='Keep the temporary datadir for debugging') 76 | parser.add_argument('--stgit', action='store_true', 77 | help='Enable stgit mode') 78 | 79 | args = parser.parse_args() 80 | 81 | print('Using datadir: %s' % (datadir)) 82 | 83 | git = stubs.GitStub(smtpport=SMTP_PORT) 84 | git.start() 85 | 86 | if args.stgit: 87 | stg = stubs.StgStub() 88 | stg.start() 89 | 90 | patchwork = stubs.PatchworkStub(port=PATCHWORK_PORT) 91 | patchwork.start() 92 | 93 | smtpd = stubs.SmtpdStub(port=5871) 94 | smtpd.start() 95 | 96 | os.chdir(datadir) 97 | 98 | pwcli = stubs.PwcliWrapper(stgit=args.stgit, 99 | patchworkport=PATCHWORK_PORT, 100 | smtpport=SMTP_PORT, 101 | censor=False, 102 | builder='builder') 103 | pwcli.write_config() 104 | pwcli.start() 105 | pwcli.wait() 106 | 107 | patchwork.stop() 108 | smtpd.stop() 109 | 110 | if args.stgit: 111 | stg.stop() 112 | 113 | git.stop() 114 | 115 | if not args.keep: 116 | shutil.rmtree(datadir) 117 | else: 118 | print('Keeping temporary datadir: %s' % (datadir)) 119 | 120 | 121 | if __name__ == "__main__": 122 | main() 123 | -------------------------------------------------------------------------------- /stubs/builder: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import argparse 35 | import sys 36 | import stubs 37 | import os 38 | 39 | 40 | def main(): 41 | # for the help and possible future additions 42 | parser = argparse.ArgumentParser(description='builder stub mimicking a compiler') 43 | args = parser.parse_args() 44 | assert args # to shut up pyflakes 45 | 46 | builder = stubs.BuilderStub() 47 | 48 | # hack to enable automatic flushing so that printouts are not 49 | # out of order 50 | # https://stackoverflow.com/questions/27067713/why-text-i-o-must-be-buffered-in-python-3 51 | sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering=1) 52 | 53 | # print really long line several times 54 | s = '' 55 | for i in range(20): 56 | s += '1234567890' 57 | 58 | for i in range(5): 59 | sys.stdout.write(s + '\n') 60 | 61 | filenames = ['foo.c', 'bar.c', 'aaa.c', 'bbb.c'] 62 | for filename in filenames: 63 | sys.stdout.write(' CC %s\n' % (filename)) 64 | sys.stdout.flush() 65 | 66 | count = builder.get_warning_count() 67 | for i in range(min(count, len(filenames))): 68 | sys.stderr.write('%s: warning: is suspicious\n' % (filenames[i])) 69 | sys.stdout.flush() 70 | 71 | sys.exit(builder.get_return_value()) 72 | 73 | 74 | if __name__ == "__main__": 75 | main() 76 | -------------------------------------------------------------------------------- /stubs/cmdtests/builder.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import os 35 | import os.path 36 | import subprocess 37 | import stubs 38 | import sys 39 | 40 | srcdir = os.environ['SRCDIR'] 41 | datadir = os.environ['DATADIR'] 42 | 43 | def log(msg): 44 | msg = '* %s\n' % (msg) 45 | print(msg, end='', flush=True) 46 | print(msg, file=sys.stderr, end='', flush=True) 47 | 48 | def main(): 49 | os.chdir(datadir) 50 | 51 | builder = stubs.BuilderStub() 52 | assert builder # pyflakes 53 | 54 | subprocess.call('builder') 55 | 56 | log('print two warnings') 57 | builder.set_warning_count(2) 58 | subprocess.call('builder') 59 | 60 | log('set warning count one above the limit') 61 | return_value = 99 62 | builder.set_warning_count(5) 63 | builder.set_return_value(return_value) 64 | returncode = subprocess.call('builder') 65 | print('returncode = %d' % (returncode)) 66 | 67 | builder.cleanup() 68 | 69 | if __name__ == "__main__": 70 | main() 71 | -------------------------------------------------------------------------------- /stubs/cmdtests/builder.stderr: -------------------------------------------------------------------------------- 1 | * print two warnings 2 | foo.c: warning: is suspicious 3 | bar.c: warning: is suspicious 4 | * set warning count one above the limit 5 | foo.c: warning: is suspicious 6 | bar.c: warning: is suspicious 7 | aaa.c: warning: is suspicious 8 | bbb.c: warning: is suspicious 9 | -------------------------------------------------------------------------------- /stubs/cmdtests/builder.stdout: -------------------------------------------------------------------------------- 1 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 2 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 3 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 4 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 5 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 6 | CC foo.c 7 | CC bar.c 8 | CC aaa.c 9 | CC bbb.c 10 | * print two warnings 11 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 13 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 14 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 15 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 16 | CC foo.c 17 | CC bar.c 18 | CC aaa.c 19 | CC bbb.c 20 | * set warning count one above the limit 21 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 22 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 23 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 24 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 25 | 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 26 | CC foo.c 27 | CC bar.c 28 | CC aaa.c 29 | CC bbb.c 30 | returncode = 99 31 | -------------------------------------------------------------------------------- /stubs/cmdtests/git.stdout: -------------------------------------------------------------------------------- 1 | check branch 2 | * master 3 | 4 | check configs 5 | test@example.com 6 | Timo Testi 7 | localhost 8 | 5870 9 | 10 | check return value from a config field which does not exist 11 | existance not found 12 | 13 | add patches 14 | test git log 15 | bbd3154f2111 foo: test 2 16 | 750f7254ae57 foo: new patch 17 | 18 | test git show HEAD 19 | commit 750f7254ae57223354ec431fe9978430745ab359 20 | 21 | test git show --format 22 | commit 750f7254ae57223354ec431fe9978430745ab359 23 | foo: new patch 24 | 25 | TODO: add printing of commit log here, the parsin is just missing 26 | 27 | test git cherry-pick 28 | Commit id fb409caeb2ecda7176f3d6af845e87b1c60f6665 not found. 29 | bbd3154f2111 foo: test 2 30 | 750f7254ae57 foo: new patch 31 | 32 | test git commit 33 | 34 | test git am conflict 35 | Applying: foo: conflict patch 36 | Using index info to reconstruct a base tree... 37 | Falling back to patching base and 3-way merge... 38 | Auto-merging foo/bar.c 39 | CONFLICT (content): Merge conflict in drivers/net/wireless/ath/foo/core.h 40 | Failed to merge in the changes. 41 | Patch failed at 0001 foo: conflict patch 42 | When you have resolved this problem run "git am --resolved". 43 | If you would prefer to skip this patch, instead run "git am --skip". 44 | To restore the original branch and stop patching run "git am --abort". 45 | 46 | test git reset 47 | commit bbd3154f2111572248f813c70dc030fc3749811f 48 | 49 | -------------------------------------------------------------------------------- /stubs/cmdtests/patchwork-load-patches.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import os 35 | import os.path 36 | import subprocess 37 | import shutil 38 | 39 | def main(): 40 | srcdir = os.environ['SRCDIR'] 41 | datadir = os.environ['DATADIR'] 42 | stubdir = os.path.join(srcdir, 'stubs') 43 | 44 | patchesdir = os.path.join(datadir, 'patches') 45 | 46 | 47 | os.chdir(datadir) 48 | 49 | shutil.copytree(os.path.join(stubdir, 'data', 'patches'), patchesdir) 50 | 51 | # FIXME 52 | os.chdir(patchesdir) 53 | 54 | subprocess.call([os.path.join(stubdir, 'patchwork'), 55 | '--test=load-patches']) 56 | 57 | # cleanup 58 | shutil.rmtree(patchesdir) 59 | 60 | if __name__ == "__main__": 61 | main() 62 | -------------------------------------------------------------------------------- /stubs/cmdtests/patchwork-rest.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016,2020, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import stubs 35 | import os 36 | import requests 37 | 38 | PATCHWORK_PORT=8107 39 | 40 | def main(): 41 | #srcdir = os.environ['SRCDIR'] 42 | datadir = os.environ['DATADIR'] 43 | #stubdir = os.path.join(srcdir, 'stubs') 44 | #patchesdir = os.path.join(datadir, 'patches') 45 | 46 | os.chdir(datadir) 47 | 48 | # start patchwork 49 | pw_stub = stubs.PatchworkStub(port=PATCHWORK_PORT) 50 | pw_stub.start() 51 | 52 | server_url = 'http://localhost:%d/api/1.2' % (PATCHWORK_PORT) 53 | project = 'stub-test' 54 | username = 'test' 55 | # TODO: add token 56 | 57 | # TODO: the stub server does not support filtering per state yet 58 | print('retrieve all patches under review') 59 | params = {'project' : project, 60 | 'delegate' : username, 61 | 'state' : 'under-review', 62 | } 63 | r = requests.get('%s/patches/' % (server_url), params=params) 64 | 65 | r.raise_for_status() 66 | 67 | i = 1 68 | for patch in r.json(): 69 | print('[%d] %s\t\t%s' % (i, patch['name'], patch['state'])) 70 | i += 1 71 | 72 | print() 73 | 74 | print('retrieve patch id 1030') 75 | r = requests.get('%s/patches/%s/' % (server_url, 1030)) 76 | 77 | r.raise_for_status() 78 | 79 | patch = r.json() 80 | 81 | print('%s: %s' % (patch['id'], patch['name'])) 82 | 83 | print() 84 | 85 | print('retrieve patch id 777777 which should not exist') 86 | r = requests.get('%s/patches/%s/' % (server_url, 777777)) 87 | 88 | print('Response code: %d' % (r.status_code)) 89 | 90 | if r.status_code != 404: 91 | print('Status code is wrong!') 92 | 93 | print() 94 | 95 | pw_stub.stop() 96 | pw_stub.cleanup() 97 | 98 | if __name__ == "__main__": 99 | main() 100 | -------------------------------------------------------------------------------- /stubs/cmdtests/patchwork-rest.stdout: -------------------------------------------------------------------------------- 1 | retrieve all patches under review 2 | [1] [1/7] foo: test 1 under-review 3 | [2] [2/7] foo: test 2 under-review 4 | [3] [3/7] foo: test 3 under-review 5 | [4] [4/7] foo: test 4 under-review 6 | [5] [5/7] foo: test 5 under-review 7 | [6] [6/7] foo: test 6 under-review 8 | [7] [7/7] foo: test 7 under-review 9 | 10 | retrieve patch id 1030 11 | 1030: foo: new patch 12 | 13 | retrieve patch id 777777 which should not exist 14 | Response code: 404 15 | 16 | -------------------------------------------------------------------------------- /stubs/cmdtests/pwcli-wrapper.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import stubs 35 | import os 36 | 37 | def main(): 38 | srcdir = os.environ['SRCDIR'] 39 | datadir = os.environ['DATADIR'] 40 | 41 | os.chdir(datadir) 42 | 43 | pwcli = stubs.PwcliWrapper(builder='builder') 44 | pwcli.write_config() 45 | 46 | # print the config file 47 | f = open(pwcli.configpath, 'r') 48 | print(f.read()) 49 | f.close() 50 | 51 | pwcli.cleanup() 52 | 53 | if __name__ == "__main__": 54 | main() 55 | -------------------------------------------------------------------------------- /stubs/cmdtests/pwcli-wrapper.stdout: -------------------------------------------------------------------------------- 1 | [general] 2 | project = stub-test 3 | token = abcd1234567890 4 | username = test 5 | server-url = http://localhost:8105/ 6 | automatic-emails = true 7 | msgid-tag = Link: https://lore.kernel.org/r/%s 8 | build-command = builder 9 | 10 | 11 | -------------------------------------------------------------------------------- /stubs/cmdtests/smtpd.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import os 35 | import os.path 36 | import sys 37 | import subprocess 38 | import time 39 | 40 | def main(): 41 | srcdir = os.environ['SRCDIR'] 42 | datadir = os.environ['DATADIR'] 43 | stubdir = os.path.join(srcdir, 'stubs') 44 | smtpddir = os.path.join(datadir, 'smtpddir') 45 | 46 | os.chdir(datadir) 47 | 48 | os.mkdir(smtpddir) 49 | 50 | env = os.environ.copy() 51 | env['STUB_SMTPD_DATADIR'] = smtpddir 52 | 53 | smtpd = subprocess.Popen([os.path.join(stubdir, 'smtpd'), '--port=4321'], 54 | stdin=subprocess.DEVNULL, env=env) 55 | 56 | time.sleep(1) 57 | 58 | # check that smtpd is running 59 | if smtpd.poll() is not None: 60 | print('smtpd failed to start: %d' % (smtpd.returncode)) 61 | sys.exit(1) 62 | 63 | subprocess.call([os.path.join(stubdir, 'smtpclient'), '--port=4321']) 64 | 65 | time.sleep(1) 66 | 67 | smtpd.kill() 68 | 69 | # print all the files to make sure there are no extra mails 70 | print('files: %s' % os.listdir(smtpddir)) 71 | 72 | # cat smtpddir/0 73 | mail0 = os.path.join(smtpddir, '0') 74 | f = open(mail0, 'r') 75 | print(f.read()) 76 | 77 | # cleanup 78 | os.remove(mail0) 79 | os.rmdir(smtpddir) 80 | 81 | if __name__ == "__main__": 82 | main() 83 | -------------------------------------------------------------------------------- /stubs/cmdtests/smtpd.stdout: -------------------------------------------------------------------------------- 1 | files: ['0'] 2 | test@example.com -> foo@example.com, bar@example.com 3 | Content-Type: text/plain; charset="us-ascii" 4 | MIME-Version: 1.0 5 | Content-Transfer-Encoding: 7bit 6 | To: foo@example.com, bar@example.com 7 | From: test@example.com 8 | 9 | msg body 10 | -------------------------------------------------------------------------------- /stubs/cmdtests/stg.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import os 35 | import os.path 36 | import sys 37 | import subprocess 38 | import stubs 39 | import stubslib 40 | 41 | srcdir = os.environ['SRCDIR'] 42 | datadir = os.environ['DATADIR'] 43 | stubsdir = os.path.join(srcdir, 'stubs') 44 | stubsdatadir = os.path.join(stubsdir, 'data') 45 | patchesdir = os.path.join(stubsdatadir, 'patches') 46 | stub_git = 'git' 47 | stub_stg = 'stg' 48 | 49 | def stg_import(filename): 50 | path = os.path.join(patchesdir, filename) 51 | 52 | f = open(path, 'r') 53 | buf = f.read() 54 | f.close() 55 | 56 | cmd = [stub_stg, 'import', '--mbox', '--sign'] 57 | 58 | # p = subprocess.Popen(cmd, stdout=subprocess.PIPE, 59 | # stdin=subprocess.PIPE, stderr=subprocess.PIPE) 60 | p = subprocess.Popen(cmd, stdin=subprocess.PIPE, universal_newlines=True) 61 | 62 | (stdoutdata, stderrdata) = p.communicate(input=buf) 63 | 64 | return p.returncode 65 | 66 | def main(): 67 | os.chdir(datadir) 68 | 69 | # hack to enable automatic flushing so that printouts are not 70 | # out of order 71 | # https://stackoverflow.com/questions/27067713/why-text-i-o-must-be-buffered-in-python-3 72 | sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering=1) 73 | 74 | stgstub = stubs.StgStub() 75 | gitdir = stgstub.gitdir 76 | stgstub.start() 77 | 78 | print('import one patch') 79 | stg_import('1001-review-foo-test-1.patch') 80 | print() 81 | 82 | print('check patch was correctly imported') 83 | gitrepo = stubslib.GitRepository.load(gitdir) 84 | print((gitrepo.get_commits()[-1].get_subject())) 85 | print() 86 | 87 | print('import a second patch') 88 | stg_import('1002-review-foo-test-2.patch') 89 | print() 90 | 91 | print('test that commit id is stable and a valid git object') 92 | subprocess.call([stub_git, 'log', '--oneline', '--max-count=2']) 93 | print() 94 | 95 | print('test series') 96 | subprocess.call([stub_stg, 'series', '--noprefix', '--all']) 97 | print() 98 | 99 | print('test show') 100 | subprocess.call([stub_stg, 'show', 'foo-test-2']) 101 | 102 | print('import should fail') 103 | gitrepo = stubslib.GitRepository.load(gitdir) 104 | gitrepo.set_stg_import_failure(1) 105 | returncode = stg_import('1002-review-foo-test-2.patch') 106 | if returncode != 2: 107 | print(('wrong return code: %d' % (returncode))) 108 | sys.exit(1) 109 | print() 110 | 111 | print('test delete') 112 | subprocess.call([stub_stg, 'delete', '--top']) 113 | subprocess.call([stub_stg, 'show']) 114 | 115 | # cleanup 116 | stgstub.cleanup() 117 | 118 | if __name__ == "__main__": 119 | main() 120 | -------------------------------------------------------------------------------- /stubs/cmdtests/stg.stderr: -------------------------------------------------------------------------------- 1 | error: patch failed: drivers/net/wireless/foo/core.c:1714 2 | error: drivers/net/wireless/foo/core.c: patch does not apply 3 | error: patch failed: drivers/net/wireless/foo/core.h:635 4 | error: drivers/net/wireless/foo/core.h: patch does not apply 5 | error: patch failed: drivers/net/wireless/foo/debug.c:1427 6 | error: drivers/net/wireless/foo/debug.c: patch does not apply 7 | error: patch failed: drivers/net/wireless/foo/debug.h:59 8 | error: drivers/net/wireless/foo/debug.h: patch does not apply 9 | error: patch failed: drivers/net/wireless/foo/mac.c:6924 10 | error: drivers/net/wireless/foo/mac.c: patch does not apply 11 | stg import: Diff does not apply cleanly 12 | -------------------------------------------------------------------------------- /stubs/cmdtests/stg.stdout: -------------------------------------------------------------------------------- 1 | import one patch 2 | Checking for changes in the working directory ... done 3 | Importing patch "foo-test-1" ... done 4 | Now at patch "foo-test-1" 5 | 6 | check patch was correctly imported 7 | foo: test 1 8 | 9 | import a second patch 10 | Checking for changes in the working directory ... done 11 | Importing patch "foo-test-2" ... done 12 | Now at patch "foo-test-2" 13 | 14 | test that commit id is stable and a valid git object 15 | b50b875961e9 foo: test 1 16 | bbd3154f2111 foo: test 2 17 | 18 | test series 19 | foo-test-1 20 | foo-test-2 21 | 22 | test show 23 | commit bbd3154f2111572248f813c70dc030fc3749811f 24 | Author: Timo Tiger 25 | Date: 2011-02-11 15:23:32 26 | 27 | foo: test 2 28 | 29 | Foo commit log. Ignore this text 30 | 31 | Signed-off-by: Dino Dinosaurus 32 | 33 | --- 34 | FIXME: add the patch here 35 | 36 | diff... 37 | 38 | import should fail 39 | 40 | test delete 41 | commit b50b875961e94e1bb9b826425f950d405c45c3d5 42 | Author: Dino Dinosaurus 43 | Date: 2011-02-11 15:23:31 44 | 45 | foo: test 1 46 | 47 | Foo commit log. Ignore this text 48 | 49 | Signed-off-by: Dino Dinosaurus 50 | 51 | --- 52 | FIXME: add the patch here 53 | 54 | diff... 55 | 56 | -------------------------------------------------------------------------------- /stubs/create_fake_patches: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import argparse 35 | import string 36 | import os.path 37 | import re 38 | import email 39 | 40 | template_patch = '''Content-Type: text/plain; charset="utf-8" 41 | MIME-Version: 1.0 42 | Content-Transfer-Encoding: 7bit 43 | Subject: [$INDEX/$INDEX_MAX] $TITLE $INDEX 44 | From: Dino Dinosaurus 45 | Message-Id: <11111@example.com> 46 | To: list@example.com 47 | Date: 2011-02-11 15:23:31 48 | X-Patchwork-Id: $ID 49 | X-Submitter-Id: 7477 50 | X-Project: Linux Wireless Mailing List 51 | X-Project-Id: 15 52 | X-Commit-Ref: 53 | X-State: $STATE 54 | X-State-Id: $STATE_ID 55 | X-Delegate: test 56 | X-Delegate-Id: 25621 57 | 58 | 59 | Foo commit log. Ignore this text 60 | 61 | Signed-off-by: Dino Dinosaurus 62 | 63 | --- 64 | FIXME: add the patch here 65 | ''' 66 | 67 | 68 | def main(): 69 | # for the help and possible future additions 70 | parser = argparse.ArgumentParser(description='create fake patches for patchwork stub. Note: state is hardcoded, you need to manually change that!') 71 | parser.add_argument('start_id', type=int, nargs=1, 72 | help='The id of the first patch') 73 | parser.add_argument('count', type=int, nargs=1, 74 | help='How many patches to create') 75 | parser.add_argument('title', type=str, nargs=1, 76 | help='Title of patches') 77 | 78 | args = parser.parse_args() 79 | 80 | outputdir = os.path.join('data', 'patches') 81 | filenames = [] 82 | 83 | for index in range(1, args.count[0] + 1): 84 | t = string.Template(template_patch) 85 | patchwork_id = args.start_id[0] + index - 1 86 | 87 | # FIXME: the state is hardcoded for now 88 | state = 'New' 89 | state_id = '1' 90 | 91 | patch = t.substitute(INDEX=index, INDEX_MAX=args.count[0], 92 | TITLE=args.title[0], ID=patchwork_id, 93 | STATE=state, STATE_ID=state_id) 94 | 95 | # make the title suitable for a filename 96 | title = email.message_from_string(patch)['Subject'] 97 | title = title.lower() 98 | 99 | # remove tags (from Patch.clean_subject() 100 | title = re.sub(r'^\s*(\[.*?\]\s*)*', '', title) 101 | 102 | title = re.sub(r'\W+', '-', title) 103 | 104 | # FIXME: there should be a proper mapping, for example 105 | # 'Under Review' -> 'review' 106 | state = state.lower() 107 | 108 | filename = '%s-%s-%s.patch' % (patchwork_id, state, title) 109 | f = open(os.path.join(outputdir, filename), 'w') 110 | f.write(patch) 111 | f.close 112 | 113 | filenames.append(filename) 114 | 115 | print('%d patches wrote to %s:' % (len(filenames), outputdir)) 116 | 117 | for filename in filenames: 118 | print(filename) 119 | 120 | 121 | if __name__ == "__main__": 122 | main() 123 | -------------------------------------------------------------------------------- /stubs/data/patches/1001-review-foo-test-1.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [1/7] foo: test 1 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:31 9 | X-Patchwork-Id: 1001 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1002-review-foo-test-2.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [2/7] foo: test 2 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:32 9 | X-Patchwork-Id: 1002 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1003-review-foo-test-3.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [3/7] foo: test 3 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:34 9 | X-Patchwork-Id: 1003 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1004-review-foo-test-4.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [4/7] foo: test 4 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:34 9 | X-Patchwork-Id: 1004 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1005-review-foo-test-5.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [5/7] foo: test 5 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:35 9 | X-Patchwork-Id: 1005 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1006-review-foo-test-6.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [6/7] foo: test 6 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:36 9 | X-Patchwork-Id: 1006 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1007-review-foo-test-7.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [7/7] foo: test 7 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 15:23:36 9 | X-Patchwork-Id: 1007 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Under Review 15 | X-State-Id: 2 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1020-deferred-foo-small-cleanup.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: foo: small cleanup 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 18:00:05 9 | X-Patchwork-Id: 1020 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Deferred 15 | X-State-Id: 10 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1021-utf8-test.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 8bit 4 | Subject: foo: utf-8 tèst 5 | From: Èd Examplè 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 18:17:17 9 | X-Patchwork-Id: 1021 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Deferred 15 | X-State-Id: 10 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Èd Examplè 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1030-new-foo-new-patch.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: foo: new patch 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-11 18:40:01 9 | X-Patchwork-Id: 1030 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1031-new-foo-minor-change-with-cc.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: foo: minor change with CC 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Cc: john@example.org, zoe@example.org 9 | Date: 2011-02-12 09:00:00 10 | X-Patchwork-Id: 1031 11 | X-Submitter-Id: 7477 12 | X-Project: Linux Wireless Mailing List 13 | X-Project-Id: 15 14 | X-Commit-Ref: 15 | X-State: New 16 | X-State-Id: 1 17 | X-Delegate: test 18 | X-Delegate-Id: 25621 19 | 20 | 21 | Foo commit log. Ignore this text 22 | 23 | Signed-off-by: Dino Dinosaurus 24 | 25 | --- 26 | FIXME: add the patch here 27 | -------------------------------------------------------------------------------- /stubs/data/patches/1032-new-foo-another-minor-change-with-multiple-to.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: foo: another minor change with multiple To 5 | From: Timo Tiger 6 | Message-Id: <22222@example.com> 7 | To: list@example.com, list-second@example.com 8 | Date: 2011-02-12 09:10:00 9 | X-Patchwork-Id: 1032 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1040-new-bar-blah-blah-blah-1.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [1/15] bar: blah blah blah 1 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 10:59:59 9 | X-Patchwork-Id: 1040 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1041-new-bar-blah-blah-blah-2.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [2/15] bar: blah blah blah 2 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 10:59:59 9 | X-Patchwork-Id: 1041 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1042-new-bar-blah-blah-blah-3.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [3/15] bar: blah blah blah 3 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1042 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1043-new-bar-blah-blah-blah-4.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [4/15] bar: blah blah blah 4 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1043 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1044-new-bar-blah-blah-blah-5.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [5/15] bar: blah blah blah 5 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1044 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1045-new-bar-blah-blah-blah-6.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [6/15] bar: blah blah blah 6 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1045 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1046-new-bar-blah-blah-blah-7.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [7/15] bar: blah blah blah 7 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1046 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1047-new-bar-blah-blah-blah-8.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [8/15] bar: blah blah blah 8 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1047 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1048-new-bar-blah-blah-blah-9.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [9/15] bar: blah blah blah 9 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1048 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1049-new-bar-blah-blah-blah-10.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [10/15] bar: blah blah blah 10 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1049 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1050-new-bar-blah-blah-blah-11.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [11/15] bar: blah blah blah 11 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1050 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1051-new-bar-blah-blah-blah-12.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [12/15] bar: blah blah blah 12 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1051 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1052-new-bar-blah-blah-blah-13.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [13/15] bar: blah blah blah 13 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1052 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1053-new-bar-blah-blah-blah-14.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [14/15] bar: blah blah blah 14 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1053 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1054-new-bar-blah-blah-blah-15.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [15/15] bar: blah blah blah 15 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 11:00:00 9 | X-Patchwork-Id: 1054 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1060-deferred-koo-yyy-bbb-cc-1.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [1/4] koo: yyy bbb cc 1 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 12:00:00 9 | X-Patchwork-Id: 1060 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Deferred 15 | X-State-Id: 10 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1061-deferred-koo-yyy-bbb-cc-2.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [2/4] koo: yyy bbb cc 2 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 12:00:01 9 | X-Patchwork-Id: 1061 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Deferred 15 | X-State-Id: 10 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1062-deferred-koo-yyy-bbb-cc-3.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [3/4] koo: yyy bbb cc 3 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 12:00:02 9 | X-Patchwork-Id: 1062 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Deferred 15 | X-State-Id: 10 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/1063-deferred-koo-yyy-bbb-cc-4.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: [4/4] koo: yyy bbb cc 4 5 | From: Dino Dinosaurus 6 | Message-Id: <11111@example.com> 7 | To: list@example.com 8 | Date: 2011-02-12 12:00:02 9 | X-Patchwork-Id: 1063 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: Deferred 15 | X-State-Id: 10 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/data/patches/123456789-new-patch-with-a-really-long-name-and-id.patch: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: foo: patch with a really long a name and id so I just need to keep typing and come up with something clever, I'm just not good with that 5 | From: Lasse Really Surpringly Long And Complicated Name 6 | Message-Id: <22222@example.com> 7 | To: list@example.com 8 | Date: 2011-02-20 13:13:13 9 | X-Patchwork-Id: 123456789 10 | X-Submitter-Id: 7477 11 | X-Project: Linux Wireless Mailing List 12 | X-Project-Id: 15 13 | X-Commit-Ref: 14 | X-State: New 15 | X-State-Id: 1 16 | X-Delegate: test 17 | X-Delegate-Id: 25621 18 | 19 | 20 | Foo commit log. Ignore this text 21 | 22 | Signed-off-by: Dino Dinosaurus 23 | 24 | --- 25 | FIXME: add the patch here 26 | -------------------------------------------------------------------------------- /stubs/smtpclient: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import smtplib 35 | import argparse 36 | import email 37 | import email.mime.text 38 | import sys 39 | 40 | 41 | def run(args): 42 | from_address = 'test@example.com' 43 | to = ['foo@example.com', 'bar@example.com'] 44 | body = 'msg body' 45 | msg = email.mime.text.MIMEText(body, _charset='us-ascii') 46 | msg['To'] = ', '.join(to) 47 | msg['From'] = from_address 48 | 49 | try: 50 | server = smtplib.SMTP('localhost', args.port) 51 | server.sendmail(from_address, to, msg.as_string()) 52 | server.quit() 53 | except Exception as e: 54 | print('failed to connect to the SMTP server: %s' % e) 55 | sys.exit(1) 56 | 57 | 58 | def main(): 59 | parser = argparse.ArgumentParser(description='smtpd-stub') 60 | 61 | parser.add_argument('--port', action='store', type=int, default=5872) 62 | 63 | args = parser.parse_args() 64 | 65 | run(args) 66 | 67 | 68 | if __name__ == "__main__": 69 | main() 70 | -------------------------------------------------------------------------------- /stubs/smtpd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import argparse 35 | import aiosmtpd.controller 36 | import os 37 | import os.path 38 | import sys 39 | import signal 40 | 41 | datadir = None 42 | 43 | 44 | class CustomHandler: 45 | async def handle_DATA(self, server, session, envelope): 46 | rcpt_tos = ', '.join(envelope.rcpt_tos) 47 | 48 | print('smtpd: %s -> %s' % (envelope.mail_from, rcpt_tos)) 49 | 50 | if os.path.isdir(datadir): 51 | f = open(os.path.join(datadir, str(self.count)), 'w') 52 | f.write('%s -> %s\n' % (envelope.mail_from, rcpt_tos)) 53 | 54 | # FIXME: is .decode('utf-8') really necessary here or is this is just a leftover python2 hack? 55 | buf = envelope.content.decode('utf-8') 56 | 57 | # to maintain compability with the previous smtpd package 58 | # implementation and avoid changes in cmdtest output 59 | buf = buf[:-2] 60 | 61 | f.write(buf) 62 | 63 | f.close 64 | self.count += 1 65 | 66 | return '250 OK' 67 | 68 | def __init__(self): 69 | self.count = 0 70 | 71 | 72 | def run(args): 73 | if os.path.isdir(datadir): 74 | files = len(os.listdir(datadir)) 75 | if files > 0: 76 | print('%s directory is not empty: %d' % (datadir, files)) 77 | sys.exit(1) 78 | 79 | handler = CustomHandler() 80 | controller = aiosmtpd.controller.Controller(handler, hostname='127.0.0.1', port=args.port) 81 | 82 | # Run the event loop in a separate thread. 83 | controller.start() 84 | 85 | # wait until a signal is received 86 | signal.pause() 87 | 88 | controller.stop() 89 | 90 | 91 | def main(): 92 | global datadir 93 | 94 | if 'STUB_SMTPD_DATADIR' in os.environ: 95 | datadir = os.environ['STUB_SMTPD_DATADIR'] 96 | else: 97 | datadir = '.' 98 | 99 | parser = argparse.ArgumentParser(description='smtpd-stub') 100 | 101 | parser.add_argument('--port', action='store', type=int, default=5872) 102 | 103 | args = parser.parse_args() 104 | 105 | run(args) 106 | 107 | 108 | if __name__ == "__main__": 109 | main() 110 | -------------------------------------------------------------------------------- /tests.ini: -------------------------------------------------------------------------------- 1 | [sources] 2 | python = pwcli run_tests run_stub cmdtests/cmdtestlib.py stubs/builder stubs/create_fake_patches stubs/git stubs/patchwork stubs/smtpclient stubs/smtpd stubs/stg stubs/stubslib.py stubs/stubs.py unittests/test_git.py unittests/test_patch.py unittests/test_runprocess.py unittests/test_utils.py 3 | -------------------------------------------------------------------------------- /unittests/.gitignore: -------------------------------------------------------------------------------- 1 | /pwcli.py 2 | /pwcli.pyc 3 | -------------------------------------------------------------------------------- /unittests/__init__.py: -------------------------------------------------------------------------------- 1 | # needed to make it possible import from pwcli 2 | -------------------------------------------------------------------------------- /unittests/git-show-simple-1.data: -------------------------------------------------------------------------------- 1 | commit 07701d002c8c24e73c6cc51177981ce54fdb2b31 2 | foo: this is a test for simple format 3 | 4 | This format is to simplify commit log parsing. folkafsjdli dfsafaj 5 | fsjf dkjafd fsfljf adslkj fjkf adfsk laskj fsdlfsa akljsd asfaljs 6 | 7 | And this is a fake commit line to make sure we don't parse the wrong 8 | one: 9 | 10 | commit 0000000000000000000000000000000000000000 11 | 12 | Patchwork-Id: 12345678 13 | Signed-off-by: Ed Example 14 | -------------------------------------------------------------------------------- /unittests/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # stubs 4 | export PATH=../stubs:$PATH 5 | 6 | # hack to make it possible import classes from pwcli.py 7 | if [ ! -h pwcli.py ]; then 8 | ln -s ../pwcli pwcli.py 9 | fi 10 | 11 | python3 -m unittest discover 12 | -------------------------------------------------------------------------------- /unittests/stg-show-1.data: -------------------------------------------------------------------------------- 1 | commit 8bd453fe60574334173cdbb51faa390b98678063 2 | Author: Alice Example 3 | Date: Tue May 30 09:39:58 2017 +0300 4 | 5 | run_tests: add checks suite 6 | 7 | For now this just runs pyflakes and pep8. Need to extend it later. 8 | There should not be any functional changes. 9 | 10 | foo foo bar bar 11 | 12 | Signed-off-by: Alice Example 13 | Patchwork-Id: 12345 14 | Signed-off-by: Ed Example 15 | 16 | diff --git a/run_tests b/run_tests 17 | index 29a542dae2e6..fc833b52c27b 100755 18 | --- a/run_tests 19 | +++ b/run_tests 20 | @@ -36,7 +36,7 @@ import subprocess 21 | import sys 22 | import argparse 23 | 24 | -SUITES = ('stubs', 'cmdtests', 'unittests') 25 | +SUITES = ('stubs', 'cmdtests', 'unittests', 'checks') 26 | 27 | CMDTEST_DIRECTORIES = ['cmdtests', 'stubs/cmdtests'] 28 | 29 | -------------------------------------------------------------------------------- /unittests/test_git.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import unittest 35 | import subprocess 36 | import tempfile 37 | import os 38 | import shutil 39 | import hashlib 40 | import stubslib 41 | 42 | from pwcli import Git 43 | from pwcli import GitCommit 44 | 45 | 46 | class TestGit(unittest.TestCase): 47 | 48 | def dummy_output(self, buf): 49 | pass 50 | 51 | def setUp(self): 52 | output = subprocess.check_output(['git', '--version', 'branch']) 53 | 54 | output = output.strip() 55 | 56 | self.datadir = tempfile.mkdtemp(prefix='pwcli-unittest-') 57 | 58 | os.environ['STUB_GIT_DATADIR'] = self.datadir 59 | 60 | if output.splitlines()[0] != b'stub-git': 61 | self.fail('Not using stub-git') 62 | return 63 | 64 | def tearDown(self): 65 | shutil.rmtree(self.datadir) 66 | 67 | def test_get_branch(self): 68 | gitrepo = stubslib.GitRepository.load(self.datadir) 69 | 70 | gitrepo.create_branch('bbb') 71 | gitrepo.create_branch('foo') 72 | gitrepo.create_branch('ccc') 73 | 74 | gitrepo.change_branch('foo') 75 | 76 | git = Git(self.dummy_output) 77 | branch = git.get_branch() 78 | 79 | self.assertEqual(branch, 'foo') 80 | 81 | def test_am(self): 82 | mbox = '''From nobody 83 | From: Ed Example \nPatchwork-Id: 12345\nSigned-off-by: Ed Example \n') 113 | 114 | def test_parse_simple_format(self): 115 | f = open('git-show-simple-1.data') 116 | commit = GitCommit.parse_simple_format(f.read()) 117 | f.close() 118 | 119 | self.assertEqual(commit.commit_id, 120 | '07701d002c8c24e73c6cc51177981ce54fdb2b31') 121 | self.assertEqual(commit.title, 122 | 'foo: this is a test for simple format') 123 | self.assertTrue(commit.log.startswith('This format is to')) 124 | self.assertTrue(commit.log.endswith('Signed-off-by: Ed Example ')) 125 | self.assertEqual(commit.patchwork_id, 12345678) 126 | 127 | 128 | if __name__ == '__main__': 129 | unittest.main() 130 | -------------------------------------------------------------------------------- /unittests/test_runprocess.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import unittest 35 | 36 | import pwcli 37 | 38 | 39 | class TestRunProcess(unittest.TestCase): 40 | def test_stdout(self): 41 | msg = 'This is a test\nLine 2' 42 | p = pwcli.RunProcess(['/bin/echo', '-n', msg]) 43 | 44 | self.assertEqual(p.returncode, 0) 45 | self.assertEqual(p.stdoutdata, msg) 46 | self.assertEqual(p.stderrdata, '') 47 | 48 | def test_stderr(self): 49 | # Note: newlines in msg will fail for some reason 50 | msg = 'This is a test' 51 | python_cmd = 'import sys; sys.stderr.write("%s")' % (msg) 52 | 53 | p = pwcli.RunProcess(['python3', '-c', python_cmd]) 54 | 55 | self.assertEqual(p.returncode, 0) 56 | self.assertEqual(p.stdoutdata, '') 57 | self.assertEqual(p.stderrdata, msg) 58 | 59 | def test_nonzero_returncode(self): 60 | value = 177 61 | python_cmd = 'import sys; sys.exit(%d)' % (value) 62 | 63 | p = pwcli.RunProcess(['python3', '-c', python_cmd]) 64 | 65 | self.assertEqual(p.returncode, value) 66 | self.assertEqual(p.stdoutdata, '') 67 | self.assertEqual(p.stderrdata, '') 68 | 69 | def test_stdout_cb(self): 70 | msg = 'Line 1\nLine 2\nLine 3' 71 | cb_output = [] 72 | 73 | def cb(line): 74 | cb_output.append(line) 75 | 76 | p = pwcli.RunProcess(['/bin/echo', '-n', msg], stdout_cb=cb) 77 | 78 | self.assertEqual(p.returncode, 0) 79 | self.assertEqual(p.stdoutdata, msg) 80 | self.assertEqual(p.stderrdata, '') 81 | 82 | # strip newlines for easy comparison 83 | cb_output = [s.strip() for s in cb_output] 84 | 85 | self.assertEqual(msg.split('\n'), cb_output) 86 | 87 | def test_input(self): 88 | msg = 'This is a test' 89 | p = pwcli.RunProcess(['cat'], input=msg) 90 | 91 | self.assertEqual(p.returncode, 0) 92 | self.assertEqual(p.stdoutdata, msg) 93 | self.assertEqual(p.stderrdata, '') 94 | 95 | def test_str(self): 96 | p = pwcli.RunProcess(['/bin/echo', 'foo', 'bar']) 97 | self.assertEqual(str(p), 'RunProcess(\'/bin/echo foo bar\', None, None)') 98 | 99 | def test_repr(self): 100 | msg = 'This is a test' 101 | 102 | p = pwcli.RunProcess(['cat'], input=msg) 103 | 104 | self.assertEqual(repr(p), 105 | 'RunProcess([\'cat\'], None, \'This is a test\')') 106 | 107 | 108 | if __name__ == '__main__': 109 | unittest.main() 110 | -------------------------------------------------------------------------------- /unittests/test_utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015, The Linux Foundation. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | import unittest 35 | import os 36 | import datetime 37 | 38 | import pwcli 39 | 40 | 41 | class TestUtils(unittest.TestCase): 42 | def test_clean(self): 43 | self.assertEqual(pwcli.clean('\n\t foo '), 'foo') 44 | 45 | def test_parse_list(self): 46 | self.assertEqual(pwcli.parse_list('1-3'), [1, 2, 3]) 47 | self.assertEqual(pwcli.parse_list(''), []) 48 | self.assertEqual(pwcli.parse_list('99'), [99]) 49 | self.assertEqual(pwcli.parse_list('0,77,7777'), [0, 77, 7777]) 50 | self.assertEqual(pwcli.parse_list('0-3,5'), [0, 1, 2, 3, 5]) 51 | self.assertEqual(pwcli.parse_list('10,11,12,14-15,16'), 52 | [10, 11, 12, 14, 15, 16]) 53 | self.assertEqual(pwcli.parse_list('0-3,2'), [0, 1, 2, 3]) 54 | self.assertEqual(pwcli.parse_list('1-4,0-3,2,1-2'), [0, 1, 2, 3, 4]) 55 | 56 | # negative tests 57 | with self.assertRaises(Exception): 58 | pwcli.parse_list('1 2') 59 | 60 | with self.assertRaises(Exception): 61 | pwcli.parse_list('foo') 62 | 63 | with self.assertRaises(Exception): 64 | pwcli.parse_list('foo-bar') 65 | 66 | with self.assertRaises(Exception): 67 | pwcli.parse_list('foo,bar') 68 | 69 | with self.assertRaises(Exception): 70 | pwcli.parse_list('1-bar') 71 | 72 | with self.assertRaises(Exception): 73 | pwcli.parse_list('1,bar') 74 | 75 | with self.assertRaises(Exception): 76 | pwcli.parse_list('bar,2') 77 | 78 | with self.assertRaises(Exception): 79 | pwcli.parse_list('bar-2') 80 | 81 | def test_shrink(self): 82 | f = pwcli.shrink 83 | self.assertEqual(f('12345678', 5), '12...') 84 | self.assertEqual(f('12345678', 5, ellipsis=False), '12345') 85 | 86 | # last space should be replaced with a dot 87 | self.assertEqual(f('yyy kaa koo nee', 11), 'yyy kaa....') 88 | 89 | # test special values 90 | self.assertEqual(f('12345678', 4, ellipsis=True), '1...') 91 | self.assertEqual(f('12345678', 3, ellipsis=True), '') 92 | self.assertEqual(f('12345678', 0, ellipsis=True), '') 93 | self.assertEqual(f('12345678', -10, ellipsis=True), '') 94 | 95 | def test_get_age(self): 96 | f = pwcli.get_age 97 | 98 | def d(date): 99 | return datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S') 100 | 101 | os.environ['PWCLI_HARDCODE_DATE'] = '2020-01-01T01:00:00' 102 | 103 | self.assertEqual(f(d('2017-11-30T01:00:00')), '2y') 104 | self.assertEqual(f(d('2018-11-30T01:00:00')), '13m') 105 | self.assertEqual(f(d('2019-01-01T01:00:00')), '12m') 106 | self.assertEqual(f(d('2019-12-01T01:00:00')), '1m') 107 | self.assertEqual(f(d('2019-12-03T01:00:00')), '29d') 108 | self.assertEqual(f(d('2019-12-03T01:00:00')), '29d') 109 | self.assertEqual(f(d('2019-12-31T00:00:00')), '1d') 110 | self.assertEqual(f(d('2019-12-31T01:00:01')), '23h') 111 | self.assertEqual(f(d('2020-01-01T00:00:00')), '1h') 112 | self.assertEqual(f(d('2020-01-01T00:00:01')), '0h') 113 | self.assertEqual(f(d('2020-01-01T00:59:59')), '0h') 114 | 115 | 116 | if __name__ == '__main__': 117 | unittest.main() 118 | --------------------------------------------------------------------------------