-
Notifications
You must be signed in to change notification settings - Fork 843
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 #2363 from Blaisorblade/2361-ignore-pax-header-ent…
…ries stack unpack: Ignore pax headers (fix #2361)
- Loading branch information
Showing
8 changed files
with
153 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Use ./createFiles.sh to regenerate the test tarballs in this directory. |
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,47 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
|
||
module Stack.Untar.UntarSpec where | ||
|
||
import Data.List (sort) | ||
import Path | ||
import Path.IO (removeDirRecur) | ||
import qualified System.FilePath as FP | ||
import Stack.Fetch (untar) | ||
import Test.Hspec | ||
|
||
spec :: Spec | ||
spec = do | ||
describe "Untarring ignores strange entries" $ | ||
mapM_ testTarFile tarFiles | ||
where | ||
-- XXX tests are run in the project root folder, but data files are next to | ||
-- this source data. | ||
currentFolder = $(mkRelDir $ "src" FP.</> "test" FP.</> "Stack" FP.</> "Untar") | ||
|
||
-- Pairs test tarball names + list of unexpected entries contained: for each | ||
-- entry, a tar pathname + description. | ||
tarFilesBase = [ ("test1", []) | ||
, ("test2", [ ("bar", "named pipe") | ||
, ("devB", "block device") | ||
, ("devC", "character device")])] | ||
-- Prepend tarball name to tar pathnames: | ||
tarFiles = | ||
[ (name, | ||
[ (name FP.</> entryName, d) | ||
| (entryName, d) <- entries]) | ||
| (name, entries) <- tarFilesBase ] | ||
|
||
testTarFile (name, expected) = | ||
it ("works on test " ++ name) $ | ||
getEntries name `shouldReturn` sort expected | ||
|
||
getEntries name = do | ||
tarballName <- parseRelFile $ name ++ ".tar.gz" | ||
expectedTarFolder <- parseRelDir name | ||
|
||
entries <- untar (currentFolder </> tarballName) expectedTarFolder currentFolder | ||
removeDirRecur $ currentFolder </> expectedTarFolder | ||
return $ sort entries |
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,26 @@ | ||
#!/bin/sh | ||
|
||
# This allows recreating | ||
|
||
# Name for GNU tar. | ||
TAR=tar | ||
CHOWN=chown | ||
# Needed on my OS X install with HomeBrew. | ||
#TAR=gtar | ||
#CHOWN=gchown | ||
|
||
mkdir -p test1 test2 | ||
touch test1/foo | ||
mkfifo test2/bar | ||
sudo mknod test2/devB b 1 0 | ||
sudo mknod test2/devC c 3 2 | ||
sudo $CHOWN --reference=test2 test2/* | ||
|
||
for i in 1 2; do | ||
$TAR czf test$i.tar.gz --format=posix test$i | ||
done | ||
for i in 1 2; do | ||
gtar czf test$i.tar.gz --format=posix test$i | ||
done | ||
|
||
rm -rf test1 test2 |
Binary file not shown.
Binary file not shown.
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