diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index dab5096c0026c523094fd1d9cb4483454a22c486..6dc90e0558bdac9ee6cb0c8062d5cecb6a11a132 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -104,10 +104,10 @@ class UnityTestRunnerGenerator source_scrubbed = source_scrubbed.gsub(/\\"/, '@quote@') # hide escaped quotes to allow capture of the full string/char source_scrubbed = source_scrubbed.gsub(/\\'/, '@apos@') # hide escaped apostrophes to allow capture of the full string/char source_scrubbed = source_scrubbed.gsub(/("[^"\n]*")|('[^'\n]*')/) { |s| s.gsub(substring_re, substring_subs) } # temporarily hide problematic characters within strings - source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments - source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments - lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line - | (;|\{|\}) /x) # Match ;, {, and } as end of lines + source_scrubbed = source_scrubbed.gsub(/\/\/(?:.+\/\*|\*(?:$|[^\/])).*$/, '') # remove line comments that comment out the start of blocks + source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments + source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments (all that remain) + lines = source_scrubbed.split(/(^\s*\#.*$) | (;|\{|\}) /x) # Treat preprocessor directives as a logical line. Match ;, {, and } as end of lines .map { |line| line.gsub(substring_unre, substring_unsubs) } # unhide the problematic characters previously removed lines.each_with_index do |line, _index| diff --git a/test/testdata/testRunnerGenerator.c b/test/testdata/testRunnerGenerator.c index b3c0cddef5829d29227b58a2d3980a4a70c42c5f..113993927557648f0faa5d6596ffcd996a4cccff 100644 --- a/test/testdata/testRunnerGenerator.c +++ b/test/testdata/testRunnerGenerator.c @@ -124,7 +124,9 @@ void test_NotBeConfusedByLongComplicatedStrings(void) void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void) { TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True"); + /* still should not break anything */ } +/* nor should this */ void test_StillNotBeConfusedByLongComplicatedStrings(void) {