File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 77import itertools
88import logging
99import os
10+ import re
1011import resource
1112import subprocess
1213import sys
3940 )
4041
4142TIMEOUT = 10.0 # seconds
43+ INVALID_OPTION_ERROR_RE = re .compile (
44+ r"(unrecognized|unknown|illegal|invalid) option|usage|try --help" ,
45+ re .IGNORECASE ,
46+ )
4247
4348# Unset some environment variables, so that testing --enable-environment-names
4449# does not actually depend on the current environment.
@@ -242,9 +247,15 @@ def run_command_invalid(
242247
243248 def run_command_unrecognized_option (self , args ):
244249 rc , stdout , stderr = self .run_command (args )
245- assert rc == 2 , (rc , stdout , stderr )
250+ assert rc != 0 , (rc , stdout , stderr )
246251 assert stdout .startswith ("Usage" ) or stdout == ""
247- assert "unrecognized option" in stderr
252+ # getopt/argument parsing diagnostics vary across libc/platforms
253+ # (for example GNU/Linux vs. Solaris), even when the option is rejected.
254+ assert INVALID_OPTION_ERROR_RE .search (f"{ stdout } \n { stderr } " ), (
255+ rc ,
256+ stdout ,
257+ stderr ,
258+ )
248259
249260 def run_command_missing_arg (self , args ):
250261 rc , stdout , stderr = self .run_command (args )
You can’t perform that action at this time.
0 commit comments