diff options
-rw-r--r-- | source/app.d | 36 | ||||
-rw-r--r-- | source/conda.d | 10 | ||||
-rw-r--r-- | source/ini.d | 27 | ||||
-rw-r--r-- | source/merge.d | 22 | ||||
-rw-r--r-- | source/util.d | 1 |
5 files changed, 78 insertions, 18 deletions
diff --git a/source/app.d b/source/app.d index 71b8d9e..47c1ad7 100644 --- a/source/app.d +++ b/source/app.d @@ -20,6 +20,9 @@ int main(string[] args) { string test_requires; // pip requirements file string mergefile; string base_spec; + string dumpfile_yaml; + string dumpfile_explicit; + string dumpfile_freeze; // disable buffering stdout.setvbuf(0, _IONBF); @@ -56,10 +59,19 @@ int main(string[] args) { output_dir = buildPath(output_dir, env_name).absolutePath; mergefile = buildPath(mergefile).absolutePath; + dumpfile_yaml = buildPath(output_dir, env_name ~ ".yml"); + dumpfile_explicit = buildPath(output_dir, env_name ~ ".txt"); + dumpfile_freeze = buildPath(output_dir, env_name ~ ".pip"); + if (!test_requires.empty) { test_requires = buildPath(test_requires).absolutePath; } + if (!test_requires.exists) { + writeln("--test-requires, file not found: '" ~ test_requires ~ "'"); + return 1; + } + if (installer_variant != "3") { writeln("Python 2.7 has reached end-of-life."); writeln("3.x variant will be used instead."); @@ -110,18 +122,30 @@ int main(string[] args) { output_dir.mkdirRecurse; } - conda.dump_env_yaml(buildPath(output_dir, env_name ~ ".yml")); - conda.dump_env_explicit(buildPath(output_dir, env_name ~ ".txt")); + writeln("Creating YAML dump: " ~ dumpfile_yaml); + conda.dump_env_yaml(dumpfile_yaml); + writeln("Creating explicit dump: " ~ dumpfile_explicit); + conda.dump_env_explicit(dumpfile_explicit); + writeln("Creating pip-freeze dump: " ~ dumpfile_freeze); + conda.dump_env_freeze(dumpfile_freeze); if (run_tests) { + int failures = 0; string testdir = buildPath(output_dir, "testdir"); test_runner_t runner = test_runner_t(test_program, test_args, test_requires); - testable_t[] testable = testable_packages(conda, mergefile); - foreach (t; testable) { - integration_test(conda, testdir, runner, t); + testable_t[] pkgs = testable_packages(conda, mergefile); + + foreach (pkg; pkgs) { + failures += integration_test(conda, testdir, runner, pkg); + } + + if (failures) { + writefln("%d of %d integration tests failed!", failures, pkgs.length); + } else { + writefln("All integration tests passed!"); } } - writeln("Done!"); + writefln("Done!"); return 0; } diff --git a/source/conda.d b/source/conda.d index ff44b50..7b30c56 100644 --- a/source/conda.d +++ b/source/conda.d @@ -275,4 +275,14 @@ class Conda { } return proc.output; } + + string dump_env_freeze(string filename=null) { + auto proc = this.sh_block("pip freeze"); + if (filename !is null) { + auto file = File(filename, "w+"); + file.write(proc.output); + } + return proc.output; + } + } diff --git a/source/ini.d b/source/ini.d new file mode 100644 index 0000000..c23f080 --- /dev/null +++ b/source/ini.d @@ -0,0 +1,27 @@ +module ini; + +import std.stdio; +import std.file; +import std.array; + + +struct Section_t { + string name; + string[string][] pairs; +} + +class ConfigParser { + File file; + string[string][] pairs; + int[] section_pos; + + this(File file) { + this.file = file; + } + + auto _parse() { + foreach (line; this.file.byLine) { + writeln("-> " ~ line); + } + } +} diff --git a/source/merge.d b/source/merge.d index f63a5da..7de55fe 100644 --- a/source/merge.d +++ b/source/merge.d @@ -150,6 +150,11 @@ auto integration_test(ref Conda conda, string outdir, test_runner_t runner, test import std.random : randomSample; import std.utf : byCodeUnit; + auto id = letters.byCodeUnit.randomSample(6).to!string; + string basetemp = tempDir.buildPath("dm_testable_" ~ id); + basetemp.mkdir; + scope(exit) basetemp.rmdirRecurse; + string cwd = getcwd().absolutePath; scope (exit) cwd.chdir; string repo_root = buildPath(outdir, pkg.repo.baseName) @@ -158,14 +163,14 @@ auto integration_test(ref Conda conda, string outdir, test_runner_t runner, test if (!repo_root.exists) { if (conda.sh("git clone --recursive " ~ pkg.repo ~ " " ~ repo_root)) { - exit(1); + return 1; } } repo_root.chdir; if (conda.sh("git checkout " ~ pkg.head)) { - exit(1); + return 1; } foreach (string found; conda.scan_packages(repo_root.baseName ~ "*")) { @@ -177,25 +182,20 @@ 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)) { - exit(1); + return 1; } } if (conda.sh("python -m pip install .[test]")) { - exit(1); + return 1; } if (conda.sh("python setup.py egg_info")) { - exit(1); + return 1; } - auto id = letters.byCodeUnit.randomSample(6).to!string; - string basetemp = tempDir.buildPath("dm_testable" ~ id); - basetemp.mkdir; - scope(exit) basetemp.rmdirRecurse; - if (conda.sh(runner.program ~ " " ~ runner.args ~ " --basetemp=" ~ basetemp) > 1) { - exit(1); + return 1; } return 0; } diff --git a/source/util.d b/source/util.d index d49f9d7..04b8be7 100644 --- a/source/util.d +++ b/source/util.d @@ -93,4 +93,3 @@ string safe_install(string specs) { } return result.join(" "); } - |