Merge lp:~fullermd/brz/silence-git-apply-test into lp:brz

Proposed by Matthew Fuller
Status: Rejected
Rejected by: Jelmer Vernooij
Proposed branch: lp:~fullermd/brz/silence-git-apply-test
Merge into: lp:brz
Diff against target: 25 lines (+14/-0)
1 file modified
breezy/git/tests/test_blackbox.py (+14/-0)
To merge this branch: bzr merge lp:~fullermd/brz/silence-git-apply-test
Reviewer Review Type Date Requested Status
Jelmer Vernooij Needs Fixing
Review via email: mp+365006@code.launchpad.net

Commit message

Silence output from patch(1) in git-apply test.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I think we'd actually want to fix this further upstream and just pass stdout=self.outf in cmd_git_apply_patch.run().

That way, we don't have to muck about with dup2, which will inevitably break on Windows.

review: Needs Fixing
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Proposed an alternative here that should work on Windows https://code.launchpad.net/~jelmer/brz/patch-silent/+merge/365620

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Marking this as rejected since we've landed an alternative fix that will also work on Windows.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks for reporting the bug and the original MP!

Unmerged revisions

7296. By Matthew Fuller

Silence output from patch(1) in git-apply test.

The test suite stubs in stdout/err wrappers for the python code, but
doesn't mess with the underlying file descriptors, so spawned off
processes still get the terminal. cmd_git_apply._apply_patch() uses
subprocess to spawn off the system patch(1) to do the application, and
patch talks a lot about what it's doing. While patch has a -s arg to
quiet it down, we probably want it speaking a lot in normal use so the
user can see what's going on, so just switch stdout to /dev/null
around the run_bzr call in the test instead.

An argument could be made that the test suite as a whole should be
better about moving the fd's so subprocesses can't hit the terminal
directly, but for the moment, this seems to be the only test where it
matters.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/tests/test_blackbox.py'
2--- breezy/git/tests/test_blackbox.py 2019-02-17 04:08:56 +0000
3+++ breezy/git/tests/test_blackbox.py 2019-03-24 21:04:11 +0000
4@@ -493,7 +493,21 @@
5 +Certainty: certain
6 +Fixed-Lintian-Tags: out-of-date-standards-version
7 """)
8+
9+ # git-apply shells out to patch(1) with subprocess, which
10+ # splatters the screen. Fake up stdout so the subprocess's
11+ # output is silenced.
12+ import sys, os
13+ stdout_fd = sys.stdout.fileno()
14+ saved_stdout = os.dup(stdout_fd)
15+ devnull = os.open(os.devnull, os.O_WRONLY)
16+
17+ sys.stdout.flush()
18+ os.dup2(devnull, stdout_fd)
19 output, error = self.run_bzr('git-apply foo.patch')
20+ sys.stdout.flush()
21+ os.dup2(saved_stdout, stdout_fd)
22+
23 self.assertContainsRe(
24 error,
25 'Committing to: .*\n'

Subscribers

People subscribed via source and target branches