Skip to content

Commit

Permalink
Merge pull request #88 from justindossey/dont-strip-mode
Browse files Browse the repository at this point in the history
Don't strip off the second byte of the octal mode.
  • Loading branch information
arlimus committed Apr 22, 2016
2 parents c624d1c + 9d2dd99 commit ead8ca9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/train/extras/stat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.linux_stat(shell_escaped_path, backend)

{
type: find_type(tmask),
mode: tmask & 00777,
mode: tmask & 07777,
owner: fields[2],
group: fields[4],
mtime: fields[7].to_i,
Expand Down Expand Up @@ -85,7 +85,7 @@ def self.bsd_stat(shell_escaped_path, backend)

{
type: find_type(tmask),
mode: tmask & 00777,
mode: tmask & 07777,
owner: fields[2],
group: fields[4],
mtime: fields[7].to_i,
Expand Down Expand Up @@ -113,7 +113,7 @@ def self.aix_stat(shell_escaped_path, backend)

{
type: find_type(tmask),
mode: tmask & 00777,
mode: tmask & 07777,
owner: fields[1],
group: fields[2],
mtime: fields[3].to_i,
Expand Down
17 changes: 9 additions & 8 deletions test/unit/extras/stat_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
cls.find_type(00140755).must_equal :socket
end

it 'detects sockets' do
it 'detects symlinks' do
cls.find_type(00120755).must_equal :symlink
end

it 'detects sockets' do
it 'detects files' do
cls.find_type(00100755).must_equal :file
end

it 'detects sockets' do
it 'detects block devices' do
cls.find_type(00060755).must_equal :block_device
end

it 'detects sockets' do
it 'detects directories' do
cls.find_type(00040755).must_equal :directory
end

it 'detects sockets' do
it 'detects character devices' do
cls.find_type(00020755).must_equal :character_device
end

it 'detects sockets' do
it 'detects pipes' do
cls.find_type(00010755).must_equal :pipe
end
end
Expand All @@ -53,11 +53,12 @@

it 'reads correct stat results' do
res = Minitest::Mock.new
# 43ff is 41777; linux_stat strips the 4
res.expect :stdout, "360\n43ff\nroot\n0\nroot\n0\n1444520846\n1444522445\n?"
backend.expect :run_command, res, [String]
cls.linux_stat('/path', backend).must_equal({
type: :directory,
mode: 00777,
mode: 01777,
owner: 'root',
group: 'root',
mtime: 1444522445,
Expand Down Expand Up @@ -93,7 +94,7 @@
backend.expect :run_command, res, [String]
cls.bsd_stat('/path', backend).must_equal({
type: :directory,
mode: 00777,
mode: 01777,
owner: 'root',
group: 'root',
mtime: 1444522445,
Expand Down

0 comments on commit ead8ca9

Please sign in to comment.