Skip to content

Commit b99a8fb

Browse files
authored
Merge pull request #255 from byexamples/Issue-245-Turn-Echo-Off-on-each-Exec-for-10.5.4
Issue 245 turn echo off on each exec for 10.5.4
2 parents 3400cd6 + 66dc0d5 commit b99a8fb

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ modules-test: clean_test
9090

9191
docs-test: clean_test
9292
@$(python_bin) -W error test/r.py @test/minimum.env -- *.md
93-
@$(python_bin) -W error test/r.py @test/minimum.env --skip docs/recipes/python-doctest.md -- `find docs \( -name languages -prune -o -name "*.md" \) -type f`
93+
@$(python_bin) -W error test/r.py @test/minimum.env -x-turn-echo-off --skip docs/advanced/echo-filtering.md docs/recipes/python-doctest.md -- `find docs \( -name languages -prune -o -name "*.md" \) -type f`
94+
@$(python_bin) -W error test/r.py @test/minimum.env docs/advanced/echo-filtering.md
9495
@$(python_bin) -W error test/r.py @test/minimum.env -o '+py-doctest' docs/recipes/python-doctest.md
9596
@$(python_bin) -m doctest docs/recipes/python-doctest.md
9697
@make -s clean_test

byexample/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''Write snippets of code in C++, Python, Ruby, and others as documentation and execute them as regression tests.'''
22

3-
__version__ = "10.5.3"
3+
__version__ = "10.5.4"
44

55
_author = 'Di Paola Martin'
66
_license = 'GNU GPLv3'

byexample/cmdline.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,13 @@ def parse_args(args=None):
520520
help=
521521
"delay in seconds after the prompt to capture more output; 0 disable this (default)."
522522
)
523+
g.add_argument(
524+
"-x-turn-echo-off",
525+
action='store_true',
526+
default=False,
527+
help=
528+
"turn off the echo on each example execution (ignored if force-echo-filtering is on); (default: %(default)s)."
529+
)
523530
g.add_argument(
524531
"-x-min-rcount",
525532
metavar="<n>",

byexample/runner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,17 @@ def _shutdown_interpreter(self):
432432
who
433433
)
434434

435+
def _may_turn_echo_off(self, options):
436+
# If the echo-filtering is enabled, we must not turn off the echo
437+
# of the child process (interpreter) otherwise, if the child
438+
# really does not output the echo'd input, the echo-filtering
439+
# algorithm will fail badly because no echo will be found.
440+
if options['force_echo_filtering']:
441+
return
442+
443+
if options['x']['turn_echo_off']:
444+
self._interpreter.setecho(False)
445+
435446
@profile
436447
def _exec_and_wait(self, source, options, *, from_example=None, **kargs):
437448
if from_example is None:
@@ -444,6 +455,9 @@ def _exec_and_wait(self, source, options, *, from_example=None, **kargs):
444455
# get a copy: _expect_prompt_or_type will modify this in-place
445456
input_list = list(input_list)
446457

458+
# turn the echo off (may be)
459+
self._may_turn_echo_off(options)
460+
447461
countdown = Countdown(timeout)
448462
lines = source.split('\n')
449463

0 commit comments

Comments
 (0)