msys2's Python package version 3.8.1-1 produces wrong output for
PureWindowsPath's string representation. It does this:
>>> import pathlib
>>> str(pathlib.PureWindowsPath('/yo/madame'))
'/yo/madame'
When it should do this:
>>> import pathlib
>>> str(pathlib.PureWindowsPath('/yo/madame'))
'\\yo\\madame'
Because of this, tests/plugins/src.ctf.fs/query/test_query_trace_info.py
is currently failing, as the Babeltrace output contains back-slashes but
the regex we produce contains forward-slashes.
The issue appears to be fixed in 3.8.1-2:
https://github.com/msys2/MINGW-packages/commit/
7ce8394ec8af3bdef83d1a24fd9a96bf8da3c154#diff-
8b71128fa8f1e4e070196eeb2fc9a19d
But anyway, it's not really necessary to use PureWindowsPath and
PurePosixPath. I changed the code to just use a version of the regex
with back-slashes when on Windows, and with front-slashes when on the
others.
Change-Id: Idcd865d87350682644a536ada95cfac161cc1182
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2733
Tested-by: jenkins <jenkins@lttng.org>
import bt2
import os
import re
import bt2
import os
import re
-from pathlib import PureWindowsPath, PurePosixPath
test_ctf_traces_path = os.environ['BT_CTF_TRACES_PATH']
test_ctf_traces_path = os.environ['BT_CTF_TRACES_PATH']
- os_stream_path = PurePosixPath(
- '/tests/data/ctf-traces/intersection/3eventsintersect/'
- )
if os.environ['BT_OS_TYPE'] == 'mingw':
if os.environ['BT_OS_TYPE'] == 'mingw':
- os_stream_path = PureWindowsPath(os_stream_path)
+ os_stream_path = (
+ '\\tests\\data\\ctf-traces\\intersection\\3eventsintersect\\'
+ )
+ else:
+ os_stream_path = '/tests/data/ctf-traces/intersection/3eventsintersect/'
self.assertEqual(len(res), 1)
trace = res[0]
self.assertEqual(len(res), 1)
trace = res[0]
self.assertRegex(
str(streams[0]["port-name"]),
r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
self.assertRegex(
str(streams[0]["port-name"]),
r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
- + re.escape(str(os_stream_path / "test_stream_0"))
+ + re.escape(os_stream_path + "test_stream_0")
+ r"$",
)
self.assertRegex(
str(streams[1]["port-name"]),
r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
+ r"$",
)
self.assertRegex(
str(streams[1]["port-name"]),
r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
- + re.escape(str(os_stream_path / "test_stream_1"))
+ + re.escape(os_stream_path + "test_stream_1")
{"inputs": [os.path.join(test_ctf_traces_path, "succeed", "succeed1")]},
).query()
{"inputs": [os.path.join(test_ctf_traces_path, "succeed", "succeed1")]},
).query()
- os_stream_path = PurePosixPath(
- '/tests/data/ctf-traces/succeed/succeed1/dummystream'
- )
if os.environ['BT_OS_TYPE'] == 'mingw':
if os.environ['BT_OS_TYPE'] == 'mingw':
- os_stream_path = PureWindowsPath(os_stream_path)
+ os_stream_path = '\\tests\\data\\ctf-traces\\succeed\\succeed1\\dummystream'
+ else:
+ os_stream_path = '/tests/data/ctf-traces/succeed/succeed1/dummystream'
self.assertEqual(len(res), 1)
trace = res[0]
self.assertEqual(len(res), 1)
trace = res[0]
self.assertRegex(
str(streams[0]["port-name"]),
r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*"
self.assertRegex(
str(streams[0]["port-name"]),
r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*"
- + re.escape(str(os_stream_path))
+ + re.escape(os_stream_path)