Skip to content

Commit

Permalink
TST: Robust testing of new filematching
Browse files Browse the repository at this point in the history
  • Loading branch information
carterbox committed Mar 21, 2024
1 parent e16c470 commit e598d6a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
3 changes: 2 additions & 1 deletion tests/test-recipes/split-packages/copying_files/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ echo "weee" > %PREFIX%\subpackage_file1
mkdir %PREFIX%\somedir
echo "weee" > %PREFIX%\somedir\subpackage_file1
echo "weee" > %PREFIX%\subpackage_file1.ext
echo "weee" > %PREFIX%\subpackage_file2.ext
echo "weee" > %PREFIX%\subpackage_file2.ext
echo "weee" > %PREFIX%\subpackage_file3.ext
22 changes: 21 additions & 1 deletion tests/test-recipes/split-packages/copying_files/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,32 @@ requirements:
- my_script_subpackage

outputs:
- name: my_script_subpackage
- name: my_script_subpackage_files
requirements:
host:
- libdav1d7
files:
- subpackage_file1
- somedir
- "*.ext"
# Libs should match because they are in the prefix
- "lib/libdav1d*"
- "Library/bin/dav1d*"
test:
script: subpackage_test.py
script_interpreter: python
- name: my_script_subpackage_include_exclude
requirements:
host:
- libdav1d7
files:
include:
- subpackage_file1
- somedir
- "*.ext"
# Libs should not match because they come from a different package
- "lib/libdav1d*"
- "Library/bin/dav1d*"
exclude:
- "*3.ext"
test:
Expand Down
42 changes: 31 additions & 11 deletions tests/test-recipes/split-packages/copying_files/subpackage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,52 @@
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")
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('plain file OK')

filename = os.path.join(os.environ['PREFIX'], 'somedir', 'subpackage_file1')
assert os.path.isfile(filename), filename + " is missing"
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")
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('subfolder file OK')

filename = os.path.join(os.environ['PREFIX'], 'subpackage_file1.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
assert 'weee' in contents, 'incorrect file contents: %s' % contents

filename = os.path.join(os.environ['PREFIX'], 'subpackage_file2.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")
assert 'weee' in contents, 'incorrect file contents: %s' % contents
print('glob OK')

filename = os.path.join(os.environ['PREFIX'], 'subpackage_file3.ext')
assert not os.path.isfile(filename)
print("glob exclude OK")
external_host_file = 'lib/libdav1d.so.7'
if 'osx' in os.getenv('target_platform', ''):
external_host_file = 'lib/libdav1d.7.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 e598d6a

Please sign in to comment.