Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jan 19, 2024
2 parents 955d53a + 2814bae commit 2215a6b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
3 changes: 2 additions & 1 deletion bin/pdd
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ https://github.com/cqfn/pdd/blob/master/README.md"

if opts['skip-gitignore'] && File.exist?('.gitignore')
cfg = File.new('.gitignore')
body = File.read(cfg)
body = ''
File.foreach(cfg) { |line| body << line unless line.start_with?('#') }
extra = body.split(/\s+/).map(&:strip)
opts['skip-gitignore'] = extra
PDD.log.info "Found #{body.split("\n").length} lines in #{File.absolute_path(cfg)}"
Expand Down
51 changes: 46 additions & 5 deletions features/cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,67 @@ Feature: Command Line Processing
Then Exit code is zero
And XML file "out.xml" matches "/puzzles[count(puzzle)=0]"

Scenario: Excluding unnecessary files from gitignore
Given this step says to skip
And I have a "a/b/c/test.txt" file with content:
Scenario: Excluding unnecessary files from .gitignore
Given I have a "a/b/c/test.txt" file with content:
"""
~~ @todo #44 some puzzle to be excluded
"""
And I have a "f/g/h/hello.md" file with content:
"""
~~ @todo #44 some puzzle to be excluded as well
~~ @todo #45 some puzzle to be excluded as well
"""
And I have a ".gitignore" file with content:
"""
# This is the list of patterns
a/**/*
!/f
"""
When I run bin/pdd with "> out.xml"
When I run bin/pdd with "--skip-gitignore > out.xml"
Then Exit code is zero
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='45']"
And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"

Scenario: Excluding unnecessary files from .gitignore and ignore comments
Given I have a "a/b/c/test.txt" file with content:
"""
~~ @todo #44 some puzzle to be excluded
"""
And I have a "f/g/h/hello.md" file with content:
"""
~~ @todo #45 some puzzle to be excluded as well
"""
And I have a ".gitignore" file with content:
"""
# This is the list of patterns
# a/**/*
f/**/*
"""
When I run bin/pdd with "--skip-gitignore > out.xml"
Then Exit code is zero
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='44']"
And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"

Scenario: Files from .gitignore is not excluded by default
Given I have a "a/b/c/test.txt" file with content:
"""
~~ @todo #44 some puzzle to be excluded
"""
And I have a "f/g/h/hello.md" file with content:
"""
~~ @todo #45 some puzzle to be excluded as well
"""
And I have a ".gitignore" file with content:
"""
# This is the list of patterns
a/**/*
!/f
"""
When I run bin/pdd with "> out.xml"
Then Exit code is zero
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='44']"
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='45']"
And XML file "out.xml" matches "/puzzles[count(puzzle)=2]"

Scenario: Rejects unknown options
Given I have a "test.txt" file with content:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
FileUtils.rm_rf(@dir)
end

Given(/skip/) do
Given(/skip test/) do
skip_this_scenario
end

Expand Down

0 comments on commit 2215a6b

Please sign in to comment.