From: Tomi Ollila Date: Wed, 25 May 2016 21:37:41 +0000 (+0300) Subject: [PATCH 2/2] test: test_python: set PYTHONPATH to the python execution environment X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fe8167feaac6b3a0f0ebae0c9ac60ee8b3248ce6;p=notmuch-archives.git [PATCH 2/2] test: test_python: set PYTHONPATH to the python execution environment --- diff --git a/0f/b9a28695c016d128958a49179507fd1c760f79 b/0f/b9a28695c016d128958a49179507fd1c760f79 new file mode 100644 index 000000000..6960afe20 --- /dev/null +++ b/0f/b9a28695c016d128958a49179507fd1c760f79 @@ -0,0 +1,83 @@ +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 E9A1E6DE00EB + for ; Wed, 25 May 2016 14:37:54 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.255 +X-Spam-Level: +X-Spam-Status: No, score=0.255 tagged_above=-999 required=5 tests=[AWL=0.264, + 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 XeoJVzaoPPst for ; + Wed, 25 May 2016 14:37:47 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 14F8B6DE01F7 + for ; Wed, 25 May 2016 14:37:47 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 2D7101000DF; Thu, 26 May 2016 00:37:43 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Cc: tomi.ollila@iki.fi +Subject: [PATCH 2/2] test: test_python: set PYTHONPATH to the python execution + environment +Date: Thu, 26 May 2016 00:37:41 +0300 +Message-Id: <1464212261-26892-2-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 2.8.2 +In-Reply-To: <1464212261-26892-1-git-send-email-tomi.ollila@iki.fi> +References: <1464212261-26892-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: Wed, 25 May 2016 21:37:55 -0000 + +Place PYTHONPATH to the environment when python is executed in a way +that current shell environment is not affected. This also allows adding +the old value of PYTHONPATH to the end of the new value (otherwise it +would have been appended 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. +--- + 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 a7e6397c324e..ec2da0b7151c 100644 +--- a/test/test-lib.sh ++++ b/test/test-lib.sh +@@ -1171,10 +1171,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.8.2 +