Skip to content

Commit

Permalink
Import rubocop test harness, use it
Browse files Browse the repository at this point in the history
This moves most tests to run inline instead of spawning an extra process.
This isn't only faster but also much more explicit in what is actually being tested against.
A few tests are left intact for issues that actually manifested during live rubocop runs.
  • Loading branch information
Earlopain committed Dec 13, 2023
1 parent 061e331 commit 8a32f40
Show file tree
Hide file tree
Showing 17 changed files with 638 additions and 430 deletions.
8 changes: 6 additions & 2 deletions lib/rubocop/markdown/preprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ class << self
# using preproccessed source buffer.
#
# We have to restore it.
def restore!(file)
def restore_and_save!(file)
contents = File.read(file)
contents.gsub!(/^##{MARKER}/m, "")
restore!(contents)
File.write(file, contents)
end

def restore!(src)
src.gsub!(/^##{MARKER}/m, "")
end
end

attr_reader :config
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/markdown/rubocop_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def file_finished(file, offenses)

# Run Preprocess.restore if file has been autocorrected
if @options[:auto_correct] || @options[:autocorrect]
RuboCop::Markdown::Preprocess.restore!(file)
RuboCop::Markdown::Preprocess.restore_and_save!(file)
end

super(file, offenses)
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/NON_CODE_OFFENSES.md

This file was deleted.

7 changes: 0 additions & 7 deletions test/fixtures/backticks.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
inherit_from: "../../../.rubocop.yml"

Markdown:
Autodetect: false
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ inherit_from: "../../../.rubocop.yml"

require:
- "rubocop-md"

Markdown:
Autodetect: false
5 changes: 0 additions & 5 deletions test/fixtures/configs/no_warn_invalid.yml

This file was deleted.

8 changes: 0 additions & 8 deletions test/fixtures/configs/no_warn_invalid_with_require.yml

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/in_flight_parse.rb

This file was deleted.

25 changes: 0 additions & 25 deletions test/fixtures/multiple_invalid_snippets.md

This file was deleted.

20 changes: 0 additions & 20 deletions test/fixtures/multiple_invalid_snippets_unknown.md

This file was deleted.

52 changes: 0 additions & 52 deletions test/fixtures/multiple_snippets.markdown

This file was deleted.

Loading

0 comments on commit 8a32f40

Please sign in to comment.