-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9387 from joshcooper/dir_chdir_9997
(PUP-9997) Avoid Dir.chdir
- Loading branch information
Showing
7 changed files
with
100 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
require 'spec_helper' | ||
require 'puppet/module_tool' | ||
|
||
describe Puppet::ModuleTool::Tar::Gnu do | ||
describe Puppet::ModuleTool::Tar::Gnu, unless: Puppet::Util::Platform.windows? do | ||
let(:sourcedir) { '/space path/the/src/dir' } | ||
let(:sourcefile) { '/space path/the/module.tar.gz' } | ||
let(:destdir) { '/space path/the/dest/dir' } | ||
let(:sourcedir) { '/space path/the/src/dir' } | ||
let(:destfile) { '/space path/the/dest/file.tar.gz' } | ||
let(:destfile) { '/space path/the/dest/fi le.tar.gz' } | ||
|
||
let(:safe_sourcedir) { '/space\ path/the/src/dir' } | ||
let(:safe_sourcefile) { '/space\ path/the/module.tar.gz' } | ||
let(:safe_destdir) { '/space\ path/the/dest/dir' } | ||
let(:safe_destfile) { 'fi\ le.tar.gz' } | ||
|
||
it "unpacks a tar file" do | ||
expect(Dir).to receive(:chdir).with(File.expand_path(destdir)).and_yield | ||
expect(Puppet::Util::Execution).to receive(:execute).with("gzip -dc #{Shellwords.shellescape(File.expand_path(sourcefile))} | tar xof -") | ||
expect(Puppet::Util::Execution).to receive(:execute).with("find . -type d -exec chmod 755 {} +") | ||
expect(Puppet::Util::Execution).to receive(:execute).with("find . -type f -exec chmod u+rw,g+r,a-st {} +") | ||
expect(Puppet::Util::Execution).to receive(:execute).with("chown -R <owner:group> .") | ||
expect(Puppet::Util::Execution).to receive(:execute).with("gzip -dc #{safe_sourcefile} | tar --extract --no-same-owner --directory #{safe_destdir} --file -") | ||
expect(Puppet::Util::Execution).to receive(:execute).with(['find', destdir, '-type', 'd', '-exec', 'chmod', '755', '{}', '+']) | ||
expect(Puppet::Util::Execution).to receive(:execute).with(['find', destdir, '-type', 'f', '-exec', 'chmod', 'u+rw,g+r,a-st', '{}', '+']) | ||
expect(Puppet::Util::Execution).to receive(:execute).with(['chown', '-R', '<owner:group>', destdir]) | ||
subject.unpack(sourcefile, destdir, '<owner:group>') | ||
end | ||
|
||
it "packs a tar file" do | ||
expect(Puppet::Util::Execution).to receive(:execute).with("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}") | ||
expect(Puppet::Util::Execution).to receive(:execute).with("tar cf - #{safe_sourcedir} | gzip -c > #{safe_destfile}") | ||
subject.pack(sourcedir, destfile) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters