`test_query_trace_info.py`: adapt regex to NT path style
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 15 Jul 2019 21:49:56 +0000 (17:49 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 20 Jul 2019 13:25:42 +0000 (09:25 -0400)
In a MinGW 64 test environment, the stream path is expressed using NT
path (`C:\\...`). In `test_query_trace_info.py`, adapt the regex
accordingly using Python's `pathlib` API.

Change-Id: Ieee3b9cac0881aec7086cef69ecf681ad71c0722
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1708
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/plugins/src.ctf.fs/query/test_query_trace_info.py

index c1e87e3976de29e1402f39529b6cc366eb6e8a61..a63fe04f1f86ca14eb374157b1ba42617be24747 100644 (file)
@@ -18,6 +18,7 @@ import unittest
 import bt2
 import os
 import re
+from pathlib import PureWindowsPath, PurePosixPath
 
 
 test_ctf_traces_path = os.environ['BT_CTF_TRACES_PATH']
@@ -152,17 +153,28 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase):
                 ]
             },
         )
+
+        os_stream_path = PurePosixPath(
+            '/tests/data/ctf-traces/intersection/3eventsintersect/'
+        )
+        if os.environ['BT_OS_TYPE'] == 'mingw':
+            os_stream_path = PureWindowsPath(os_stream_path)
+
         self.assertEqual(len(res), 1)
         trace = res[0]
         streams = sorted(trace["streams"], key=sort_predictably)
         self.assertEqual(len(streams), 2)
         self.assertRegexpMatches(
             str(streams[0]["port-name"]),
-            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*/tests/data/ctf-traces/intersection/3eventsintersect/test_stream_0$",
+            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
+            + re.escape(str(os_stream_path / "test_stream_0"))
+            + r"$",
         )
         self.assertRegexpMatches(
             str(streams[1]["port-name"]),
-            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*/tests/data/ctf-traces/intersection/3eventsintersect/test_stream_1$",
+            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
+            + re.escape(str(os_stream_path / "test_stream_1"))
+            + r"$",
         )
 
     def test_trace_uuid_no_stream_class_id_no_stream_id(self):
@@ -171,13 +183,22 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase):
             "trace-info",
             {"paths": [os.path.join(test_ctf_traces_path, "succeed", "succeed1")]},
         )
+
+        os_stream_path = PurePosixPath(
+            '/tests/data/ctf-traces/succeed/succeed1/dummystream'
+        )
+        if os.environ['BT_OS_TYPE'] == 'mingw':
+            os_stream_path = PureWindowsPath(os_stream_path)
+
         self.assertEqual(len(res), 1)
         trace = res[0]
         streams = sorted(trace["streams"], key=sort_predictably)
         self.assertEqual(len(streams), 1)
         self.assertRegexpMatches(
             str(streams[0]["port-name"]),
-            r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*/tests/data/ctf-traces/succeed/succeed1/dummystream$",
+            r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*"
+            + re.escape(str(os_stream_path))
+            + r"$",
         )
 
 
This page took 0.025361 seconds and 4 git commands to generate.