summaryrefslogtreecommitdiff
path: root/test/ValidateOptions.py
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2023-02-20 13:26:05 -0700
committerMats Wichmann <mats@linux.com>2023-04-14 10:16:29 -0600
commit6ce33bdadec1cf558a6d0df27a6a083516d6cf23 (patch)
treec6119695c63111cc8a1ae300c81c0597a3aa02de /test/ValidateOptions.py
parentc80cbb0846c5d9265f356e86c4e79f1d13e3e8a8 (diff)
downloadscons-git-6ce33bdadec1cf558a6d0df27a6a083516d6cf23.tar.gz
Minor cleanup ValidateOptions doc/code/test
Some nearby things in Main.py as well: - docstrings polished a bit, minor linting - move the list of predefined SConstruct file names into a constant defined at the top of the file, so it's a little less hidden, in the unlikely case of future changes. Manpage text and example revised a bit. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/ValidateOptions.py')
-rw-r--r--test/ValidateOptions.py64
1 files changed, 43 insertions, 21 deletions
diff --git a/test/ValidateOptions.py b/test/ValidateOptions.py
index 9b53c0949..5dff386e2 100644
--- a/test/ValidateOptions.py
+++ b/test/ValidateOptions.py
@@ -28,38 +28,60 @@ Test ValidateOptions().
import TestSCons
test = TestSCons.TestSCons()
+# ref: test/fixture/SConstruct-check-valid-options
test.file_fixture('fixture/SConstruct-check-valid-options', 'SConstruct')
-# Should see "This is in SConstruct" because all options specified (none) are valid and
-# so ValidatedOptions() won't exit before it's printed.
+# Should see "This is in SConstruct" because all options specified (none)
+# are valid and so ValidatedOptions() won't exit before it's printed.
test.run()
test.must_contain_single_instance_of(test.stdout(), ["This is in SConstruct"])
-# Should see "This is in SConstruct" because all options specified (--testing=abc) are valid and
-# so ValidatedOptions() won't exit before it's printed.
+# Should see "This is in SConstruct" because all options specified
+# (--testing=abc) are valid and so ValidatedOptions() won't exit before
+# it's printed.
test.run(arguments="--testing=abc")
test.must_contain_single_instance_of(test.stdout(), ["This is in SConstruct"])
-# Should not see "This is in SConstruct" because the option specified (--garbage=xyz) is invalid and
-# so ValidatedOptions() will exit before it's printed.
-test.run(arguments="--garbage=xyz", status=2, stderr=".*SCons Error: no such option: --garbage.*",
- match=TestSCons.match_re_dotall)
-test.fail_test(("This is in SConstruct" in test.stdout()),
- message='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed')
+# Should not see "This is in SConstruct" because the option specified
+# (--garbage=xyz) is invalid and so ValidatedOptions() will exit
+# before it's printed.
+test.run(
+ arguments="--garbage=xyz",
+ status=2,
+ stderr=".*SCons Error: no such option: --garbage.*",
+ match=TestSCons.match_re_dotall,
+)
+test.fail_test(
+ ("This is in SConstruct" in test.stdout()),
+ message='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed',
+)
# Now we'll test having ValidateOptions raise a SConsBadOptionError exception
-test.run(arguments="--garbage=xyz raise=1", status=2,
- stderr=".*SConsBadOptionError: no such option: no such option: --garbage.*",
- match=TestSCons.match_re_dotall)
-test.fail_test(("This is in SConstruct" in test.stdout()),
- message='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed')
+test.run(
+ arguments="--garbage=xyz raise=1",
+ status=2,
+ stderr=".*SConsBadOptionError: no such option: no such option: --garbage.*",
+ match=TestSCons.match_re_dotall,
+)
+test.fail_test(
+ ("This is in SConstruct" in test.stdout()),
+ message='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed',
+)
-# Now we'll test having ValidateOptions raise a SConsBadOptionError exception and catching that exception
-test.run(arguments="--garbage=xyz raise=2", status=3,
- stdout=".*Parser is SConsOptionParser:True.*Message is .no such option. --garbage.*",
- match=TestSCons.match_re_dotall)
-test.fail_test(("This is in SConstruct" in test.stdout()),
- message='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed')
+# Now we'll test having ValidateOptions raise a SConsBadOptionError
+# exception and catching that exception
+test.run(
+ arguments="--garbage=xyz raise=2",
+ status=3,
+ stdout=".*Parser is SConsOptionParser: True.*Message is. no such option. --garbage.*",
+ match=TestSCons.match_re_dotall,
+)
+test.fail_test(
+ ("This is in SConstruct" in test.stdout()),
+ message='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed',
+)
+
+test.pass_test()
# Local Variables:
# tab-width:4