Skip to content

Commit

Permalink
Add global workspace tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey committed Jul 6, 2023
1 parent 9c57296 commit d5dcdb3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,16 @@ jobs:
- name: Run No-Workspace-With-Plugins Tests
working-directory: test_apps/no_workspace
run: pytest test_no_workspace.py::TestNoWorkspaceWithPlugins -vv

# Leave the no-workspace setup. The global setup should override
- name: Run Global No-Plugins One Above Site-Packages Dir
working-directory: test_apps/no_workspace
run: pytest test_global_install.py::TestGlobalInstallNoPlugins -vv

- name: Run Global With Plugins At Site-Packages Dir
working-directory: test_apps/no_workspace
run: pytest test_global_install.py::TestGlobalInstallWithPlugins -vv

- name: Run Global No-Plugins At CLI Dir
working-directory: test_apps/no_workspace
run: pytest test_global_install.py::TestGlobalInstallAtCliDir -vv
10 changes: 9 additions & 1 deletion test_apps/no_workspace/t_invocation_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

# Assume pip is installed in 'site-packages'
site_packages_dir = pathlib.Path(pip.__file__).parent.parent
site_cli_dir = site_packages_dir.joinpath("origen/__bin__/bin")

class T_InvocationBaseTests(CLI):
site_packages_dir = site_packages_dir
site_cli_dir = site_cli_dir
templates_dir = no_workspace_test_dir.joinpath("templates")
templates_out_dir = templates_dir.joinpath("output")
debug_cli_dir = debug_cli_dir
Expand Down Expand Up @@ -129,7 +132,12 @@ def gen_pyproj(cls):
cls.templates_out_dir.mkdir(exist_ok=True)
pyproj = cls.templates_out_dir.joinpath(f"{cls.__name__}.{toml}")
with open(pyproj, "w") as f:
f.write(t.render(local_origen=cls.local_origen, name=cls.__name__, o2_root=o2_root))
f.write(t.render(
local_origen=cls.local_origen,
name=cls.__name__,
o2_root=o2_root,
has_pls=cls.has_pls,
))
return pyproj

# TEST_NEEDED invocation origen/metal package locations
Expand Down
6 changes: 3 additions & 3 deletions test_apps/no_workspace/templates/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ origen_metal = { path = "{{ o2_root }}/python/origen_metal", develop = true }
origen = ">= 0.0.0"
origen_metal = ">= 0.0.0"
{% endif %}
{% if include_plugins %}
{% if has_pls %}
{% if local_origen %}
pl_ext_cmds = { path = "{{ o2_root }}/test_apps/pl_ext_cmds", develop = true }
python_plugin = { path = "{{ o2_root }}/test_apps/python_plugin", develop = true }
test_apps_shared_test_helpers = { path = "{{ o2_root }}/test_apps/test_apps_shared_test_helpers", develop = true }
{% else %}
pl_ext_cmds = ">= 0.0.0"
python_plugin = ">= 0.0.0"
test_apps_shared_test_helpers = ">= 0.0.0"
{% endif %}
{% endif %}
33 changes: 33 additions & 0 deletions test_apps/no_workspace/test_global_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from .t_invocation_env import T_InvocationEnv, PyProjectSrc

class GlobalInstalBase(T_InvocationEnv):
@classmethod
def set_params(cls):
cls.local_origen = True
cls.invocation = PyProjectSrc.Global
cls.cli_dir = cls.site_cli_dir
cls.file_based_evals = True

# Pyproject closer to root - no plugins
class TestGlobalInstallNoPlugins(GlobalInstalBase):
@classmethod
def set_params(cls):
super().set_params()
cls.target_pyproj_dir = cls.site_packages_dir.parent
cls.has_pls = False

# Pyproject at site-packages dir - with plugins
class TestGlobalInstallWithPlugins(GlobalInstalBase):
@classmethod
def set_params(cls):
super().set_params()
cls.target_pyproj_dir = cls.site_packages_dir
cls.has_pls = True

# Pyproject at binary location - no plugins
class TestGlobalInstallAtCliDir(GlobalInstalBase):
@classmethod
def set_params(cls):
super().set_params()
cls.target_pyproj_dir = cls.site_cli_dir
cls.has_pls = False

0 comments on commit d5dcdb3

Please sign in to comment.