Skip to content

Commit

Permalink
(#98) Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pbenety committed Jun 13, 2018
1 parent 6063955 commit 0e25181
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 7 additions & 3 deletions lib/pdd/sources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ def exclude(ptn)

private

def binary?(f)
# @todo #98:30min Change the implementation of this method
# to also work in Windows machines. Investigate the possibility
# of use a gem for this. After that, remove the skip of the test
# `test_ignores_binary_files` in `test_sources.rb`.
def binary?(file)
return false if Gem.win_platform?
`grep -qI '.' #{Shellwords.escape(f)}`
`grep -qI '.' #{Shellwords.escape(file)}`
if $CHILD_STATUS.success?
false
else
PDD.log.info "#{f} is a binary file (#{File.size(f)} bytes)"
PDD.log.info "#{file} is a binary file (#{File.size(file)} bytes)"
true
end
end
Expand Down
8 changes: 2 additions & 6 deletions test/test_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
# Copyright:: Copyright (c) 2014-2018 Yegor Bugayenko
# License:: MIT
class TestSource < Minitest::Test
# @todo #85:30min Make this test pass on AppVeyor.
def test_parsing
skip('Skipped because it fails on AppVeyor')
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'a.txt')
File.write(
file,
"
* \x40todo #44 привет,
* how are you\t\r\tdoing?
* how are you\t\tdoing?
* -something else
Something else
~~ \x40todo #ABC-3 this is another puzzle
Expand Down Expand Up @@ -90,7 +88,6 @@ def test_failing_on_incomplete_puzzle
end

def test_failing_on_broken_unicode
skip if Gem.win_platform?
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'xx.txt')
File.write(file, ' * \x40todo #44 this is a broken unicode: ' + 0x92.chr)
Expand All @@ -101,7 +98,6 @@ def test_failing_on_broken_unicode
end

def test_failing_on_invalid_puzzle_without_hash_sign
skip('doesnt work now')
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'a.txt')
File.write(
Expand All @@ -113,7 +109,7 @@ def test_failing_on_invalid_puzzle_without_hash_sign
error = assert_raises PDD::Error do
PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
end
assert !error.message.index('Incorrect format').nil?
assert !error.message.index('is not followed by a puzzle marker').nil?
end
end

Expand Down

1 comment on commit 0e25181

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 0e25181 Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 98-9de926c6 discovered in lib/pdd/sources.rb and submitted as #102. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.