diff options
author | Phil Dawson <phil.dawson@codethink.co.uk> | 2018-07-18 10:24:52 +0100 |
---|---|---|
committer | Phil Dawson <phil.dawson@codethink.co.uk> | 2018-08-01 09:05:45 +0100 |
commit | bf8c3dfb2b0b8671e83cd64fae59f1764061f19b (patch) | |
tree | a853c1fb9b4d235815925dc3ea0c6ffaf93ad35f | |
parent | dc60b71303eb9f69d32be7874fd3fefbe841dc30 (diff) | |
download | buildstream-bf8c3dfb2b0b8671e83cd64fae59f1764061f19b.tar.gz |
testutils/patch.py: Add methods for applying and removing patches
-rw-r--r-- | tests/testutils/patch.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/testutils/patch.py b/tests/testutils/patch.py new file mode 100644 index 000000000..df287f374 --- /dev/null +++ b/tests/testutils/patch.py @@ -0,0 +1,21 @@ +import subprocess + + +def apply(file, patch): + try: + subprocess.check_output(['patch', file, patch]) + except subprocess.CalledProcessError as e: + message = "Patch failed with exit code {}\n Output:\n {}".format( + e.returncode, e.output) + print(message) + raise + + +def remove(file, patch): + try: + subprocess.check_output(['patch', '--reverse', file, patch]) + except subprocess.CalledProcessError as e: + message = "patch --reverse failed with exit code {}\n Output:\n {}".format( + e.returncode, e.output) + print(message) + raise |