bugfix: specinfra file type detection

mask & tmask returns non-zero values, if some bits fit the file-type. this leads to overlapping results. make sure the mask result has the full mask present, then use it.

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-09-03 14:14:57 +02:00
parent d3d91c8c3f
commit f618fa391b
3 changed files with 10 additions and 3 deletions

View file

@ -171,7 +171,7 @@ module Vulcano::Backends
path = Shellwords.escape(@path)
raw_type = Specinfra::Runner.run_command("stat -c %f #{path}").stdout
tmask = raw_type.to_i(16)
res = TYPES.find{|name, mask| mask & tmask}
res = TYPES.find{|name, mask| mask & tmask == mask}
return :unknown if res.nil?
res[0]
end

View file

@ -2,8 +2,11 @@ require 'docker'
require 'yaml'
require_relative '../lib/vulcano'
tests = ARGV.drop(1)
exit 0 if tests.empty?
tests = ARGV
if tests.empty?
puts 'Nothing to do.'
exit 0
end
class DockerTester
def initialize(tests)

4
test/resource/file.rb Normal file
View file

@ -0,0 +1,4 @@
describe file('/tmp') do
its(:type) { should eq :directory }
end