Issue 10453: Add -h/--help option to compileall (original) (raw)

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: Arfrever, Kotan, brunogola, donmez, eric.araujo, ezio.melotti, maker, pitrou, r.david.murray, skrah
Priority: high Keywords: easy, patch

Created on 2010-11-18 16:07 by eric.araujo, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_compileall.patch Kotan,2010-11-20 17:02 unit test, to test that -h returns usage and returns with error code 0
issue10453.patch maker,2010-11-20 19:41
issue10453_tests.patch maker,2010-11-20 19:41
issue10453_final.patch maker,2010-11-20 20:27
issue10453_noargs.patch maker,2010-11-20 23:04
issue10453_quiet.patch maker,2010-11-21 07:50
test_compileall_windows.patch skrah,2010-11-22 14:57
compileall_multidir_test.diff r.david.murray,2010-12-06 19:21
compileall_multidir.diff r.david.murray,2010-12-06 19:45
compileall_cli_revisited.patch r.david.murray,2010-12-13 14:34
Messages (40)
msg121467 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-18 16:07
It would be useful if “python -m compileall -h” was possible. Right now it fails with “option -h not recognized” and prints its help text, which is a bit silly :) Bug week-end candidate!
msg121470 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-18 16:12
One neat way to solve this is to make compileall use argparse.
msg121673 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 16:23
I'm still working on this task; the attachment shows how I'm solving the bug. The patch is NOT yet completed, there are some problems with the unittests. Hoping that Eric will give me a help soon.
msg121682 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 16:43
The new attached patch passes the unittest.
msg121683 - (view) Author: Daniel Albeseder (Kotan) Date: 2010-11-20 17:02
I did a very simple addition to the CommandLineTest, to check that "-h" really returns the "usage:". I am not sure, if this is useful since, it rather tests argparse now with the proposed patch...
msg121684 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 17:06
Eric, the unittests in Lib/test/test_compileall.py seems quite consistent to me, so for now I won't add anything. About adding a method for testing the '-h' argument, now that Lib/compileall.py uses argparse, it sounds trivial. EDIT: Kotan, I'm still of the same opinion. Anyway, I think you should use as template test.test_compileall.CommandLineTests.test_legacy_paths: so, check for returncode and use subprocess.call instead of subprocess.Popen.
msg121686 - (view) Author: Daniel Albeseder (Kotan) Date: 2010-11-20 17:11
I wanted to test, that no unwanted output is given before the usage. I just added the test before I started to try to fix this bug, as I recognized Michele already was already fixing the bug. This was just my test-driven approach, where the unit test failed before the fix, and should pass afterwards. As the unwanted output was the main reason for the issue, I just did put this into the test. However I agree that the test at all is silly, and I fully agree if it is not used.
msg121689 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-20 17:26
On the other hand, the test case in test_compileall says "test some aspects of compileall's CLI". Since the patch completely changes the logic of CLI parsing, having tests that cover as much as practical of the CLI would greatly increase the confidence that the patch is correct.
msg121740 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 19:41
Unittest added; should be enough.
msg121763 - (view) Author: Bruno Gola (brunogola) Date: 2010-11-20 20:42
applied the patch on an ubuntu 10.04 64bits, py3k (trunk) test_force fails as following: ====================================================================== FAIL: test_force (__main__.CommandLineTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "Lib/test/test_compileall.py", line 202, in test_force self.assertNotEqual(access, access2) AssertionError: 1290285399.744327 == 1290285399.744327 ----------------------------------------------------------------------
msg121772 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 20:57
Yes, I was discussing about that on IRC. That's a matter of platform -on mine for example works-. He gave me a hand in solving this failure; now -I think- he's gonna apply that.
msg121774 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 20:58
*discussing that on IRC with R. David Murray
msg121782 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-20 21:22
Patch committed with minor formatting changes and one fixed test (test_force) in r86611. Thanks, Michele!
msg121808 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-20 22:58
Invocation without arguments does not work. I have a fix, I’ll add a test and commit.
msg121809 - (view) Author: Michele Orrù (maker) * Date: 2010-11-20 23:04
Sorry.
msg121858 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-21 03:56
One buildbot also shows a bug in quiet or test_quiet: Traceback (most recent call last): File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_compileall.py", line 227, in test_quiet self.assertTrue(len(noise) > len(quiet)) AssertionError: False is not True I changed that to assertGreater to get more information in the next failure.
msg121859 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-21 03:59
I hadn’t seen your patch Michele. I find mine more readable: http://pastealacon.com/26257 . That was just the easy part though; do you want to write a test?
msg121880 - (view) Author: Michele Orrù (maker) * Date: 2010-11-21 07:50
Yeah, maybe your is more readable. I suppose that failure was due to some missing arguments when calling compileall (line 225). The attached patch should fix this issue, but currently I have no Windows machines where to test.
msg122017 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-21 23:23
Patch for test_quiet looks good, thanks. Do you want to write test_noargs?
msg122073 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-22 02:43
test_quiet hopefully fixed in r86668.
msg122085 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-22 03:43
Not fixed: http://www.python.org/dev/buildbot/all/builders/AMD64%20Windows%20Server%202008%203.x/builds/54/steps/test/logs/stdio
msg122132 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-11-22 14:57
On Windows, test_compileall fails due to #10197. The patch uses subprocess.check_output() instead. Technically, now byte strings are compared instead of strings, but that should not matter for the outcome.
msg122397 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-25 19:25
Thanks for the patch Stefan. I can’t test on Windows now; can you/have you?
msg122414 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-11-25 22:31
Yes, the patch is tested on Windows. Feel free to commit it if you have a chance.
msg122417 - (view) Author: Michele Orrù (maker) * Date: 2010-11-25 23:03
Thank you Stefan, these days I was a little busy and I hadn't the time to review my patch. I really appreciate you help.
msg122422 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-26 00:45
Revision 86758, thanks.
msg123492 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2010-12-06 19:03
r86611 has introduced a regression: $ mkdir dir1 dir2 $ python3.1 -m compileall dir1 dir2 Listing dir1 ... Listing dir2 ... $ python3.2 -m compileall dir1 dir2 usage: compileall.py [-h] [-l] [-f] [-q] [-b] [-d DESTDIR] [-x REGEXP] [-i FILE] [FILE|DIR] compileall.py: error: unrecognized arguments: dir2
msg123495 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-06 19:13
Whoops, a nargs='?' should have been '*'. Who wants to write the test?
msg123496 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-06 19:15
I'm working on it.
msg123497 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-06 19:19
Let me be more helpful, just in case. This is the offending line: parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='?')
msg123498 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-06 19:21
Here's the test. The fix isn't as simple as making it nargs='*', though.
msg123500 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-06 19:45
Here is a fix. This is not finished, though, because I see that I did not do an adequate review of the original patch. There are still bugs in the -d and -i handling that need both tests and fixes.
msg123621 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-08 17:39
I'm still working on this, making sure the remaining options that aren't currently tested have tests and work.
msg123630 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-08 18:42
Thank you for stepping up. I plead guilty too for letting bugs slip. I’ll be here for pre- or post-commit review.
msg123694 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-09 18:45
OK, here is what I hope is a comprehensive set of CLI tests, and fixes for the bugs revealed thereby. Except for the new test added by Georg after the original patch here was committed, all of the tests either pass using the old compileall module or fail only because stderr has resource warnings in it. I did some refactoring on the tests, and since there were few enough original tests I went through and refactored them all. Hopefully that won't make the review more difficult. Note that I have not tested this patch on windows :)
msg123875 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-13 14:28
Updating patch because the assertTestRegexMatches name was updated.
msg123877 - (view) Author: Ismail Donmez (donmez) * Date: 2010-12-13 14:38
Patch works fine on Mac OSX 10.6.5
msg123982 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-12-14 22:19
Works under Windows 7.
msg123984 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-14 22:33
committed in r87248.
msg123986 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-14 22:38
Thanks for going through. Nice patch!
History
Date User Action Args
2022-04-11 14:57:09 admin set github: 54662
2010-12-14 22:42:42 r.david.murray link issue10707 superseder
2010-12-14 22:38:04 eric.araujo set resolution: accepted -> fixedmessages: +
2010-12-14 22:33:56 r.david.murray set status: open -> closedresolution: acceptedmessages: + stage: test needed -> resolved
2010-12-14 22:19:34 pitrou set nosy: + pitroumessages: +
2010-12-13 14:38:42 donmez set messages: +
2010-12-13 14:34:25 r.david.murray set files: + compileall_cli_revisited.patch
2010-12-13 14:34:00 r.david.murray set files: - compileall_cli_revisited.patch
2010-12-13 14:32:22 r.david.murray set nosy: + donmez
2010-12-13 14:31:51 r.david.murray link issue10691 superseder
2010-12-13 14:29:37 r.david.murray set files: + compileall_cli_revisited.patch
2010-12-13 14:29:05 r.david.murray set files: - compileall_cli_revisited.patch
2010-12-13 14:28:59 r.david.murray set files: - compileall_cli_revisited.patch
2010-12-13 14:28:20 r.david.murray set files: + compileall_cli_revisited.patchmessages: +
2010-12-09 18:45:24 r.david.murray set files: + compileall_cli_revisited.patchmessages: +
2010-12-08 18:42:25 eric.araujo set messages: +
2010-12-08 17:39:32 r.david.murray set assignee: eric.araujo -> r.david.murraymessages: +
2010-12-06 19:45:57 r.david.murray set files: + compileall_multidir.diffmessages: +
2010-12-06 19:21:08 r.david.murray set files: + compileall_multidir_test.diffmessages: +
2010-12-06 19:19:28 eric.araujo set messages: +
2010-12-06 19:15:46 r.david.murray set messages: +
2010-12-06 19:13:17 eric.araujo set messages: +
2010-12-06 19:03:10 Arfrever set nosy: + Arfrevermessages: +
2010-12-03 06:47:15 eric.araujo set priority: normal -> highstage: needs patch -> test needed
2010-11-26 00:45:09 eric.araujo set messages: +
2010-11-25 23:03:49 maker set messages: +
2010-11-25 22:31:04 skrah set messages: +
2010-11-25 19:25:55 eric.araujo set messages: +
2010-11-22 14:57:15 skrah set files: + test_compileall_windows.patchnosy: + skrahmessages: +
2010-11-22 14:47:33 eric.araujo link issue10505 superseder
2010-11-22 03:43:58 eric.araujo set messages: +
2010-11-22 02:43:46 eric.araujo set messages: +
2010-11-21 23:23:12 eric.araujo set messages: +
2010-11-21 07:50:40 maker set files: + issue10453_quiet.patchmessages: +
2010-11-21 03:59:26 eric.araujo set messages: +
2010-11-21 03:56:45 eric.araujo set status: closed -> openmessages: + assignee: r.david.murray -> eric.araujoresolution: accepted -> (no value)stage: resolved -> needs patch
2010-11-20 23:04:14 maker set files: + issue10453_noargs.patchmessages: +
2010-11-20 22:58:08 eric.araujo set messages: +
2010-11-20 21:22:18 r.david.murray set status: open -> closedresolution: acceptedmessages: + stage: commit review -> resolved
2010-11-20 21:04:35 r.david.murray set assignee: eric.araujo -> r.david.murraystage: needs patch -> commit review
2010-11-20 20:58:05 maker set messages: +
2010-11-20 20:57:11 maker set messages: +
2010-11-20 20:42:04 brunogola set nosy: + brunogolamessages: +
2010-11-20 20:27:40 maker set files: + issue10453_final.patch
2010-11-20 19:41:34 maker set files: + issue10453_tests.patch
2010-11-20 19:41:21 maker set files: + issue10453.patchmessages: +
2010-11-20 19:40:47 maker set files: - issue10453.patch
2010-11-20 17:26:35 r.david.murray set nosy: + r.david.murraymessages: +
2010-11-20 17:11:41 Kotan set messages: +
2010-11-20 17:06:03 maker set messages: +
2010-11-20 17:02:37 Kotan set files: + test_compileall.patchnosy: + Kotanmessages: +
2010-11-20 16:55:49 maker set files: + issue10453.patch
2010-11-20 16:55:33 maker set files: - issue10453.patch
2010-11-20 16:43:06 maker set files: + issue10453.patchmessages: +
2010-11-20 16:41:53 maker set files: - issue10453.patch
2010-11-20 16:23:55 maker set files: + issue10453.patchnosy: + ezio.melotti, makermessages: + keywords: + patch
2010-11-18 16:12:28 eric.araujo set messages: +
2010-11-18 16:07:05 eric.araujo create