summaryrefslogtreecommitdiffstats
path: root/util/cmake/tests/test_parsing.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-10-07 08:38:08 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2022-02-28 15:41:11 +0100
commit2389aaf8c754c78464f27cf480e22a41a89de1b0 (patch)
treefe330ef8f5778ada633bbae76ce1b13ced11fc91 /util/cmake/tests/test_parsing.py
parent6708fad936319eba56577ad76620a8a72f78ccdb (diff)
pro2cmake: Handle qmake condition operator precedence
Unfortunately qmake does not have operator precedence in conditions, and each sub-expression is simply evaluated left to right. So c1|c2:c3 is evaluated as (c1|c2):c3 and not c1|(c2:c3). To handle that in pro2cmake, wrap each condition sub-expression in parentheses. It's ugly, but there doesn't seem to be another way of handling it, because SymPy uses Python operator precedence for condition operators, and it's not possible to change the precendece. Fixes: QTBUG-78929 Change-Id: I6ab767c4243e3f2d0fea1c36cd004409faba3a53 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util/cmake/tests/test_parsing.py')
-rwxr-xr-xutil/cmake/tests/test_parsing.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py
index 02ca7f8ae44..bd784edd860 100755
--- a/util/cmake/tests/test_parsing.py
+++ b/util/cmake/tests/test_parsing.py
@@ -28,7 +28,9 @@
#############################################################################
import os
+from pro2cmake import map_condition
from qmake_parser import QmakeParser
+from condition_simplifier import simplify_condition
_tests_path = os.path.dirname(os.path.abspath(__file__))
@@ -352,3 +354,15 @@ def test_value_function():
assert target == 'Dummy'
value = result[1]['value']
assert value[0] == '$$TARGET'
+
+
+def test_condition_operator_precedence():
+ result = parse_file(_tests_path + '/data/condition_operator_precedence.pro')
+
+ def validate_simplify(input_str: str, expected: str) -> None:
+ output = simplify_condition(map_condition(input_str))
+ assert output == expected
+
+ validate_simplify(result[0]["condition"], "a1 OR a2")
+ validate_simplify(result[1]["condition"], "b3 AND (b1 OR b2)")
+ validate_simplify(result[2]["condition"], "c4 OR (c1 AND c3) OR (c2 AND c3)")