-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement symlink logic for windows hosts
- Loading branch information
Showing
7 changed files
with
136 additions
and
33 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require "spec_helper" | ||
require 'tmpdir' | ||
|
||
|
||
# creates a dir at <path> then deletes it after block executes | ||
# this will DESTROY any existing entry at that location in the filesystem | ||
def with_tmpdir(path) | ||
begin | ||
FileUtils.remove_entry path if path.exist? | ||
path.mkpath | ||
yield | ||
ensure | ||
begin | ||
FileUtils.remove_entry path if path.exist? | ||
rescue Errno::ENOENT | ||
# seems like our job is done | ||
end | ||
end | ||
end | ||
|
||
|
||
RSpec.describe ArduinoCI::Host do | ||
next if skip_ruby_tests | ||
|
||
context "symlinks" do | ||
it "creates symlinks that we agree are symlinks" do | ||
our_dir = Pathname.new(__dir__) | ||
foo_dir = our_dir + "foo_dir" | ||
bar_dir = our_dir + "bar_dir" | ||
|
||
with_tmpdir(foo_dir) do | ||
foo_dir.unlink # we just want to place something at this location | ||
expect(foo_dir.exist?).to be_falsey | ||
|
||
with_tmpdir(bar_dir) do | ||
expect(bar_dir.exist?).to be_truthy | ||
expect(bar_dir.symlink?).to be_falsey | ||
|
||
ArduinoCI::Host.symlink(bar_dir, foo_dir) | ||
expect(ArduinoCI::Host.symlink?(bar_dir)).to be_falsey | ||
expect(ArduinoCI::Host.symlink?(foo_dir)).to be_truthy | ||
expect(ArduinoCI::Host.readlink(foo_dir).realpath).to eq(bar_dir.realpath) | ||
end | ||
end | ||
|
||
expect(foo_dir.exist?).to be_falsey | ||
expect(bar_dir.exist?).to be_falsey | ||
|
||
end | ||
end | ||
|
||
end |