summaryrefslogtreecommitdiffstats
path: root/python/mozbuild/mozbuild/test/test_line_endings.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /python/mozbuild/mozbuild/test/test_line_endings.py
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'python/mozbuild/mozbuild/test/test_line_endings.py')
-rw-r--r--python/mozbuild/mozbuild/test/test_line_endings.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/python/mozbuild/mozbuild/test/test_line_endings.py b/python/mozbuild/mozbuild/test/test_line_endings.py
new file mode 100644
index 0000000000..f8cdd89174
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/test_line_endings.py
@@ -0,0 +1,45 @@
+import unittest
+
+import mozunit
+from mozfile import NamedTemporaryFile
+from six import StringIO
+
+from mozbuild.preprocessor import Preprocessor
+
+
+class TestLineEndings(unittest.TestCase):
+ """
+ Unit tests for the Context class
+ """
+
+ def setUp(self):
+ self.pp = Preprocessor()
+ self.pp.out = StringIO()
+ self.f = NamedTemporaryFile(mode="wb")
+
+ def tearDown(self):
+ self.f.close()
+
+ def createFile(self, lineendings):
+ for line, ending in zip([b"a", b"#literal b", b"c"], lineendings):
+ self.f.write(line + ending)
+ self.f.flush()
+
+ def testMac(self):
+ self.createFile([b"\x0D"] * 3)
+ self.pp.do_include(self.f.name)
+ self.assertEqual(self.pp.out.getvalue(), "a\nb\nc\n")
+
+ def testUnix(self):
+ self.createFile([b"\x0A"] * 3)
+ self.pp.do_include(self.f.name)
+ self.assertEqual(self.pp.out.getvalue(), "a\nb\nc\n")
+
+ def testWindows(self):
+ self.createFile([b"\x0D\x0A"] * 3)
+ self.pp.do_include(self.f.name)
+ self.assertEqual(self.pp.out.getvalue(), "a\nb\nc\n")
+
+
+if __name__ == "__main__":
+ mozunit.main()