Skip to content

Commit

Permalink
Update run-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Apr 27, 2024
1 parent f5ef427 commit 681ece5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions run_tests.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python
import os
from os.path import dirname, join, abspath
import sqlite3
import sys
import os
import re


Expand Down Expand Up @@ -95,16 +93,21 @@ def main():
# Statically check if ``package_name`` is installed outside of the repo.
# To do this, we make a copy of PYTHONPATH, remove the repodir, and use
# ubelt to check to see if ``package_name`` can be resolved to a path.
temp_path = list(map(abspath, sys.path))
if repo_dir in temp_path:
temp_path.remove(repo_dir)
temp_path = [pathlib.Path(p).resolve() for p in sys.path]
_resolved_repo_dir = repo_dir.resolve()
if _resolved_repo_dir in temp_path:
temp_path.remove(_resolved_repo_dir)
print(f'[run_tests] Searching for installed version of {package_name}.')
modpath = ub.modname_to_modpath(package_name, sys_path=temp_path)
if modpath is not None:
# If it does, then import it. This should cause the installed version
# to be used on further imports even if the repo_dir is in the path.
print(f'[run_tests] Using installed version of {package_name}')
module = ub.import_module_from_path(modpath, index=0)
print(f'[run_tests] Installed module = {module!r}')
print(f'[run_tests] modpath={modpath}')
modpath_contents = list(pathlib.Path(modpath).glob('*'))
print(f'[run_tests] modpath_contents = {ub.urepr(modpath_contents, nl=1)}')
# module = ub.import_module_from_path(modpath, index=0)
# print(f'[run_tests] Installed module = {module!r}')
else:
print(f'[run_tests] No installed version of {package_name} found')

Expand All @@ -113,12 +116,9 @@ def main():
os.chdir(test_dir)

testdir_contents = list(pathlib.Path(test_dir).glob('*'))
modpath_contents = list(pathlib.Path(modpath).glob('*'))
pyproject_fpath = join(repo_dir, 'pyproject.toml')
pyproject_fpath = repo_dir / 'pyproject.toml'
print(f'[run_tests] pyproject_fpath = {pyproject_fpath}')
print(f'[run_tests] modpath={modpath}')
print(f'[run_tests] test_dir={test_dir}')
print(f'[run_tests] modpath_contents = {ub.urepr(modpath_contents, nl=1)}')
print(f'[run_tests] testdir_contents = {ub.urepr(testdir_contents, nl=1)}')

pytest_args = [
Expand Down

0 comments on commit 681ece5

Please sign in to comment.