Skip to content

Commit 64d8ee1

Browse files
committed
backend/sdoc_source_code: reader_c: fix a small edge case related to code comments
This is a result of fast coding. Was overlooked that the range was asserted by the itest incorrectly.
1 parent 5de8475 commit 64d8ee1

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

strictdoc/backend/sdoc_source_code/reader_c.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,15 @@ def read(
261261
function_markers = []
262262
function_comment_node = None
263263
function_comment_text = None
264+
265+
# In the condition below, it is important that the comment is
266+
# considered a function comment only if it there are no empty
267+
# lines between the comment and function.
264268
if (
265269
node_.prev_sibling is not None
266270
and node_.prev_sibling.type == "comment"
271+
and (node_.prev_sibling.end_point[0] + 1)
272+
== node_.start_point[0]
267273
):
268274
function_comment_node = node_.prev_sibling
269275
assert function_comment_node.text is not None, node_.text

tests/integration/features/test_reports/junit_xml/ctest/05_user_example/test.itest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN: %check_exists --file "%S/Output/html/_source_files/tests/test1.cpp.html"
1414

1515
# Ensure that the test report document has the right content.
1616
RUN: %cat "%S/Output/html/%THIS_TEST_FOLDER/reports/tests_unit.ctest.junit.html" | filecheck %s --check-prefix CHECK-TEST-REPORT
17-
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestSuiteName.TestName#15#21">
18-
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 15-21</i>, function TEST(MyTestSuiteName, TestName)
17+
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestSuiteName.TestName#17#21">
18+
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 17-21</i>, function TEST(MyTestSuiteName, TestName)
1919
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestHelper.TestName2#32#36">
2020
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 32-36</i>, function TEST_F(MyTestHelper, TestName2)
2121
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestPattern/MyTestHelperPattern.TestName3/1#44#48">

tests/integration/features/test_reports/junit_xml/gtest/05_user_example/test.itest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN: %check_exists --file "%S/Output/html/_source_files/tests/test1.cpp.html"
1414

1515
# Ensure that the test report document has the right content.
1616
RUN: %cat "%S/Output/html/%THIS_TEST_FOLDER/reports/tests_unit.gtest.junit.html" | filecheck %s --check-prefix CHECK-TEST-REPORT
17-
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestSuiteName.TestName#15#21">
18-
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 15-21</i>, function TEST(MyTestSuiteName, TestName)
17+
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestSuiteName.TestName#17#21">
18+
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 17-21</i>, function TEST(MyTestSuiteName, TestName)
1919
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestHelper.TestName2#32#36">
2020
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 32-36</i>, function TEST_F(MyTestHelper, TestName2)
2121
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestPattern/MyTestHelperPattern.TestName3/1#44#48">

tests/integration/features/test_reports/junit_xml/gtest/06_user_example_still_does_not_work/test.itest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN: %check_exists --file "%S/Output/html/_source_files/tests/test1.cpp.html"
1414

1515
# Ensure that the test report document has the right content.
1616
RUN: %cat "%S/Output/html/%THIS_TEST_FOLDER/reports/tests_unit.gtest.junit.html" | filecheck %s --check-prefix CHECK-TEST-REPORT
17-
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#TestCaseVc.TestCase#15#21">
18-
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 15-21</i>, function TEST(TestCaseVc, TestCase)
17+
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#TestCaseVc.TestCase#17#21">
18+
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 17-21</i>, function TEST(TestCaseVc, TestCase)
1919
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#TestCaseVc.Steering1#23#27">
2020
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 23-27</i>, function TEST(TestCaseVc, Steering1)

0 commit comments

Comments
 (0)