mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
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"
This commit is contained in:
parent
23d4e2b3c9
commit
180c382de2
3 changed files with 24 additions and 8 deletions
|
@ -5,8 +5,8 @@ import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import atexit
|
import atexit
|
||||||
import unittest
|
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 .exceptions import CommandError
|
||||||
from .hooks import Hooks
|
from .hooks import Hooks
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class Task(object):
|
||||||
|
|
||||||
A taskw client should not be used after being destroyed.
|
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):
|
def __init__(self, taskd=None, taskw=DEFAULT_TASK):
|
||||||
"""Initialize a Task warrior (client) that can interact with a taskd
|
"""Initialize a Task warrior (client) that can interact with a taskd
|
||||||
|
|
|
@ -8,7 +8,8 @@ import atexit
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
from .utils import (find_unused_port, release_port, port_used, run_cmd_wait,
|
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
|
from .exceptions import CommandError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -30,7 +31,7 @@ class Taskd(object):
|
||||||
A server can be stopped and started multiple times, but should not be
|
A server can be stopped and started multiple times, but should not be
|
||||||
started or stopped after being destroyed.
|
started or stopped after being destroyed.
|
||||||
"""
|
"""
|
||||||
DEFAULT_TASKD = binary_location("taskd")
|
DEFAULT_TASKD = taskd_binary_location()
|
||||||
|
|
||||||
def __init__(self, taskd=DEFAULT_TASKD, certpath=None,
|
def __init__(self, taskd=DEFAULT_TASKD, certpath=None,
|
||||||
address="localhost"):
|
address="localhost"):
|
||||||
|
|
|
@ -41,13 +41,28 @@ DEFAULT_HOOK_PATH = os.path.abspath(
|
||||||
TASKW_SKIP = os.environ.get("TASKW_SKIP", False)
|
TASKW_SKIP = os.environ.get("TASKW_SKIP", False)
|
||||||
TASKD_SKIP = os.environ.get("TASKD_SKIP", False)
|
TASKD_SKIP = os.environ.get("TASKD_SKIP", False)
|
||||||
# Environment flags to control use of PATH or in-tree binaries
|
# 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}")
|
UUID_regex = ("[0-9A-Fa-f]{8}-" + ("[0-9A-Fa-f]{4}-" * 3) + "[0-9A-Fa-f]{12}")
|
||||||
|
|
||||||
|
|
||||||
def binary_location(cmd):
|
def task_binary_location(cmd="task"):
|
||||||
"""If USE_PATH is set rely on PATH to look for task/taskd binaries.
|
"""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.
|
Otherwise ../src/ is used by default.
|
||||||
"""
|
"""
|
||||||
if USE_PATH:
|
if USE_PATH:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue