Skip to content

Commit

Permalink
Merge pull request #255 from byexamples/Issue-245-Turn-Echo-Off-on-ea…
Browse files Browse the repository at this point in the history
…ch-Exec-for-10.5.4

Issue 245 turn echo off on each exec for 10.5.4
  • Loading branch information
eldipa committed Jun 13, 2022
2 parents 3400cd6 + 66dc0d5 commit b99a8fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ modules-test: clean_test

docs-test: clean_test
@$(python_bin) -W error test/r.py @test/minimum.env -- *.md
@$(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`
@$(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`
@$(python_bin) -W error test/r.py @test/minimum.env docs/advanced/echo-filtering.md
@$(python_bin) -W error test/r.py @test/minimum.env -o '+py-doctest' docs/recipes/python-doctest.md
@$(python_bin) -m doctest docs/recipes/python-doctest.md
@make -s clean_test
Expand Down
2 changes: 1 addition & 1 deletion byexample/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''Write snippets of code in C++, Python, Ruby, and others as documentation and execute them as regression tests.'''

__version__ = "10.5.3"
__version__ = "10.5.4"

_author = 'Di Paola Martin'
_license = 'GNU GPLv3'
Expand Down
7 changes: 7 additions & 0 deletions byexample/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,13 @@ def parse_args(args=None):
help=
"delay in seconds after the prompt to capture more output; 0 disable this (default)."
)
g.add_argument(
"-x-turn-echo-off",
action='store_true',
default=False,
help=
"turn off the echo on each example execution (ignored if force-echo-filtering is on); (default: %(default)s)."
)
g.add_argument(
"-x-min-rcount",
metavar="<n>",
Expand Down
14 changes: 14 additions & 0 deletions byexample/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,17 @@ def _shutdown_interpreter(self):
who
)

def _may_turn_echo_off(self, options):
# If the echo-filtering is enabled, we must not turn off the echo
# of the child process (interpreter) otherwise, if the child
# really does not output the echo'd input, the echo-filtering
# algorithm will fail badly because no echo will be found.
if options['force_echo_filtering']:
return

if options['x']['turn_echo_off']:
self._interpreter.setecho(False)

@profile
def _exec_and_wait(self, source, options, *, from_example=None, **kargs):
if from_example is None:
Expand All @@ -444,6 +455,9 @@ def _exec_and_wait(self, source, options, *, from_example=None, **kargs):
# get a copy: _expect_prompt_or_type will modify this in-place
input_list = list(input_list)

# turn the echo off (may be)
self._may_turn_echo_off(options)

countdown = Countdown(timeout)
lines = source.split('\n')

Expand Down

0 comments on commit b99a8fb

Please sign in to comment.