Skip to content

Commit

Permalink
Bin files independent of pwd (Fixes #291) (#462)
Browse files Browse the repository at this point in the history
Use path relative to the file in the bin directory rather than the
current working directory.

for enable-executable and executable-tests-check
  • Loading branch information
Insti authored Oct 21, 2016
1 parent f646982 commit 46b9684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
14 changes: 9 additions & 5 deletions bin/enable-executable
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

require 'fileutils'

puts 'Ensuring test files are executable...'
puts 'Ensuring test files are executable.'

(Dir.glob('**/*test.rb') + Dir.glob('bin/*')).each do |f|
if File.executable?(f)
# Assume that this file lives in #{base}/bin
base = File.join(__dir__,'..')
files = Dir.glob("#{base}/**/*test.rb") + Dir.glob("#{base}/bin/*")

files.each do |file|
if File.executable?(file)
print '.'
else
print "\nAdding exec bit to #{f}"
FileUtils.chmod('u+x', f)
print "\nAdding exec bit to #{file}"
FileUtils.chmod('u+x', file)
end
end
puts
10 changes: 7 additions & 3 deletions bin/executable-tests-check
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env ruby
require 'minitest/autorun'

(Dir.glob('**/*test.rb') + Dir.glob('bin/*')).each do |f|
describe f do
# Assume that this file lives in #{base}/bin
base = File.join(__dir__,'..')
files = Dir.glob("#{base}/**/*test.rb") + Dir.glob("#{base}/bin/*")

files.each do |file|
describe file do
it 'should have the execution bit set' do
assert File.executable?(f), "Execution bit not set for #{f}"
assert File.executable?(file), "Execution bit not set for #{file}"
end
end
end

0 comments on commit 46b9684

Please sign in to comment.