From 24f87615e63b27eea3e790ca3e100f8dbbbef1de Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 31 May 2019 21:32:54 -0400 Subject: Refactor to accept Session_t --- source/merge.d | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'source/merge.d') diff --git a/source/merge.d b/source/merge.d index 96773a6..4e715b4 100644 --- a/source/merge.d +++ b/source/merge.d @@ -12,6 +12,7 @@ import std.stdio; import std.string; import conda; import util; +import session; import dyaml : dumper, Loader, Node; @@ -24,7 +25,7 @@ auto RE_DELIVERY_NAME = regex(r"(?P.*)[-_](?P.*)[-_]py(?P package: %-15s :: version: %s", record["name"], !record["version"].empty ? record["version"] : "any"); @@ -86,9 +86,9 @@ bool env_combine(ref Conda conda, string name, string specfile, string mergefile } -testable_t[] testable_packages(ref Conda conda, string mergefile) { +testable_t[] testable_packages(ref Conda conda, string[] inputs) { testable_t[] results; - foreach (record; dmfile(mergefile)) { + foreach (record; dmfile(inputs)) { Node meta; string pkg_d; string pkg; @@ -143,7 +143,10 @@ testable_t[] testable_packages(ref Conda conda, string mergefile) { return results; } -auto integration_test(ref Conda conda, string outdir, test_runner_t runner, testable_t pkg) { +auto integration_test(ref Session_t session, + ref Conda conda, + string outdir, + testable_t pkg) { import core.stdc.stdlib : exit; import std.ascii : letters; import std.conv : to; @@ -182,8 +185,16 @@ auto integration_test(ref Conda conda, string outdir, test_runner_t runner, test } } - if (runner.requires) { - if (conda.sh("python -m pip install -r " ~ runner.requires)) { + if (!session.test_conda_requirements.empty) { + if (conda.sh("conda install " + ~ safe_install(session.test_conda_requirements))) { + return 1; + } + } + + if (!session.test_pip_requirements.empty) { + if (conda.sh("python -m pip install " + ~ safe_install(session.test_pip_requirements))) { return 1; } } @@ -196,7 +207,7 @@ auto integration_test(ref Conda conda, string outdir, test_runner_t runner, test return 1; } - if (runner.program == "pytest" || runner.program == "py.test") { + if (session.test_program == "pytest" || session.test_program == "py.test") { string data; string pytest_cfg= "pytest.ini"; if (!pytest_cfg.exists) { @@ -206,7 +217,8 @@ auto integration_test(ref Conda conda, string outdir, test_runner_t runner, test File(pytest_cfg, "w+").write(data); } - if (conda.sh(runner.program ~ " " ~ runner.args ~ " --basetemp=" ~ basetemp)) { + if (conda.sh(session.test_program ~ " " + ~ session.test_args ~ " --basetemp=" ~ basetemp)) { return 1; } return 0; -- cgit