From 4e907f1f62e2dc5676aeb48b99494709b7bf9d50 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 6 Jun 2019 10:31:03 +0200 Subject: [PATCH] Fix comment fixup in pro2cmake Comments should be removed before line continuations, otherwise the semantics of an assignment change. Found this during reconversion of qtimageformats. Adjust test to specifically test for all the expected values. Amends 76f5b784ce54730ed8d6ad4bb9c39c9a05c5d81d. Change-Id: Iaa46bbc9cbd7b2390fe9b5f0078ac33d225a9258 Reviewed-by: Simon Hausmann --- util/cmake/pro2cmake.py | 2 +- util/cmake/tests/test_parsing.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index bfd791a196..2eda9b69d3 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -870,8 +870,8 @@ class QmakeParser: contents = file_fd.read() old_contents = contents - contents = fixup_linecontinuation(contents) contents = fixup_comments(contents) + contents = fixup_linecontinuation(contents) if old_contents != contents: print('Warning: Fixed line continuation in .pro-file!\n' diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py index 11d1ed093f..f924b13913 100755 --- a/util/cmake/tests/test_parsing.py +++ b/util/cmake/tests/test_parsing.py @@ -308,6 +308,25 @@ def test_realworld_lc(): def test_realworld_lc_with_comment_in_between(): result = parse_file(_tests_path + '/data/lc_with_comment.pro') + + my_var = result[1]['value'][0] + assert my_var == 'foo' + + my_var = result[2]['value'][0] + assert my_var == 'foo2' + + my_var = result[3]['value'][0] + assert my_var == 'foo3' + + my_var = result[4]['value'][0] + assert my_var == 'foo4' + + my_var = result[5]['value'][0] + assert my_var == 'foo5' + + sub_dirs = result[0]['value'] + assert sub_dirs[0] == 'tga' + assert sub_dirs[1] == 'wbmp' assert len(result) == 6