gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / python-robotframework-source-date-epoch.patch
CommitLineData
b9790285
MC
1From 3cc41c05fad5601c0dd1832f64a6e9efca017727 Mon Sep 17 00:00:00 2001
2From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
3Date: Mon, 1 Apr 2019 11:36:04 -0400
4Subject: [PATCH] robottime: Honor the SOURCE_DATE_EPOCH environment variable.
5
6Honoring the SOURCE_DATE_EPOCH environment variable allows building
7the documentation using libdoc reproducibly, by setting the generated
8timestamp to a fixed value.
9
10For more background on reproducible builds and the SOURCE_DATE_EPOCH
11environment variable, see:
12https://reproducible-builds.org/specs/source-date-epoch/.
13
14* src/robot/utils/robottime.py: import `os'.
15(TimestampCache._get_epoch): Retrieve date from SOURCE_DATE_EPOCH if
16it is defined, otherwise from time.time().
17* utest/output/test_logger.py (TestLogger.test_write_to_one_logger):
18Check for the existance of a timestamp attribute instead of checking
19for its content as the later is easy to break when using the
20SOURCE_DATE_EPOCH environment variable.
21---
22 src/robot/utils/robottime.py | 3 +++
23 utest/output/test_logger.py | 2 +-
24 2 files changed, 4 insertions(+), 1 deletion(-)
25
26diff --git a/src/robot/utils/robottime.py b/src/robot/utils/robottime.py
27index 06432a4a6..91526f826 100644
28--- a/src/robot/utils/robottime.py
29+++ b/src/robot/utils/robottime.py
30@@ -14,6 +14,7 @@
31 # limitations under the License.
32
33 import datetime
34+import os
35 import time
36 import re
37
38@@ -395,6 +396,8 @@ class TimestampCache(object):
39
40 # Seam for mocking
41 def _get_epoch(self):
42+ if os.getenv('SOURCE_DATE_EPOCH'):
43+ return float(os.getenv('SOURCE_DATE_EPOCH'))
44 return time.time()
45
46 def _use_cache(self, secs, *separators):
47diff --git a/utest/output/test_logger.py b/utest/output/test_logger.py
48index 92fe6d77d..e980227aa 100644
49--- a/utest/output/test_logger.py
50+++ b/utest/output/test_logger.py
51@@ -46,7 +46,7 @@ class TestLogger(unittest.TestCase):
52 logger = LoggerMock(('Hello, world!', 'INFO'))
53 self.logger.register_logger(logger)
54 self.logger.write('Hello, world!', 'INFO')
55- assert_true(logger.msg.timestamp.startswith('20'))
56+ assert_true(hasattr(logger.msg, 'timestamp'))
57
58 def test_write_to_one_logger_with_trace_level(self):
59 logger = LoggerMock(('expected message', 'TRACE'))
60--
612.20.1
62