From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- testing/mozharness/test/test_base_log.py | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 testing/mozharness/test/test_base_log.py (limited to 'testing/mozharness/test/test_base_log.py') diff --git a/testing/mozharness/test/test_base_log.py b/testing/mozharness/test/test_base_log.py new file mode 100644 index 0000000000..769cb1e390 --- /dev/null +++ b/testing/mozharness/test/test_base_log.py @@ -0,0 +1,43 @@ +import os +import shutil +import unittest + +import mozharness.base.log as log + +tmp_dir = "test_log_dir" +log_name = "test" + + +def clean_log_dir(): + if os.path.exists(tmp_dir): + shutil.rmtree(tmp_dir) + + +def get_log_file_path(level=None): + if level: + return os.path.join(tmp_dir, "%s_%s.log" % (log_name, level)) + return os.path.join(tmp_dir, "%s.log" % log_name) + + +class TestLog(unittest.TestCase): + def setUp(self): + clean_log_dir() + + def tearDown(self): + clean_log_dir() + + def test_log_dir(self): + fh = open(tmp_dir, "w") + fh.write("foo") + fh.close() + l = log.SimpleFileLogger( + log_dir=tmp_dir, log_name=log_name, log_to_console=False + ) + self.assertTrue(os.path.exists(tmp_dir)) + l.log_message("blah") + self.assertTrue(os.path.exists(get_log_file_path())) + del l + + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3