Skip to content

Commit

Permalink
tests: enable debugruntest for test-pager.t
Browse files Browse the repository at this point in the history
Summary:
This test wasn't using `debugruntest` since it's one of those tests that shells out to Python for various things.

Making this work on Windows required a couple of changes, as non-debugruntest tests rely on having bash and bash-like utils for running:
- The test had to shell out and used the `echo` command for this. On Bash using `echo` is fine, but on Windows cmd's echo does not output a new line
- Like in D54347528, `$PYTHON` could no longer be used on things hg called
- Since the test was essentially running on Bash, the Python scripts this test was shelling out to could no longer use `sys.stdout.write`.
  - As this test was previously running essentially on Bash, the newlines from `sys.stdout.write` contained carriage returns
  - This was changed to use `hg dbsh` and `ui.write` instead

Reviewed By: muirdm

Differential Revision: D54826008

fbshipit-source-id: 16460ddd30dd8dc8a27ca66580ada8f50b774905
  • Loading branch information
sggutier authored and facebook-github-bot committed Mar 19, 2024
1 parent cb2ae40 commit d239119
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions eden/scm/tests/test-pager.t
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#debugruntest-compatible
#inprocess-hg-incompatible

$ eagerepo
$ setconfig devel.segmented-changelog-rev-compat=true
$ cat >> fakepager.py <<EOF
> import sys
> printed = False
> for line in sys.stdin:
> sys.stdout.write('paged! %r\n' % line)
> ui.write('paged! %r\n' % line)
> printed = True
> if not printed:
> sys.stdout.write('paged empty output!\n')
> ui.write('paged empty output!\n')
> EOF

Enable ui.assume-tty so that the pager will start, and set the pager to our
fake pager that lets us see when the pager was running.
$ setconfig ui.assume-tty=yes ui.color=no
$ cat >>$HGRCPATH <<EOF
> [pager]
> pager = $PYTHON $TESTTMP/fakepager.py
> pager = hg dbsh $TESTTMP/fakepager.py
> EOF

$ hg init repo
Expand Down Expand Up @@ -212,10 +215,19 @@ improve this.

Pager works with shell aliases.

#if windows
On Windows cmd's echo is used, which prints carriage returns, so we use hg instead

$ cat >> $HGRCPATH <<EOF
> [alias]
> echoa = !hg dbsh -c "ui.write('a\n')"
> EOF
#else
$ cat >> $HGRCPATH <<EOF
> [alias]
> echoa = !echo a
> EOF
#endif

$ hg echoa
a
Expand Down Expand Up @@ -343,13 +355,11 @@ During pushbuffer, pager should not start:

Environment variables like LESS and LV are set automatically:
$ cat > $TESTTMP/printlesslv.py <<EOF
> from __future__ import absolute_import
> import os
> import sys
> sys.stdin.read()
> for name in ['LESS', 'LV']:
> sys.stdout.write(('%s=%s\n') % (name, os.environ.get(name, '-')))
> sys.stdout.flush()
> ui.write(('%s=%s\n') % (name, os.environ.get(name, '-')))
> EOF

$ cat >> $HGRCPATH <<EOF
Expand All @@ -358,7 +368,7 @@ Environment variables like LESS and LV are set automatically:
> [ui]
> formatted=1
> [pager]
> pager = $PYTHON $TESTTMP/printlesslv.py
> pager = hg dbsh $TESTTMP/printlesslv.py
> EOF
$ unset LESS
$ unset LV
Expand Down

0 comments on commit d239119

Please sign in to comment.