Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id CEC3E6DE00F5 for ; Fri, 15 Apr 2016 14:18:29 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.28 X-Spam-Level: X-Spam-Status: No, score=0.28 tagged_above=-999 required=5 tests=[AWL=0.289, HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I84KnNaVcBPh for ; Fri, 15 Apr 2016 14:18:21 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id D15326DE00EB for ; Fri, 15 Apr 2016 14:18:20 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 4F424100104; Sat, 16 Apr 2016 00:18:15 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org Cc: tomi.ollila@iki.fi Subject: [PATCH] test: test_python: set PYTHONPATH for the duration python is executed Date: Sat, 16 Apr 2016 00:18:14 +0300 Message-Id: <1460755094-22088-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1460738800-9021-1-git-send-email-tomi.ollila@iki.fi> References: <1460738800-9021-1-git-send-email-tomi.ollila@iki.fi> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2016 21:18:29 -0000 Set PYTHONPATH for the duration python is executed so environment is not changed. This also allows appending the old value of PYTHONPATH to it in case it is set (otherwise it would have been append again and again when test_python is called). At the same time, use -B option to avoid writing .pyc files to bindings/python/* (which are not cleared out by distclean). Drop the (unused) prefix code which preserved the original stdout of the python program and opened sys.stdout to OUTPUT. In place of that there is now note how (debug) information can be printed to original stdout. --- when doing LD_LIBRARY_PATH this kept irritating me -- and it looks like this is the last place where environment is changed (using export) in mid-execution. test/test-lib.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 562fde7b8878..5560a9dac3db 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -1164,10 +1164,10 @@ test_emacs () { } test_python() { - export PYTHONPATH=$TEST_DIRECTORY/../bindings/python - - (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \ - | $NOTMUCH_PYTHON - + # Note: if there is need to print debug information from python program, + # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w') + PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \ + $NOTMUCH_PYTHON -B - > OUTPUT } test_ruby() { -- 2.6.4