Skip to content

Commit

Permalink
Resolve parsing error in QFace annotations due to missing space betwe…
Browse files Browse the repository at this point in the history
…en key and value

Corrected the parsing logic to handle missing spaces in annotations.
Updated tests to ensure compatibility and correctness on Windows.

Task-number: QTBUG-129592
  • Loading branch information
ShvMittal authored and Gagi2k committed Oct 24, 2024
1 parent 810238f commit 4a77e9a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/in/com.pelagicore.ivi.tuner.qface
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface BaseTuner {
/** Service Tuner */
@service: true
@interface: true
@config: {private: true, b: B, c: C}
@config: {private: true, b: B, c: C, d:D}
@data: [1,2,3]
interface Tuner extends BaseTuner {
/** property currentStation */
Expand Down
8 changes: 6 additions & 2 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def test_error_template_syntax_error(mock_stderr):
generator.write(dst_template, 'syntaxError.txt', ctx)
path = generator.apply(dst_template, ctx)
assert Path(path).exists() == False
assert mock_stderr.getvalue() == "tests/templates/syntaxError.txt:1: error: Encountered unknown tag 'fooo'.\n"
expected_error = "tests/templates/syntaxError.txt:1: error: Encountered unknown tag 'fooo'.\n"
actual_output = mock_stderr.getvalue().replace("\\", "/") # Normalize backslashes
assert expected_error in actual_output, f"Expected error not found. Expected: {expected_error}, Actual: {actual_output}"

@patch('sys.stderr', new_callable=StringIO)
def test_error_template_undefined_variable(mock_stderr):
Expand All @@ -127,7 +129,9 @@ def test_error_template_undefined_variable(mock_stderr):
generator.write(dst_template, 'undefinedVariable.txt', ctx)
path = generator.apply(dst_template, ctx)
assert Path(path).exists() == False
assert mock_stderr.getvalue() == "tests/templates/undefinedVariable.txt:1: error: 'this_is_not_defined' is undefined\n"
expected_error = "tests/templates/undefinedVariable.txt:1: error: 'this_is_not_defined' is undefined\n"
actual_output = mock_stderr.getvalue().replace("\\", "/") # Normalize backslashes
assert expected_error in actual_output, f"Expected error not found. Expected: {expected_error}, Actual: {actual_output}"

@patch('sys.stderr', new_callable=StringIO)
def test_error_template_doesnt_exist(mock_stderr):
Expand Down
9 changes: 7 additions & 2 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_flag():
assert interface.attribute('config', 'a') == 'a' # use value from yaml
assert interface.attribute('config', 'b') == 'b' # use value from yaml
assert interface.attribute('config', 'c') == 'C' # use value from IDL
assert interface.attribute('config', 'd') == 'D' # use value from IDL, No Space after :
assert interface.tags['data'] == [1, 2, 3] # array annotatiom

def test_merge_annotation():
Expand Down Expand Up @@ -89,7 +90,9 @@ def test_merge_broken_annotation(mock_stderr):
FileSystem.merge_annotations(system, inputPath / 'broken_tuner_annotations.yaml')

assert interface.attribute('extra', 'extraA') is None
assert mock_stderr.getvalue().__contains__("tests/in/broken_tuner_annotations.yaml:2: error: mapping values are not allowed")
expected_error = "tests/in/broken_tuner_annotations.yaml:2: error: mapping values are not allowed"
actual_output = mock_stderr.getvalue().replace("\\", "/") # Normalize backslashes
assert expected_error in actual_output, f"Expected error not found. Expected: {expected_error}, Actual: {actual_output}"

@patch('sys.stderr', new_callable=StringIO)
def test_merge_invalid_annotation(mock_stderr):
Expand All @@ -99,4 +102,6 @@ def test_merge_invalid_annotation(mock_stderr):
FileSystem.merge_annotations(system, inputPath / 'invalid_tuner_annotations.yaml')

assert interface.attribute('extra', 'extraA') is None
assert mock_stderr.getvalue() == "Error parsing annotation tests/in/invalid_tuner_annotations.yaml: not able to lookup symbol: Tunerrrrrrrr\n"
expected_error = "Error parsing annotation tests/in/invalid_tuner_annotations.yaml: not able to lookup symbol: Tunerrrrrrrr\n"
actual_output = mock_stderr.getvalue().replace("\\", "/") # Normalize backslashes
assert expected_error in actual_output, f"Expected error not found. Expected: {expected_error}, Actual: {actual_output}"

0 comments on commit 4a77e9a

Please sign in to comment.