Skip to content

Commit

Permalink
TST: Avoid package collisions in subpackage tests
Browse files Browse the repository at this point in the history
Package collisions cause errors.
  • Loading branch information
carterbox committed Apr 25, 2024
1 parent 475c0ec commit 4f988f9
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 33 deletions.
7 changes: 7 additions & 0 deletions tests/test-recipes/split-packages/copying_files/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ echo "weee" > %PREFIX%\somedir\subpackage_file1
echo "weee" > %PREFIX%\subpackage_file1.ext
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
12 changes: 12 additions & 0 deletions tests/test-recipes/split-packages/copying_files/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ echo "weee" > $PREFIX/somedir/subpackage_file1
echo "weee" > $PREFIX/subpackage_file1.ext
echo "weee" > $PREFIX/subpackage_file2.ext
echo "weee" > $PREFIX/subpackage_file3.ext

# The files used to test the two subpackages must be disjoint because they are
# coinstalled
# test copying filename
echo "weee" > $PREFIX/subpackage_include_exclude1
# test copying by folder name
mkdir $PREFIX/somedir
echo "weee" > $PREFIX/somedir/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
10 changes: 5 additions & 5 deletions tests/test-recipes/split-packages/copying_files/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ outputs:
- name: my_script_subpackage_files
build:
ignore_run_exports_from:
- dav1d
- libpng
requirements:
host:
- dav1d=1.2.1
- libpng=1.6.39
files:
- subpackage_file1
- somedir
- "*.ext"
# Libs should match because they are in the prefix
- "lib/libdav1d*" # [unix]
- "Library/bin/dav1d*" # [win]
- "lib/libpng*" # [unix]
- "Library/bin/libpng*" # [win]
test:
script: subpackage_test.py
script_interpreter: python
Expand All @@ -34,7 +34,7 @@ outputs:
- dav1d=1.2.1
files:
include:
- subpackage_file1
- subpackage_include_exclude1
- somedir
- "*.ext"
# Libs should not match because they come from a different package
Expand Down
68 changes: 40 additions & 28 deletions tests/test-recipes/split-packages/copying_files/subpackage_test.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,69 @@
import os

if os.getenv('PKG_NAME') == 'my_script_subpackage_files':

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'

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)
assert os.path.isfile(filename)
print('glob files prefix OK')

if os.getenv('PKG_NAME') == 'my_script_subpackage_include_exclude':

file_basename = 'subpackage_include_exclude1'

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'], 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'], 'subpackage_file1')
filename = os.path.join(os.environ['PREFIX'], f'{file_basename}1')
assert os.path.isfile(filename)
contents = open(filename).read().rstrip()
if hasattr(contents, 'decode'):
contents = contents.decode()
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('plain file OK')

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

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

filename = os.path.join(os.environ['PREFIX'], 'subpackage_file2.ext')
filename = os.path.join(os.environ['PREFIX'], f'{file_basename}2.ext')
assert os.path.isfile(filename)
contents = open(filename).read().rstrip()
if hasattr(contents, 'decode'):
contents = contents.decode()
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('glob 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'

if os.getenv('PKG_NAME') == 'my_script_subpackage_files':
filename = os.path.join(os.environ['PREFIX'], 'subpackage_file3.ext')
assert os.path.isfile(filename)
print('glob files 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':
filename = os.path.join(os.environ['PREFIX'], 'subpackage_file3.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')

0 comments on commit 4f988f9

Please sign in to comment.