diff options
-rw-r--r-- | source/merge.d | 26 | ||||
-rw-r--r-- | source/session.d | 31 |
2 files changed, 56 insertions, 1 deletions
diff --git a/source/merge.d b/source/merge.d index fa625c8..0b55f92 100644 --- a/source/merge.d +++ b/source/merge.d @@ -165,6 +165,7 @@ int integration_test(ref Session_t session, import std.random : randomSample; import std.utf : byCodeUnit; + TestExtended_t te; auto id = letters.byCodeUnit.randomSample(6).to!string; string basetemp = tempDir.buildPath("dm_testable_" ~ id); basetemp.mkdir; @@ -206,6 +207,21 @@ int integration_test(ref Session_t session, } } + // Retrieve extended test data for this package + foreach (TestExtended_t t; session.test_extended) { + if (repo_root.baseName == t.name) { + te = t; + break; + } + } + + // Inject extended runtime environment early. + // a pip-installed package might need something. + foreach (string k, string v; te.runtime) { + te.runtime[k] = interpolate(conda.env, v).dup; + conda.env[k] = te.runtime[k]; + } + if (!session.test_pip_requirements.empty) { if (conda.sh("python -m pip install " ~ conda.multiarg("-i", session.pip_index) ~ " " @@ -233,8 +249,16 @@ int integration_test(ref Session_t session, File(pytest_cfg, "w+").write(data); } + // Execute extended commands + foreach (string cmd; te.commands) { + conda.sh(interpolate(conda.env, cmd)); + } + + // Run tests if (conda.sh(session.test_program ~ " " - ~ session.test_args ~ " --basetemp=" ~ basetemp)) { + ~ session.test_args ~ " " + ~ te.test_args ~ " " + ~ " --basetemp=" ~ basetemp)) { return 1; } return 0; diff --git a/source/session.d b/source/session.d index ef2a9e7..277353f 100644 --- a/source/session.d +++ b/source/session.d @@ -9,6 +9,13 @@ import util; import dyaml; +struct TestExtended_t { + string name; + string[string] runtime; + string test_args; + string[] commands; +} + struct Session_t { string delivery_name; string delivery_version; @@ -28,6 +35,7 @@ struct Session_t { bool run_tests = false; string test_program = "pytest"; string test_args = "-v"; + TestExtended_t[] test_extended; string[] test_conda_requirements; string[] test_pip_requirements; string[] test_filter_git_orgs; @@ -144,5 +152,28 @@ Session_t getconf(string filename) { foreach (Node v; data) session.test_filter_git_projects ~= v.as!string; } + + if (root.containsKey("test_extended")) { + TestExtended_t te; + data = root["test_extended"]; + + foreach (Node parent_1, Node child_1; data) { + te.name = parent_1.as!string; + if (child_1.containsKey("runtime")) { + foreach (Node parent_2, Node child_2; child_1["runtime"]) { + te.runtime[parent_2.as!string] = child_2.as!string; + } + } + if (child_1.containsKey("commands")) { + foreach (Node v; child_1["commands"]) { + te.commands ~= v.as!string.strip; + } + } + if (child_1.containsKey("test_args")) { + te.test_args = child_1["test_args"].as!string; + } + session.test_extended ~= te; + } + } return session; } |