From fbe7489804e8a0fa3d2883d482e979fec0161e4b Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Mon, 18 Jun 2018 08:17:58 +0200 Subject: [PATCH 1/8] Run integration tests in their own temporary directory Having not found a way to make `@chdir[I32]` or anything like that work, this commit adds a bash helper script that `cd`s into the directory before running stable. Also includes the code changes necessary to create the temporary dir from pony, and remove it after the tests are done. The former is done so that upcoming tests can use pony to set up some initial situation (such as drop a bundle.json). The cleanup is not done in a `tear_down()` method, because I found no non-clumsy way to get the reference to the directory into that spot. So instead, this has a mini-actor that deletes the temp dir when disposed, and is set up to be called by the test helper. Note that there's no strict need to run the existing integration tests in their own temp dirs, so we might make that temp dir passing optional, maybe, by changing `Exec`'s `cleaner arg from cleaner: DisposableActor to cleaner: (DisposableActor | None) and pass None for help and version. Signed-off-by: Stephan Renatus --- Makefile | 2 +- stable/test/integration/_clean_tmp.pony | 9 +++++++++ stable/test/integration/_exec.pony | 11 +++++++++-- stable/test/integration/helper.sh | 3 +++ stable/test/integration/test_usage.pony | 11 ++++++++++- stable/test/integration/test_version.pony | 11 ++++++++++- 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 stable/test/integration/_clean_tmp.pony create mode 100755 stable/test/integration/helper.sh diff --git a/Makefile b/Makefile index e4487f7..22eff1b 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ else endif SOURCE_FILES := $(shell find $(SRC_DIR) -path $(SRC_DIR)/test -prune -o -name \*.pony) -TEST_FILES := $(shell find $(SRC_DIR)/test -name \*.pony) +TEST_FILES := $(shell find $(SRC_DIR)/test -name \*.pony -o -name helper.sh) VERSION := "$(tag) [$(config)]" GEN_FILES_IN := $(shell find $(SRC_DIR) -name \*.pony.in) GEN_FILES = $(patsubst %.pony.in, %.pony, $(GEN_FILES_IN)) diff --git a/stable/test/integration/_clean_tmp.pony b/stable/test/integration/_clean_tmp.pony new file mode 100644 index 0000000..0507e6f --- /dev/null +++ b/stable/test/integration/_clean_tmp.pony @@ -0,0 +1,9 @@ +use "files" + +actor _CleanTmp + let _fp: FilePath + new create(fp: FilePath) => + _fp = fp + + be dispose() => + _fp.remove() diff --git a/stable/test/integration/_exec.pony b/stable/test/integration/_exec.pony index 4fdcd11..166bc12 100644 --- a/stable/test/integration/_exec.pony +++ b/stable/test/integration/_exec.pony @@ -7,6 +7,8 @@ actor _Exec new create( h: TestHelper, cmdline: String, + tmp: String, + cleaner: DisposableActor, notifier: ProcessNotify iso) => let stable_bin = @@ -18,13 +20,18 @@ actor _Exec end try let args = cmdline.split_by(" ") - let path = FilePath(h.env.root as AmbientAuth, stable_bin)? - let vars: Array[String] iso = [] + let path = FilePath(h.env.root as AmbientAuth, + "stable/test/integration/helper.sh")? let auth = h.env.root as AmbientAuth + let vars: Array[String] iso = [ + "CWD=" + tmp + "STABLE_BIN=" + stable_bin + ] let pm: ProcessMonitor = ProcessMonitor(auth, auth, consume notifier, path, consume args, consume vars) pm.done_writing() h.dispose_when_done(pm) + h.dispose_when_done(cleaner) else h.fail("Could not create FilePath!") end diff --git a/stable/test/integration/helper.sh b/stable/test/integration/helper.sh new file mode 100755 index 0000000..743fae2 --- /dev/null +++ b/stable/test/integration/helper.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd "$CWD" || exit 100 +exec "$STABLE_BIN" "$@" diff --git a/stable/test/integration/test_usage.pony b/stable/test/integration/test_usage.pony index 603dc00..8b50749 100644 --- a/stable/test/integration/test_usage.pony +++ b/stable/test/integration/test_usage.pony @@ -1,4 +1,5 @@ use "ponytest" +use "files" use "process" use ".." @@ -12,6 +13,14 @@ class TestUsage is UnitTest fun apply(h: TestHelper) => h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + let notifier: ProcessNotify iso = _ExpectClient(h, [ "Usage: stable COMMAND \\[\\.\\.\\.\\]" "A simple dependency manager for the Pony language" @@ -23,4 +32,4 @@ class TestUsage is UnitTest ], None, // stderr 0) - _Exec(h, "stable " + _args, consume notifier) + _Exec(h, "stable " + _args, tmp.path, _CleanTmp(tmp), consume notifier) diff --git a/stable/test/integration/test_version.pony b/stable/test/integration/test_version.pony index afe245f..8a815fb 100644 --- a/stable/test/integration/test_version.pony +++ b/stable/test/integration/test_version.pony @@ -1,4 +1,5 @@ use "ponytest" +use "files" use "process" use ".." @@ -8,8 +9,16 @@ class TestVersion is UnitTest fun apply(h: TestHelper) => h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + let notifier: ProcessNotify iso = _ExpectClient(h, ["\\d\\.\\d\\.\\d-[a-f0-9]+ \\[[a-z]+\\]"], None, // stderr 0) - _Exec(h, "stable version", consume notifier) + _Exec(h, "stable version", tmp.path, _CleanTmp(tmp), consume notifier) From 21c1c348590610edde96bd499efa00b9b17859cc Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Mon, 18 Jun 2018 16:29:24 +0200 Subject: [PATCH 2/8] Add integration tests for 'stable env' Turns out this is probably the lowest-hanging fruit right now. This makes use of the previous commit's "run in temp dir" feature. Signed-off-by: Stephan Renatus --- stable/test/integration/test_env.pony | 179 ++++++++++++++++++++++++++ stable/test/main.pony | 2 + 2 files changed, 181 insertions(+) create mode 100644 stable/test/integration/test_env.pony diff --git a/stable/test/integration/test_env.pony b/stable/test/integration/test_env.pony new file mode 100644 index 0000000..ab89407 --- /dev/null +++ b/stable/test/integration/test_env.pony @@ -0,0 +1,179 @@ +use "ponytest" +use "files" +use "process" +use ".." + +actor EnvTests is TestList + new create(env: Env) => PonyTest(env, this) + new make() => None + + fun tag tests(test: PonyTest) => + test(TestEnvNoBundle) + test(TestEnvEmptyBundleInSameDir) + test(TestEnvBundleInSameDir) + test(TestEnvBundleInSameDirWithCall) + test(TestEnvBundleInParentDir) + +class TestEnvNoBundle is UnitTest + new iso create() => None + + fun name(): String => "integration.Env(no bundle.json)" + + fun apply(h: TestHelper) => + h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + + let notifier: ProcessNotify iso = _ExpectClient(h, + None, + ["No bundle.json in current working directory or ancestors."], + 0) + _Exec(h, "stable env", tmp.path, _CleanTmp(tmp), consume notifier) + +class TestEnvEmptyBundleInSameDir is UnitTest + new iso create() => None + + fun name(): String => "integration.Env(empty bundle in same directory)" + + fun apply(h: TestHelper) => + h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + + let f = + try + Directory(tmp)?.create_file("bundle.json")? + else + h.fail("failed to create bundle.json in temporary directory") + return + end + h.assert_true(f.write("{\"deps\":[]}\n"), "prepare bundle.json") + + let notifier: ProcessNotify iso = _ExpectClient(h, + ["PONYPATH=\n"], // empty + None, + 0) + _Exec(h, "stable env", tmp.path, _CleanTmp(tmp), consume notifier) + +class TestEnvBundleInSameDir is UnitTest + new iso create() => None + + fun name(): String => "integration.Env(bundle in same directory)" + + fun apply(h: TestHelper) => + h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + + let f = + try + Directory(tmp)?.create_file("bundle.json")? + else + h.fail("failed to create bundle.json in temporary directory") + return + end + h.assert_true(f.write("{\"deps\":[ + {\"type\": \"local\", \"local-path\":\"../local/a\"}, + {\"type\": \"local-git\", \"local-path\":\"../local-git/b\"}, + {\"type\": \"github\", \"repo\":\"github/c\"}, + {\"type\": \"gitlab\", \"repo\":\"gitlab/d\"} + ]}\n"), "prepare bundle.json") + + let expected = + try + "../local/a" + ":" + + tmp.join(".deps/-local-git-b16798852821555717647")?.path + ":" + + tmp.join(".deps/github/c")?.path + ":" + + tmp.join(".deps/gitlab/d")?.path + else + h.fail("failed to construct expected PONYPATH") + return + end + + let notifier: ProcessNotify iso = _ExpectClient(h, + ["PONYPATH=" + expected], + None, + 0) + _Exec(h, "stable env", tmp.path, _CleanTmp(tmp), consume notifier) + +class TestEnvBundleInSameDirWithCall is UnitTest + new iso create() => None + + fun name(): String => "integration.Env(calling a program)" + + fun apply(h: TestHelper) => + h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + + let f = + try + Directory(tmp)?.create_file("bundle.json")? + else + h.fail("failed to create bundle.json in temporary directory") + return + end + h.assert_true(f.write("{\"deps\":[ + {\"type\": \"local\", \"local-path\":\"../local/a\"} + ]}\n"), "prepare bundle.json") + + let notifier: ProcessNotify iso = _ExpectClient(h, + ["../local/a"], + None, + 0) + _Exec(h, "stable env printenv PONYPATH", tmp.path, _CleanTmp(tmp), + consume notifier) + +class TestEnvBundleInParentDir is UnitTest + new iso create() => None + + fun name(): String => "integration.Env(bundle.json in parent dir)" + + fun apply(h: TestHelper) => + h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + + (let f, let nested) = + try + h.assert_true(Directory(tmp)?.mkdir("nested"), "create nested directory") + let n = tmp.join("nested")? + (Directory(tmp)?.create_file("bundle.json")?, n) + else + h.fail("failed to create bundle.json in nested temporary directory") + return + end + h.assert_true(f.write("{\"deps\":[ + {\"type\": \"local\", \"local-path\":\"../local/a\"} + ]}\n"), "prepare bundle.json") + + let notifier: ProcessNotify iso = _ExpectClient(h, + ["PONYPATH=../local/a"], + None, + 0) + _Exec(h, "stable env", nested.path, _CleanTmp(tmp), consume notifier) diff --git a/stable/test/main.pony b/stable/test/main.pony index b5e759a..d8e0842 100644 --- a/stable/test/main.pony +++ b/stable/test/main.pony @@ -11,3 +11,5 @@ actor Main is TestList test(integration.TestUsage("help")) test(integration.TestUsage("unknown arguments")) test(integration.TestVersion) + + integration.EnvTests.make().tests(test) From a27efe93fb304bbbb4a293abc1eb782c1ff5ed3f Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 19 Jun 2018 10:17:40 +0200 Subject: [PATCH 3/8] Add test case for invalid bundle.json in nested dir (valid one in parent) This is in anticipation of what's going to change in #68. Signed-off-by: Stephan Renatus --- stable/test/integration/test_env.pony | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/stable/test/integration/test_env.pony b/stable/test/integration/test_env.pony index ab89407..ad114ce 100644 --- a/stable/test/integration/test_env.pony +++ b/stable/test/integration/test_env.pony @@ -13,6 +13,7 @@ actor EnvTests is TestList test(TestEnvBundleInSameDir) test(TestEnvBundleInSameDirWithCall) test(TestEnvBundleInParentDir) + test(TestEnvBadBundleInNestedAndValidBundleInParentDir) class TestEnvNoBundle is UnitTest new iso create() => None @@ -177,3 +178,40 @@ class TestEnvBundleInParentDir is UnitTest None, 0) _Exec(h, "stable env", nested.path, _CleanTmp(tmp), consume notifier) + +class TestEnvBadBundleInNestedAndValidBundleInParentDir is UnitTest + new iso create() => None + + fun name(): String => "integration.Env(invalid bundle.json in nested dir)" + + fun apply(h: TestHelper) => + h.long_test(100_000_000) + let tmp = + try + FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + else + h.fail("failed to create temporary directory") + return + end + + (let bad_bundle, let good_bundle, let nested) = + try + h.assert_true(Directory(tmp)?.mkdir("nested"), "create nested directory") + let n = tmp.join("nested")? + (Directory(n)?.create_file("bundle.json")?, + Directory(tmp)?.create_file("bundle.json")?, + n) + else + h.fail("failed to create bundle.json example data files") + return + end + h.assert_true(good_bundle.write("{\"deps\":[ + {\"type\": \"local\", \"local-path\":\"../local/a\"} + ]}\n"), "prepare good bundle.json") + h.assert_true(bad_bundle.write("{}"), "prepare bad bundle.json") + + let notifier: ProcessNotify iso = _ExpectClient(h, + ["PONYPATH=../local/a"], + ["JSON error at: " + bad_bundle.path.path + ": missing \"deps\" array"], + 0) + _Exec(h, "stable env", nested.path, _CleanTmp(tmp), consume notifier) From 107991d7c60783f9ec035ab2088ab0c7cb2c5a85 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Mon, 25 Jun 2018 08:37:56 +0200 Subject: [PATCH 4/8] Run integration tests in separate tmp directory This adds stable/test/integration/tmp/ as an empty, tracked folder; and uses that one as base directory for running the integration tests. It felt a bit cleaner to me than having the temp dirs created in the top-level folder; also causes less of a mess when debugging integration tests by disabling the cleanup dispose()'s delete call. (I suppose it would have been just as good to use /tmp/, but I wasn't sure what our expectations regarding different operating systems were.) Signed-off-by: Stephan Renatus --- .gitignore | 2 ++ stable/test/integration/test_env.pony | 18 ++++++++++++------ stable/test/integration/test_usage.pony | 3 ++- stable/test/integration/test_version.pony | 3 ++- stable/test/integration/tmp/.gitkeep | 0 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 stable/test/integration/tmp/.gitkeep diff --git a/.gitignore b/.gitignore index 5710358..17f204d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build +/stable/test/integration/tmp/** +!/stable/test/integration/tmp/.gitkeep # generated stable/version.pony diff --git a/stable/test/integration/test_env.pony b/stable/test/integration/test_env.pony index ad114ce..edf06c2 100644 --- a/stable/test/integration/test_env.pony +++ b/stable/test/integration/test_env.pony @@ -24,7 +24,8 @@ class TestEnvNoBundle is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return @@ -45,7 +46,8 @@ class TestEnvEmptyBundleInSameDir is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return @@ -75,7 +77,8 @@ class TestEnvBundleInSameDir is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return @@ -121,7 +124,8 @@ class TestEnvBundleInSameDirWithCall is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return @@ -154,7 +158,8 @@ class TestEnvBundleInParentDir is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return @@ -188,7 +193,8 @@ class TestEnvBadBundleInNestedAndValidBundleInParentDir is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return diff --git a/stable/test/integration/test_usage.pony b/stable/test/integration/test_usage.pony index 8b50749..9c76a33 100644 --- a/stable/test/integration/test_usage.pony +++ b/stable/test/integration/test_usage.pony @@ -15,7 +15,8 @@ class TestUsage is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return diff --git a/stable/test/integration/test_version.pony b/stable/test/integration/test_version.pony index 8a815fb..d024bbb 100644 --- a/stable/test/integration/test_version.pony +++ b/stable/test/integration/test_version.pony @@ -11,7 +11,8 @@ class TestVersion is UnitTest h.long_test(100_000_000) let tmp = try - FilePath.mkdtemp(h.env.root as AmbientAuth, "")? + FilePath.mkdtemp(h.env.root as AmbientAuth, + "stable/test/integration/tmp/")? else h.fail("failed to create temporary directory") return diff --git a/stable/test/integration/tmp/.gitkeep b/stable/test/integration/tmp/.gitkeep new file mode 100644 index 0000000..e69de29 From 80713ebe4295a50a9fd05b677b25b8cb42a1ad56 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 26 Jun 2018 08:40:57 +0200 Subject: [PATCH 5/8] Run integration tests sequentially One of these tests had timed out on circleci. Having flakey tests seems an annoyance we should try to avoid; but I couldn't reproduce this by running `make integration` in a loop locally. So, the hypothesis is that the timeout was no bug in the tests, but a genuine timeout. Trying to reproduce the test failures locally, I've found that restricting the memory to 4M (docker's minimum) caused the tests to fail in a reproducible way. The integration test binary is now passed `--sequential`, so that the individual test runs don't compete for resources. This makes the error _not appear anymore_ in the docker 4M scenario. This reverts commit 8d8a906c69921050b18eded39159c1073afb071d. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 22eff1b..c043849 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ $(tests_binary): $(GEN_FILES) $(SOURCE_FILES) $(TEST_FILES) | $(BUILD_DIR) ${PONYC} $(arch_arg) --debug -o ${BUILD_DIR} $(SRC_DIR)/test integration: $(binary) $(tests_binary) - STABLE_BIN=$$(pwd)/$(binary) $(tests_binary) --only=integration + STABLE_BIN=$$(pwd)/$(binary) $(tests_binary) --only=integration --sequential test: $(tests_binary) $^ --exclude=integration From e01b3d23e3bc5e1edae42f57944b384a50d1b4f5 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 26 Jun 2018 08:40:57 +0200 Subject: [PATCH 6/8] Double integration test timeouts Seems like --sequential alone isn't enough. 200ms doesn't seem too bad, so let's try this. Signed-off-by: Stephan Renatus --- stable/test/integration/test_env.pony | 12 ++++++------ stable/test/integration/test_usage.pony | 2 +- stable/test/integration/test_version.pony | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stable/test/integration/test_env.pony b/stable/test/integration/test_env.pony index edf06c2..89f815e 100644 --- a/stable/test/integration/test_env.pony +++ b/stable/test/integration/test_env.pony @@ -21,7 +21,7 @@ class TestEnvNoBundle is UnitTest fun name(): String => "integration.Env(no bundle.json)" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, @@ -43,7 +43,7 @@ class TestEnvEmptyBundleInSameDir is UnitTest fun name(): String => "integration.Env(empty bundle in same directory)" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, @@ -74,7 +74,7 @@ class TestEnvBundleInSameDir is UnitTest fun name(): String => "integration.Env(bundle in same directory)" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, @@ -121,7 +121,7 @@ class TestEnvBundleInSameDirWithCall is UnitTest fun name(): String => "integration.Env(calling a program)" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, @@ -155,7 +155,7 @@ class TestEnvBundleInParentDir is UnitTest fun name(): String => "integration.Env(bundle.json in parent dir)" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, @@ -190,7 +190,7 @@ class TestEnvBadBundleInNestedAndValidBundleInParentDir is UnitTest fun name(): String => "integration.Env(invalid bundle.json in nested dir)" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, diff --git a/stable/test/integration/test_usage.pony b/stable/test/integration/test_usage.pony index 9c76a33..4dfc6c2 100644 --- a/stable/test/integration/test_usage.pony +++ b/stable/test/integration/test_usage.pony @@ -12,7 +12,7 @@ class TestUsage is UnitTest fun name(): String => "integration.Usage(" + _args + ")" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, diff --git a/stable/test/integration/test_version.pony b/stable/test/integration/test_version.pony index d024bbb..775b850 100644 --- a/stable/test/integration/test_version.pony +++ b/stable/test/integration/test_version.pony @@ -8,7 +8,7 @@ class TestVersion is UnitTest fun name(): String => "integration.Version" fun apply(h: TestHelper) => - h.long_test(100_000_000) + h.long_test(200_000_000) let tmp = try FilePath.mkdtemp(h.env.root as AmbientAuth, From 7bff702c6900173065104705dd617983e4c34b1f Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 10 Jul 2018 15:52:29 +0200 Subject: [PATCH 7/8] integration: register tmpdir cleanup after creation Signed-off-by: Stephan Renatus --- stable/test/integration/_exec.pony | 2 -- stable/test/integration/test_env.pony | 19 ++++++++++++------- stable/test/integration/test_usage.pony | 3 ++- stable/test/integration/test_version.pony | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/stable/test/integration/_exec.pony b/stable/test/integration/_exec.pony index 166bc12..ebd580e 100644 --- a/stable/test/integration/_exec.pony +++ b/stable/test/integration/_exec.pony @@ -8,7 +8,6 @@ actor _Exec h: TestHelper, cmdline: String, tmp: String, - cleaner: DisposableActor, notifier: ProcessNotify iso) => let stable_bin = @@ -31,7 +30,6 @@ actor _Exec path, consume args, consume vars) pm.done_writing() h.dispose_when_done(pm) - h.dispose_when_done(cleaner) else h.fail("Could not create FilePath!") end diff --git a/stable/test/integration/test_env.pony b/stable/test/integration/test_env.pony index 89f815e..4080a35 100644 --- a/stable/test/integration/test_env.pony +++ b/stable/test/integration/test_env.pony @@ -30,12 +30,13 @@ class TestEnvNoBundle is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) let notifier: ProcessNotify iso = _ExpectClient(h, None, ["No bundle.json in current working directory or ancestors."], 0) - _Exec(h, "stable env", tmp.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable env", tmp.path, consume notifier) class TestEnvEmptyBundleInSameDir is UnitTest new iso create() => None @@ -52,6 +53,7 @@ class TestEnvEmptyBundleInSameDir is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) let f = try @@ -66,7 +68,7 @@ class TestEnvEmptyBundleInSameDir is UnitTest ["PONYPATH=\n"], // empty None, 0) - _Exec(h, "stable env", tmp.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable env", tmp.path, consume notifier) class TestEnvBundleInSameDir is UnitTest new iso create() => None @@ -83,6 +85,7 @@ class TestEnvBundleInSameDir is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) let f = try @@ -113,7 +116,7 @@ class TestEnvBundleInSameDir is UnitTest ["PONYPATH=" + expected], None, 0) - _Exec(h, "stable env", tmp.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable env", tmp.path, consume notifier) class TestEnvBundleInSameDirWithCall is UnitTest new iso create() => None @@ -130,6 +133,7 @@ class TestEnvBundleInSameDirWithCall is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) let f = try @@ -146,8 +150,7 @@ class TestEnvBundleInSameDirWithCall is UnitTest ["../local/a"], None, 0) - _Exec(h, "stable env printenv PONYPATH", tmp.path, _CleanTmp(tmp), - consume notifier) + _Exec(h, "stable env printenv PONYPATH", tmp.path, consume notifier) class TestEnvBundleInParentDir is UnitTest new iso create() => None @@ -164,6 +167,7 @@ class TestEnvBundleInParentDir is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) (let f, let nested) = try @@ -182,7 +186,7 @@ class TestEnvBundleInParentDir is UnitTest ["PONYPATH=../local/a"], None, 0) - _Exec(h, "stable env", nested.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable env", nested.path, consume notifier) class TestEnvBadBundleInNestedAndValidBundleInParentDir is UnitTest new iso create() => None @@ -199,6 +203,7 @@ class TestEnvBadBundleInNestedAndValidBundleInParentDir is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) (let bad_bundle, let good_bundle, let nested) = try @@ -220,4 +225,4 @@ class TestEnvBadBundleInNestedAndValidBundleInParentDir is UnitTest ["PONYPATH=../local/a"], ["JSON error at: " + bad_bundle.path.path + ": missing \"deps\" array"], 0) - _Exec(h, "stable env", nested.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable env", nested.path, consume notifier) diff --git a/stable/test/integration/test_usage.pony b/stable/test/integration/test_usage.pony index 4dfc6c2..173d289 100644 --- a/stable/test/integration/test_usage.pony +++ b/stable/test/integration/test_usage.pony @@ -21,6 +21,7 @@ class TestUsage is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) let notifier: ProcessNotify iso = _ExpectClient(h, [ "Usage: stable COMMAND \\[\\.\\.\\.\\]" @@ -33,4 +34,4 @@ class TestUsage is UnitTest ], None, // stderr 0) - _Exec(h, "stable " + _args, tmp.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable " + _args, tmp.path, consume notifier) diff --git a/stable/test/integration/test_version.pony b/stable/test/integration/test_version.pony index 775b850..4462430 100644 --- a/stable/test/integration/test_version.pony +++ b/stable/test/integration/test_version.pony @@ -17,9 +17,10 @@ class TestVersion is UnitTest h.fail("failed to create temporary directory") return end + h.dispose_when_done(_CleanTmp(tmp)) let notifier: ProcessNotify iso = _ExpectClient(h, ["\\d\\.\\d\\.\\d-[a-f0-9]+ \\[[a-z]+\\]"], None, // stderr 0) - _Exec(h, "stable version", tmp.path, _CleanTmp(tmp), consume notifier) + _Exec(h, "stable version", tmp.path, consume notifier) From 2bb160861ec030d5f19a2819f187cc40bbff61be Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 10 Jul 2018 16:32:30 +0200 Subject: [PATCH 8/8] integration/helper.sh: mention chdir issue Signed-off-by: Stephan Renatus --- stable/test/integration/helper.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/stable/test/integration/helper.sh b/stable/test/integration/helper.sh index 743fae2..29c60e9 100755 --- a/stable/test/integration/helper.sh +++ b/stable/test/integration/helper.sh @@ -1,3 +1,4 @@ #!/bin/bash +# workaround -- see https://github.com/ponylang/ponyc/issues/2821 cd "$CWD" || exit 100 exec "$STABLE_BIN" "$@"