fix: test-sources should use project dir (#2437)
* fix: test-sources should use project dir Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * docs: fix docstring Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
@@ -565,7 +565,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
if build_options.test_sources:
|
if build_options.test_sources:
|
||||||
copy_test_sources(
|
copy_test_sources(
|
||||||
build_options.test_sources,
|
build_options.test_sources,
|
||||||
build_options.package_dir,
|
Path.cwd(),
|
||||||
testbed_app_path,
|
testbed_app_path,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ def build_in_container(
|
|||||||
if build_options.test_sources:
|
if build_options.test_sources:
|
||||||
copy_test_sources(
|
copy_test_sources(
|
||||||
build_options.test_sources,
|
build_options.test_sources,
|
||||||
build_options.package_dir,
|
Path.cwd(),
|
||||||
test_cwd,
|
test_cwd,
|
||||||
copy_into=container.copy_into,
|
copy_into=container.copy_into,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -712,7 +712,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
test_cwd.mkdir()
|
test_cwd.mkdir()
|
||||||
copy_test_sources(
|
copy_test_sources(
|
||||||
build_options.test_sources,
|
build_options.test_sources,
|
||||||
build_options.package_dir,
|
Path.cwd(),
|
||||||
test_cwd,
|
test_cwd,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
if build_options.test_sources:
|
if build_options.test_sources:
|
||||||
copy_test_sources(
|
copy_test_sources(
|
||||||
build_options.test_sources,
|
build_options.test_sources,
|
||||||
build_options.package_dir,
|
Path.cwd(),
|
||||||
test_cwd,
|
test_cwd,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
if build_options.test_sources:
|
if build_options.test_sources:
|
||||||
copy_test_sources(
|
copy_test_sources(
|
||||||
build_options.test_sources,
|
build_options.test_sources,
|
||||||
build_options.package_dir,
|
Path.cwd(),
|
||||||
test_cwd,
|
test_cwd,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -111,21 +111,21 @@ def copy_into_local(src: Path, dst: PurePath) -> None:
|
|||||||
|
|
||||||
def copy_test_sources(
|
def copy_test_sources(
|
||||||
test_sources: list[str],
|
test_sources: list[str],
|
||||||
package_dir: Path,
|
project_dir: Path,
|
||||||
test_dir: PurePath,
|
test_dir: PurePath,
|
||||||
copy_into: Callable[[Path, PurePath], None] = copy_into_local,
|
copy_into: Callable[[Path, PurePath], None] = copy_into_local,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Copy the list of test sources from the package to the test directory.
|
"""Copy the list of test sources from the package to the test directory.
|
||||||
|
|
||||||
:param test_sources: A list of test paths, relative to the package_dir.
|
:param test_sources: A list of test paths, relative to the project_dir.
|
||||||
:param package_dir: The root of the package directory.
|
:param project_dir: The root of the project.
|
||||||
:param test_dir: The folder where test sources should be placed.
|
:param test_dir: The folder where test sources should be placed.
|
||||||
:param copy_info: The copy function to use. By default, does a local
|
:param copy_into: The copy function to use. By default, does a local
|
||||||
filesystem copy; but an OCIContainer.copy_info method (or equivalent)
|
filesystem copy; but an OCIContainer.copy_info method (or equivalent)
|
||||||
can be provided.
|
can be provided.
|
||||||
"""
|
"""
|
||||||
for test_path in test_sources:
|
for test_path in test_sources:
|
||||||
source = package_dir.resolve() / test_path
|
source = project_dir.resolve() / test_path
|
||||||
|
|
||||||
if not source.exists():
|
if not source.exists():
|
||||||
msg = f"Test source {test_path} does not exist."
|
msg = f"Test source {test_path} does not exist."
|
||||||
|
|||||||
Reference in New Issue
Block a user