From 180c382de27ea8ab4a2793168c88396fafeebf1d Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Tue, 3 Mar 2015 01:46:53 +0000 Subject: [PATCH] Tests - Finer control on which binaries to look for on PATH * It is now possible to control whether taskw and/or taskd are looked up on the PATH by setting TASK_USE_PATH/TASKD_USE_PATH to "1" --- test/basetest/task.py | 6 +++--- test/basetest/taskd.py | 5 +++-- test/basetest/utils.py | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/test/basetest/task.py b/test/basetest/task.py index 73c0d2af0..cf13465ce 100644 --- a/test/basetest/task.py +++ b/test/basetest/task.py @@ -5,8 +5,8 @@ import tempfile import shutil import atexit import unittest -from .utils import (run_cmd_wait, run_cmd_wait_nofail, which, binary_location, - ) +from .utils import (run_cmd_wait, run_cmd_wait_nofail, which, + task_binary_location) from .exceptions import CommandError from .hooks import Hooks @@ -22,7 +22,7 @@ class Task(object): A taskw client should not be used after being destroyed. """ - DEFAULT_TASK = binary_location("task") + DEFAULT_TASK = task_binary_location() def __init__(self, taskd=None, taskw=DEFAULT_TASK): """Initialize a Task warrior (client) that can interact with a taskd diff --git a/test/basetest/taskd.py b/test/basetest/taskd.py index 209ae7da8..50f56ac9f 100644 --- a/test/basetest/taskd.py +++ b/test/basetest/taskd.py @@ -8,7 +8,8 @@ import atexit from time import sleep from subprocess import Popen from .utils import (find_unused_port, release_port, port_used, run_cmd_wait, - which, parse_datafile, DEFAULT_CERT_PATH, binary_location) + which, parse_datafile, DEFAULT_CERT_PATH, + taskd_binary_location) from .exceptions import CommandError try: @@ -30,7 +31,7 @@ class Taskd(object): A server can be stopped and started multiple times, but should not be started or stopped after being destroyed. """ - DEFAULT_TASKD = binary_location("taskd") + DEFAULT_TASKD = taskd_binary_location() def __init__(self, taskd=DEFAULT_TASKD, certpath=None, address="localhost"): diff --git a/test/basetest/utils.py b/test/basetest/utils.py index b644ddd3f..8bc321158 100644 --- a/test/basetest/utils.py +++ b/test/basetest/utils.py @@ -41,13 +41,28 @@ DEFAULT_HOOK_PATH = os.path.abspath( TASKW_SKIP = os.environ.get("TASKW_SKIP", False) TASKD_SKIP = os.environ.get("TASKD_SKIP", False) # Environment flags to control use of PATH or in-tree binaries -USE_PATH = os.environ.get("USE_PATH", False) +TASK_USE_PATH = os.environ.get("TASK_USE_PATH", False) +TASKD_USE_PATH = os.environ.get("TASKD_USE_PATH", False) UUID_regex = ("[0-9A-Fa-f]{8}-" + ("[0-9A-Fa-f]{4}-" * 3) + "[0-9A-Fa-f]{12}") -def binary_location(cmd): - """If USE_PATH is set rely on PATH to look for task/taskd binaries. +def task_binary_location(cmd="task"): + """If TASK_USE_PATH is set rely on PATH to look for task binaries. + Otherwise ../src/ is used by default. + """ + return binary_location(cmd, TASK_USE_PATH) + + +def taskd_binary_location(cmd="taskd"): + """If TASKD_USE_PATH is set rely on PATH to look for taskd binaries. + Otherwise ../src/ is used by default. + """ + return binary_location(cmd, TASKD_USE_PATH) + + +def binary_location(cmd, USE_PATH=False): + """If USE_PATH is True rely on PATH to look for taskd binaries. Otherwise ../src/ is used by default. """ if USE_PATH: