From f618fa391b3a9cecc7c10388327957ac8e1efec2 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Thu, 3 Sep 2015 14:14:57 +0200 Subject: [PATCH] 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 --- lib/vulcano/backend/specinfra.rb | 2 +- test/docker.rb | 7 +++++-- test/resource/file.rb | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/resource/file.rb diff --git a/lib/vulcano/backend/specinfra.rb b/lib/vulcano/backend/specinfra.rb index c4b9f8c00..2ab65e808 100644 --- a/lib/vulcano/backend/specinfra.rb +++ b/lib/vulcano/backend/specinfra.rb @@ -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 diff --git a/test/docker.rb b/test/docker.rb index 224305f50..df39379a9 100644 --- a/test/docker.rb +++ b/test/docker.rb @@ -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) diff --git a/test/resource/file.rb b/test/resource/file.rb new file mode 100644 index 000000000..71345c136 --- /dev/null +++ b/test/resource/file.rb @@ -0,0 +1,4 @@ + +describe file('/tmp') do + its(:type) { should eq :directory } +end