Skip to content

Commit

Permalink
TST: Avoid more package collisions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carterbox committed Apr 25, 2024
1 parent 4f988f9 commit b33f6f6
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 61 deletions.
12 changes: 7 additions & 5 deletions tests/test-recipes/split-packages/copying_files/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ echo "weee" > %PREFIX%\subpackage_file2.ext
echo "weee" > %PREFIX%\subpackage_file3.ext

echo "weee" > %PREFIX%\subpackage_include_exclude1
mkdir %PREFIX%\somedir
echo "weee" > %PREFIX%\somedir\subpackage_include_exclude1
echo "weee" > %PREFIX%\subpackage_include_exclude1.ext
echo "weee" > %PREFIX%\subpackage_include_exclude2.ext
echo "weee" > %PREFIX%\subpackage_include_exclude3.ext
mkdir %PREFIX%\anotherdir
echo "weee" > %PREFIX%\anotherdir\subpackage_include_exclude1
echo "weee" > %PREFIX%\subpackage_include_exclude1.wav
echo "weee" > %PREFIX%\subpackage_include_exclude2.wav
echo "weee" > %PREFIX%\subpackage_include_exclude3.wav
mkdir %PREFIX%\Library\bin
echo "weee" > %PREFIX%\Library\bin\dav1d.fake
12 changes: 7 additions & 5 deletions tests/test-recipes/split-packages/copying_files/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ echo "weee" > $PREFIX/subpackage_file3.ext
# test copying filename
echo "weee" > $PREFIX/subpackage_include_exclude1
# test copying by folder name
mkdir $PREFIX/somedir
echo "weee" > $PREFIX/somedir/subpackage_include_exclude1
mkdir $PREFIX/anotherdir
echo "weee" > $PREFIX/anotherdir/subpackage_include_exclude1
# test glob patterns
echo "weee" > $PREFIX/subpackage_include_exclude1.ext
echo "weee" > $PREFIX/subpackage_include_exclude2.ext
echo "weee" > $PREFIX/subpackage_include_exclude3.ext
echo "weee" > $PREFIX/subpackage_include_exclude1.wav
echo "weee" > $PREFIX/subpackage_include_exclude2.wav
echo "weee" > $PREFIX/subpackage_include_exclude3.wav
mkdir $PREFIX/lib
echo "weee" > $PREFIX/lib/libdav1d.fake
6 changes: 3 additions & 3 deletions tests/test-recipes/split-packages/copying_files/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ outputs:
files:
include:
- subpackage_include_exclude1
- somedir
- "*.ext"
- anotherdir
- "*.wav"
# Libs should not match because they come from a different package
- "lib/libdav1d*" # [unix]
- "Library/bin/dav1d*" # [win]
exclude:
- "*3.ext"
- "*3.wav"
test:
script: subpackage_test.py
script_interpreter: python
100 changes: 52 additions & 48 deletions tests/test-recipes/split-packages/copying_files/subpackage_test.py
Original file line number Diff line number Diff line change
@@ -1,69 +1,73 @@
import os

if os.getenv('PKG_NAME') == 'my_script_subpackage_files':
if os.getenv("PKG_NAME") == "my_script_subpackage_files":
file_basename = "subpackage_file"
dirname = "somedir"
extension = "ext"

file_basename = 'subpackage_file1'
external_host_file = "lib/libpng16.so"
if "osx" in os.getenv("target_platform", ""):
external_host_file = "lib/libpng16.dylib"
if "win" in os.getenv("target_platform", ""):
external_host_file = "Library/bin/libpng16.dll"

external_host_file = 'lib/libpng16.so'
if 'osx' in os.getenv('target_platform', ''):
external_host_file = 'lib/libpng16.dylib'
if 'win' in os.getenv('target_platform', ''):
external_host_file = 'Library/bin/libpng16.dll'
filename = os.path.join(os.environ["PREFIX"], f"{file_basename}3.{extension}")
print(filename)
assert os.path.isfile(filename), filename + " is missing"
print("glob files OK")

filename = os.path.join(os.environ['PREFIX'], f'{file_basename}3.ext')
assert os.path.isfile(filename)
print('glob files OK')
filename = os.path.join(os.environ["PREFIX"], external_host_file)
print(filename)
assert os.path.isfile(filename), filename + " is missing"
print("glob files prefix OK")

filename = os.path.join(os.environ['PREFIX'], external_host_file)
assert os.path.isfile(filename)
print('glob files prefix OK')
if os.getenv("PKG_NAME") == "my_script_subpackage_include_exclude":
file_basename = "subpackage_include_exclude"
dirname = "anotherdir"
extension = "wav"

if os.getenv('PKG_NAME') == 'my_script_subpackage_include_exclude':
external_host_file = "lib/libdav1d.so.6"
if "osx" in os.getenv("target_platform", ""):
external_host_file = "lib/libdav1d.6.dylib"
if "win" in os.getenv("target_platform", ""):
external_host_file = "Library/bin/dav1d.dll"

file_basename = 'subpackage_include_exclude1'
filename = os.path.join(os.environ["PREFIX"], f"{file_basename}3.{extension}")
assert not os.path.isfile(filename), filename + " is missing"
print("glob exclude OK")

external_host_file = 'lib/libdav1d.so.6'
if 'osx' in os.getenv('target_platform', ''):
external_host_file = 'lib/libdav1d.6.dylib'
if 'win' in os.getenv('target_platform', ''):
external_host_file = 'Library/bin/dav1d.dll'
filename = os.path.join(os.environ["PREFIX"], external_host_file)
assert not os.path.isfile(filename), filename + " is missing"
print("glob exclude prefix OK")

filename = os.path.join(os.environ['PREFIX'], f'{file_basename}3.ext')
assert not os.path.isfile(filename)
print('glob exclude OK')

filename = os.path.join(os.environ['PREFIX'], external_host_file)
assert not os.path.isfile(filename)
print('glob exclude prefix OK')

print(os.getenv('PREFIX'))
filename = os.path.join(os.environ['PREFIX'], f'{file_basename}1')
assert os.path.isfile(filename)
print(os.getenv("PREFIX"))
filename = os.path.join(os.environ["PREFIX"], f"{file_basename}1")
assert os.path.isfile(filename), filename + " is missing"
contents = open(filename).read().rstrip()
if hasattr(contents, 'decode'):
if hasattr(contents, "decode"):
contents = contents.decode()
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('plain file OK')
assert "weee" in contents, "incorrect file contents: %s" % contents
print("plain file OK")

filename = os.path.join(os.environ['PREFIX'], 'somedir', f'{file_basename}1')
assert os.path.isfile(filename), filename + ' is missing'
filename = os.path.join(os.environ["PREFIX"], dirname, f"{file_basename}1")
assert os.path.isfile(filename), filename + " is missing"
contents = open(filename).read().rstrip()
if hasattr(contents, 'decode'):
if hasattr(contents, "decode"):
contents = contents.decode()
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('subfolder file OK')
assert "weee" in contents, "incorrect file contents: %s" % contents
print("subfolder file OK")

filename = os.path.join(os.environ['PREFIX'], f'{file_basename}1.ext')
assert os.path.isfile(filename)
filename = os.path.join(os.environ["PREFIX"], f"{file_basename}1.{extension}")
assert os.path.isfile(filename), filename + " is missing"
contents = open(filename).read().rstrip()
if hasattr(contents, 'decode'):
if hasattr(contents, "decode"):
contents = contents.decode()
assert 'weee' in contents, 'incorrect file contents: %s' % contents
assert "weee" in contents, "incorrect file contents: %s" % contents

filename = os.path.join(os.environ['PREFIX'], f'{file_basename}2.ext')
assert os.path.isfile(filename)
filename = os.path.join(os.environ["PREFIX"], f"{file_basename}2.{extension}")
assert os.path.isfile(filename), filename + " is missing"
contents = open(filename).read().rstrip()
if hasattr(contents, 'decode'):
if hasattr(contents, "decode"):
contents = contents.decode()
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('glob OK')
assert "weee" in contents, "incorrect file contents: %s" % contents
print("glob OK")

0 comments on commit b33f6f6

Please sign in to comment.