Skip to content

Commit

Permalink
Fix tar mtime tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj committed Oct 22, 2017
1 parent 77ff335 commit dbe1840
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions test/mix/tasks/hex.build_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ defmodule Mix.Tasks.Hex.BuildTest do
in_tmp fn ->
Hex.State.put(:home, tmp_path())

File.mkdir!("dir")
File.mkdir!("empty_dir")
File.write!("empty_dir/.dotfile", "")
File.write!("dir/.dotfile", "")
File.ln_s("empty_dir", "link_dir")

mtime_dir = File.stat!("empty_dir").mtime
mtime_file = File.stat!("empty_dir/.dotfile").mtime
# mtime_dir = File.stat!("dir").mtime
mtime_empty_dir = File.stat!("empty_dir").mtime
mtime_file = File.stat!("dir/.dotfile").mtime
mtime_link = File.stat!("link_dir").mtime

File.write!("myfile.txt", "hello")
Expand All @@ -61,18 +63,19 @@ defmodule Mix.Tasks.Hex.BuildTest do

extract("release_h-0.0.1.tar", "unzip")

#Check that mtimes are not retained for files and directories and symlinks
assert File.stat!("unzip/empty_dir").mtime != mtime_dir
assert File.stat!("unzip/empty_dir/.dotfile").mtime != mtime_file
assert File.stat!("unzip/linkdir").mtime != mtime_link
# Check that mtimes are not retained for files and directories and symlinks
# erl_tar does not set mtime from tar if a directory contain files
# assert File.stat!("unzip/dir").mtime != mtime_dir
assert File.stat!("unzip/empty_dir").mtime != mtime_empty_dir
assert File.stat!("unzip/dir/.dotfile").mtime != mtime_file
assert File.stat!("unzip/link_dir").mtime != mtime_link

assert File.lstat!("unzip/link_dir").type == :symlink
assert File.lstat!("unzip/empty_dir").type == :directory
assert File.read!("unzip/myfile.txt") == "hello"
assert File.read!("unzip/empty_dir/.dotfile") == ""
assert File.read!("unzip/dir/.dotfile") == ""
assert File.stat!("unzip/myfile.txt").mode == 0o100644
assert File.stat!("unzip/executable.sh").mode == 0o100755
IO.inspect File.stat!("unzip/link_dir")
end
after
purge [ReleaseFiles.MixProject]
Expand Down
2 changes: 1 addition & 1 deletion test/support/release_samples.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ defmodule ReleaseFiles.MixProject do
version: "0.0.1",
description: "foo",
package: [
files: ["myfile.txt", "executable.sh", "empty_dir", "link_dir"],
files: ["myfile.txt", "executable.sh", "dir", "empty_dir", "link_dir"],
licenses: ["MIT"],
links: %{"a" => "http://a"},
maintainers: ["maintainers"]]]
Expand Down

0 comments on commit dbe1840

Please sign in to comment.