Skip to content

Commit

Permalink
Merge pull request #96 from chef/dr/windowsfile-symlink-issue
Browse files Browse the repository at this point in the history
bugfix: windows file failed to initialize with new symlink handler
  • Loading branch information
alexpop committed Apr 29, 2016
2 parents 49172f5 + 39561eb commit 73b962b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ environment:
winrm_pass: Pass@word1

matrix:
- ruby_version: "21"
- ruby_version: "22"
train_target: winrm://test_user@localhost:5985

- ruby_version: "21"
- ruby_version: "22"
train_ssl: true
train_target: winrm://test_user@localhost:5986

clone_folder: c:\projects\train
clone_depth: 1

cache:
- C:\Users\appveyor\.gem\ruby\2.1.0
- C:\Ruby21\lib\ruby\gems\2.1.0
- C:\Users\appveyor\.gem\ruby\2.2.0
- C:\Ruby200-x64\bin\gem
- C:\Ruby22\bin\gem
- C:\Ruby22\lib\ruby\gems\2.2.0

install:
- systeminfo
Expand Down
2 changes: 1 addition & 1 deletion lib/train/extras/file_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
module Train::Extras
class WindowsFile < FileCommon
attr_reader :path
def initialize(backend, path, follow_symlink)
def initialize(backend, path, follow_symlink = false)
super(backend, path, follow_symlink)
@spath = sanitize_filename(@path)
end
Expand Down
10 changes: 5 additions & 5 deletions test/unit/extras/windows_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
}

it 'provides the full path' do
cls.new(backend, 'C:\dir\file', false).path.must_equal 'C:\dir\file'
cls.new(backend, 'C:\dir\file').path.must_equal 'C:\dir\file'
end

it 'provides the basename to a unix path' do
cls.new(backend, 'C:\dir\file', false).basename.must_equal 'file'
cls.new(backend, 'C:\dir\file').basename.must_equal 'file'
end

it 'provides the full path with whitespace' do
wf = cls.new(backend, 'C:\Program Files\file name', false)
wf = cls.new(backend, 'C:\Program Files\file name')
wf.path.must_equal 'C:\Program Files\file name'
wf.basename.must_equal 'file name'
end

it 'reads file contents' do
out = rand.to_s
backend.mock_command('Get-Content("path") | Out-String', out)
cls.new(backend, 'path', false).content.must_equal out
cls.new(backend, 'path').content.must_equal out
end

it 'check escaping of invalid chars in path' do
wf = cls.new(nil, nil, false)
wf = cls.new(nil, nil)
wf.sanitize_filename('c:/test') .must_equal 'c:/test'
wf.sanitize_filename('c:/test directory') .must_equal 'c:/test directory'
%w{ < > " * ?}.each do |char|
Expand Down

0 comments on commit 73b962b

Please sign in to comment.