mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
tests: create a temporary name, not a Tempfile
rubyzip also does use Tempfile under the hood, this causes trouble.
This commit is contained in:
parent
43eb763635
commit
c891686d72
1 changed files with 4 additions and 10 deletions
|
@ -17,6 +17,7 @@ end
|
|||
require 'fileutils'
|
||||
require 'pathname'
|
||||
require 'tempfile'
|
||||
require 'tmpdir'
|
||||
require 'zip'
|
||||
|
||||
require 'utils/base_cli'
|
||||
|
@ -51,8 +52,6 @@ class MockLoader
|
|||
undefined: { family: nil, release: nil, arch: nil },
|
||||
}
|
||||
|
||||
@archives = {}
|
||||
|
||||
# pass the os identifier to emulate a specific operating system
|
||||
def initialize(os = nil)
|
||||
# selects operating system
|
||||
|
@ -266,9 +265,7 @@ class MockLoader
|
|||
|
||||
def self.profile_tgz(name)
|
||||
path = File.join(home, 'mock', 'profiles', name)
|
||||
archive = Tempfile.new([name, '.tar.gz'])
|
||||
dst = archive.path
|
||||
archive.close
|
||||
dst = File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(name, '.tar.gz'))
|
||||
|
||||
# generate relative paths
|
||||
files = Dir.glob("#{path}/**/*")
|
||||
|
@ -277,16 +274,13 @@ class MockLoader
|
|||
require 'inspec/archive/tar'
|
||||
tag = Inspec::Archive::TarArchiveGenerator.new
|
||||
tag.archive(path, relatives, dst)
|
||||
@archives[dst] = archive
|
||||
|
||||
dst
|
||||
end
|
||||
|
||||
def self.profile_zip(name, opts = {})
|
||||
path = File.join(home, 'mock', 'profiles', name)
|
||||
archive = Tempfile.new([name, '.zip'])
|
||||
dst = archive.path
|
||||
archive.close
|
||||
dst = File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(name, '.zip'))
|
||||
|
||||
# rubyzip only works relative paths
|
||||
files = Dir.glob("#{path}/**/*")
|
||||
|
@ -295,7 +289,7 @@ class MockLoader
|
|||
require 'inspec/archive/zip'
|
||||
zag = Inspec::Archive::ZipArchiveGenerator.new
|
||||
zag.archive(path, relatives, dst)
|
||||
@archives[dst] = archive
|
||||
|
||||
dst
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue