mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 05:27:47 +02:00
Unittest - Implement faketime for use in taskw
This commit is contained in:
parent
02683aecd7
commit
15795e514d
1 changed files with 22 additions and 2 deletions
|
@ -29,6 +29,9 @@ class Task(object):
|
||||||
self.taskw = taskw
|
self.taskw = taskw
|
||||||
self.taskd = taskd
|
self.taskd = taskd
|
||||||
|
|
||||||
|
# Used to specify what command to launch (and to inject faketime)
|
||||||
|
self._command = [self.taskw]
|
||||||
|
|
||||||
# Configuration of the isolated environment
|
# Configuration of the isolated environment
|
||||||
self._original_pwd = os.getcwd()
|
self._original_pwd = os.getcwd()
|
||||||
self.datadir = tempfile.mkdtemp(prefix="task_")
|
self.datadir = tempfile.mkdtemp(prefix="task_")
|
||||||
|
@ -125,7 +128,8 @@ class Task(object):
|
||||||
|
|
||||||
Returns (exit_code, stdout, stderr)
|
Returns (exit_code, stdout, stderr)
|
||||||
"""
|
"""
|
||||||
command = [self.taskw]
|
# Create a copy of the command
|
||||||
|
command = self._command[:]
|
||||||
command.extend(args)
|
command.extend(args)
|
||||||
|
|
||||||
output = run_cmd_wait_nofail(command, input,
|
output = run_cmd_wait_nofail(command, input,
|
||||||
|
@ -150,7 +154,8 @@ class Task(object):
|
||||||
|
|
||||||
Returns (exit_code, stdout, stderr)
|
Returns (exit_code, stdout, stderr)
|
||||||
"""
|
"""
|
||||||
command = [self.taskw]
|
# Create a copy of the command
|
||||||
|
command = self._command[:]
|
||||||
command.extend(args)
|
command.extend(args)
|
||||||
|
|
||||||
output = run_cmd_wait_nofail(command, input,
|
output = run_cmd_wait_nofail(command, input,
|
||||||
|
@ -231,4 +236,19 @@ class Task(object):
|
||||||
|
|
||||||
return code, newout, newerr
|
return code, newout, newerr
|
||||||
|
|
||||||
|
def faketime(self, faketime=None):
|
||||||
|
"""Set a faketime using libfaketime that will affect the following
|
||||||
|
command calls.
|
||||||
|
|
||||||
|
If faketime is None, faketime settings will be disabled.
|
||||||
|
"""
|
||||||
|
cmd = "faketime"
|
||||||
|
|
||||||
|
if self._command[0] == cmd:
|
||||||
|
self._command = self._command[3:]
|
||||||
|
|
||||||
|
if faketime is not None:
|
||||||
|
# Use advanced time format
|
||||||
|
self._command = [cmd, "-f", faketime] + self._command
|
||||||
|
|
||||||
# vim: ai sts=4 et sw=4
|
# vim: ai sts=4 et sw=4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue