Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
73d8097b
Kaydet (Commit)
73d8097b
authored
Mar 28, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix test issues
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
7fa30a71
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
54 deletions
+48
-54
appveyor.yml
appveyor.yml
+0
-1
build.py
docker/utils/build.py
+7
-3
fnmatch.py
docker/utils/fnmatch.py
+3
-6
utils_test.py
tests/unit/utils_test.py
+37
-43
tox.ini
tox.ini
+1
-1
No files found.
appveyor.yml
Dosyayı görüntüle @
73d8097b
version
:
'
{branch}-{build}'
install
:
...
...
docker/utils/build.py
Dosyayı görüntüle @
73d8097b
import
os
from
..constants
import
IS_WINDOWS_PLATFORM
from
.fnmatch
import
fnmatch
from
.utils
import
create_archive
...
...
@@ -39,7 +40,7 @@ def exclude_paths(root, patterns, dockerfile=None):
# If the Dockerfile is in a subdirectory that is excluded, get_paths
# will not descend into it and the file will be skipped. This ensures
# it doesn't happen.
set
([
dockerfile
])
set
([
dockerfile
.
replace
(
'/'
,
os
.
path
.
sep
)
])
if
os
.
path
.
exists
(
os
.
path
.
join
(
root
,
dockerfile
))
else
set
()
)
...
...
@@ -130,9 +131,12 @@ def match_path(path, pattern):
if
pattern
:
pattern
=
os
.
path
.
relpath
(
pattern
)
pattern_components
=
pattern
.
split
(
os
.
path
.
sep
)
if
len
(
pattern_components
)
==
1
and
IS_WINDOWS_PLATFORM
:
pattern_components
=
pattern
.
split
(
'/'
)
if
'**'
not
in
pattern
:
pattern_components
=
pattern
.
split
(
os
.
path
.
sep
)
path_components
=
path
.
split
(
os
.
path
.
sep
)[:
len
(
pattern_components
)]
else
:
path_components
=
path
.
split
(
os
.
path
.
sep
)
return
fnmatch
(
'/'
.
join
(
path_components
),
pattern
)
return
fnmatch
(
'/'
.
join
(
path_components
),
'/'
.
join
(
pattern_components
)
)
docker/utils/fnmatch.py
Dosyayı görüntüle @
73d8097b
...
...
@@ -39,15 +39,13 @@ def fnmatch(name, pat):
If you don't want this, use fnmatchcase(FILENAME, PATTERN).
"""
import
os
name
=
os
.
path
.
normcase
(
name
)
pat
=
os
.
path
.
normcase
(
pat
)
name
=
name
.
lower
()
pat
=
pat
.
lower
()
return
fnmatchcase
(
name
,
pat
)
def
fnmatchcase
(
name
,
pat
):
"""Test whether FILENAME matches PATTERN, including case.
This is a version of fnmatch() which doesn't case-normalize
its arguments.
"""
...
...
@@ -67,7 +65,6 @@ def translate(pat):
There is no way to quote meta-characters.
"""
recursive_mode
=
False
i
,
n
=
0
,
len
(
pat
)
res
=
''
...
...
@@ -100,7 +97,7 @@ def translate(pat):
stuff
=
'
\\
'
+
stuff
res
=
'
%
s[
%
s]'
%
(
res
,
stuff
)
elif
recursive_mode
and
c
==
'/'
:
res
=
res
+
'/
?'
res
=
res
+
re
.
escape
(
c
)
+
'
?'
else
:
res
=
res
+
re
.
escape
(
c
)
return
res
+
'
\
Z(?ms)'
tests/unit/utils_test.py
Dosyayı görüntüle @
73d8097b
...
...
@@ -618,9 +618,11 @@ class PortsTest(unittest.TestCase):
def
convert_paths
(
collection
):
if
not
IS_WINDOWS_PLATFORM
:
return
collection
return
set
(
map
(
lambda
x
:
x
.
replace
(
'/'
,
'
\\
'
),
collection
))
return
set
(
map
(
convert_path
,
collection
))
def
convert_path
(
path
):
return
path
.
replace
(
'/'
,
os
.
path
.
sep
)
class
ExcludePathsTest
(
unittest
.
TestCase
):
...
...
@@ -685,12 +687,12 @@ class ExcludePathsTest(unittest.TestCase):
set
([
'Dockerfile.alt'
,
'.dockerignore'
])
assert
self
.
exclude
([
'*'
],
dockerfile
=
'foo/Dockerfile3'
)
==
\
set
([
'foo/Dockerfile3'
,
'.dockerignore'
]
)
convert_paths
(
set
([
'foo/Dockerfile3'
,
'.dockerignore'
])
)
def
test_exclude_dockerfile_child
(
self
):
includes
=
self
.
exclude
([
'foo/'
],
dockerfile
=
'foo/Dockerfile3'
)
assert
'foo/Dockerfile3'
in
includes
assert
'foo/a.py'
not
in
includes
assert
convert_path
(
'foo/Dockerfile3'
)
in
includes
assert
convert_path
(
'foo/a.py'
)
not
in
includes
def
test_single_filename
(
self
):
assert
self
.
exclude
([
'a.py'
])
==
convert_paths
(
...
...
@@ -917,6 +919,7 @@ class TarTest(unittest.TestCase):
sorted
(
tar_data
.
getnames
()),
[
'bar'
,
'bar/foo'
,
'foo'
]
)
@pytest.mark.skipif
(
IS_WINDOWS_PLATFORM
,
reason
=
'No UNIX sockets on Win32'
)
def
test_tar_socket_file
(
self
):
base
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
base
)
...
...
@@ -945,62 +948,53 @@ class ShouldCheckDirectoryTest(unittest.TestCase):
]
def
test_should_check_directory_not_excluded
(
self
):
self
.
assertTrue
(
should_check_directory
(
'not_excluded'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
'not_excluded'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
self
.
assertTrue
(
should_check_directory
(
'dir/with'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
convert_path
(
'dir/with'
),
self
.
exclude_patterns
,
self
.
include_patterns
)
def
test_shoud_check_parent_directories_of_excluded
(
self
):
self
.
assertTrue
(
should_check_directory
(
'dir'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
'dir'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
self
.
assertTrue
(
should_check_directory
(
'dir/with'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
convert_path
(
'dir/with'
)
,
self
.
exclude_patterns
,
self
.
include_patterns
)
def
test_should_not_check_excluded_directories_with_no_exceptions
(
self
):
self
.
assertFalse
(
should_check_directory
(
'exclude_rather_large_directory'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
not
should_check_directory
(
'exclude_rather_large_directory'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
self
.
assertFalse
(
should_check_directory
(
'dir/with/subdir_excluded'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
not
should_check_directory
(
convert_path
(
'dir/with/subdir_excluded'
),
self
.
exclude_patterns
,
self
.
include_patterns
)
def
test_should_check_excluded_directory_with_exceptions
(
self
):
self
.
assertTrue
(
should_check_directory
(
'dir/with/exceptions'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
convert_path
(
'dir/with/exceptions'
),
self
.
exclude_patterns
,
self
.
include_patterns
)
self
.
assertTrue
(
should_check_directory
(
'dir/with/exceptions/in'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
convert_path
(
'dir/with/exceptions/in'
),
self
.
exclude_patterns
,
self
.
include_patterns
)
def
test_should_not_check_siblings_of_exceptions
(
self
):
self
.
assertFalse
(
should_check_directory
(
'dir/with/exceptions/but_not_here'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
not
should_check_directory
(
convert_path
(
'dir/with/exceptions/but_not_here'
),
self
.
exclude_patterns
,
self
.
include_patterns
)
def
test_should_check_subdirectories_of_exceptions
(
self
):
self
.
assertTrue
(
should_check_directory
(
'dir/with/exceptions/like_this_one/subdir'
,
self
.
exclude_patterns
,
self
.
include_patterns
)
assert
should_check_directory
(
convert_path
(
'dir/with/exceptions/like_this_one/subdir'
),
self
.
exclude_patterns
,
self
.
include_patterns
)
...
...
tox.ini
Dosyayı görüntüle @
73d8097b
...
...
@@ -5,7 +5,7 @@ skipsdist=True
[testenv]
usedevelop
=
True
commands
=
py.test
--cov
=
docker {posargs:tests/unit}
py.test
-
v
-
-cov
=
docker {posargs:tests/unit}
deps
=
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment