commit: daf5f024f5307fe875088791421dfaa3b5cb7089
parent 1e05d25828265448cb9bbd6c0330f8f4805b6dd3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 18 Feb 2022 01:37:31 +0100
Add tests for check_dir
Diffstat:
3 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -2,3 +2,4 @@
/test/fixtures/hello
/test/fixtures/hello.a
/test/fixtures/hello.o
+/test/check_dir-fixtures/
diff --git a/Makefile b/Makefile
@@ -22,6 +22,7 @@ test/fixtures/hello.a: test/fixtures/hello
.PHONY: test
test: all $(TEST_BLOBS)
+ rm -fr test/check_dir-fixtures
cp -r test/fixtures test/check_dir-fixtures
hare test
rm -fr test/check_dir-fixtures
diff --git a/main.ha b/main.ha
@@ -135,6 +135,28 @@ fn check_dir(dirname: str, ignoring: bool) (ok|invalid) = {
return ok;
};
+@test fn check_dir() void = {
+ const dirname = "test/check_dir-fixtures";
+
+ let files_before = match(os::readdir(dirname)) {
+ case let d: []fs::dirent => yield d;
+ case let e: fs::error =>
+ fmt::fatal("os::readdir({}): {}", dirname, fs::strerror(e));
+ };
+
+ let ret = check_dir(dirname, false);
+ assert(ret is ok);
+
+ let files_after = match(os::readdir(dirname)) {
+ case let d: []fs::dirent => yield d;
+ case let e: fs::error =>
+ fmt::fatal("os::readdir({}): {}", dirname, fs::strerror(e));
+ };
+
+ assert(len(files_after) == 5);
+ assert(len(files_before) == 8);
+};
+
fn fn_noop() void = {
return;
};