From 429591910359dd7487dc111298eaf1f36121631d Mon Sep 17 00:00:00 2001 From: mefyl Date: Mon, 26 Feb 2018 12:17:34 +0100 Subject: [PATCH] Add test for "/.." patterns in .dockerignore. Signed-off-by: mefyl --- tests/unit/utils_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 8a4b1937..c2dd502b 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -902,6 +902,22 @@ class ExcludePathsTest(unittest.TestCase): ['*.md', '!README*.md', 'README-secret.md'] ) == set(['README.md', 'README-bis.md']) + def test_parent_directory(self): + base = make_tree( + [], + ['a.py', + 'b.py', + 'c.py']) + # Dockerignore reference stipulates that absolute paths are + # equivalent to relative paths, hence /../foo should be + # equivalent to ../foo. It also stipulates that paths are run + # through Go's filepath.Clean, which explicitely "replace + # "/.." by "/" at the beginning of a path". + assert exclude_paths( + base, + ['../a.py', '/../b.py'] + ) == set(['c.py']) + class TarTest(unittest.TestCase): def test_tar_with_excludes(self):