mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-07-10 14:20:40 +00:00
Fall back to iterative brace removal because I suspect regex version is too slow.
Further tidying of ci.
This commit is contained in:
@@ -51,11 +51,17 @@ jobs:
|
||||
gem install bundler
|
||||
bundle install
|
||||
|
||||
- name: Run Ruby Unit Tests and Style Check
|
||||
- name: Run Ruby Unit Tests
|
||||
env:
|
||||
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
|
||||
run: |
|
||||
cd test && rake test:unit style:check
|
||||
cd test && rake test:unit
|
||||
|
||||
- name: Run Style Check
|
||||
env:
|
||||
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
|
||||
run: |
|
||||
cd test && rake style:check
|
||||
|
||||
# Job: C compilation and system tests — only needs to run on one Ruby version per OS,
|
||||
# since the generated C code and runtime behavior don't vary with the Ruby version.
|
||||
@@ -102,7 +108,12 @@ jobs:
|
||||
- name: Run System Tests
|
||||
env:
|
||||
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
|
||||
run: cd test && rake test:system test:examples
|
||||
run: cd test && rake test:system
|
||||
|
||||
- name: Run Examples
|
||||
env:
|
||||
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
|
||||
run: cd test && rake test:examples
|
||||
|
||||
# Job: Valgrind memory-leak check (Linux/gcc_64 only, latest Ruby)
|
||||
valgrind:
|
||||
|
||||
@@ -118,15 +118,11 @@ class CMockHeaderParser
|
||||
|
||||
def remove_nested_pairs_of_braces(source)
|
||||
# remove nested pairs of braces because no function declarations will be inside of them (leave outer pair for function definition detection)
|
||||
if RUBY_VERSION.split('.')[0].to_i > 1
|
||||
# we assign a string first because (no joke) if Ruby 1.9.3 sees this line as a regex, it will crash.
|
||||
r = '\\{([^\\{\\}]*|\\g<0>)*\\}'
|
||||
source.gsub!(/#{r}/m, '{ }')
|
||||
else
|
||||
while source.gsub!(/\{[^{}]*\{[^{}]*\}[^{}]*\}/m, '{ }')
|
||||
end
|
||||
# Use iterative approach for all Ruby versions: the recursive regex \{([^\{\}]*|\g<0>)*\}
|
||||
# is exponential on unbalanced brace inputs (catastrophic backtracking on Ruby < 3.2).
|
||||
while source.gsub!(/\{[^{}]*\{[^{}]*\}[^{}]*\}/m, '{ }')
|
||||
# Keep doing it!
|
||||
end
|
||||
|
||||
source
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user