diff --git a/compiler/test/stdlib/fs.test.gr b/compiler/test/stdlib/fs.test.gr index 596b965c84..8dfe028845 100644 --- a/compiler/test/stdlib/fs.test.gr +++ b/compiler/test/stdlib/fs.test.gr @@ -260,7 +260,7 @@ assert Fs.Utf8.readFile(testPath("boofar.txt")) // remove assert Fs.remove(testPath("baz.txt")) == Ok(void) -assert Fs.remove(testPath("newdir")) == Err(Fs.IsADirectory) +assert Fs.remove(testPath("newdir")) == Err(Fs.OperationNotPermitted) assert Fs.createDir(testPath("newdir/innerdir")) == Ok(void) assert Fs.remove(testPath("newdir"), removeMode=Fs.RemoveEmptyDirectory) == Err(Fs.DirectoryNotEmpty) diff --git a/compiler/test/suites/stdlib.re b/compiler/test/suites/stdlib.re index 1a2e2cc7ad..2c9a049d2f 100644 --- a/compiler/test/suites/stdlib.re +++ b/compiler/test/suites/stdlib.re @@ -1,6 +1,39 @@ open Grain_tests.TestFramework; open Grain_tests.Runner; +// Cleanup files created by fs tests +let cleanupFsTest = () => { + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "baz.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "foobar.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "foocopy.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "boofar.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "newfile.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "contentscopy.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "symlink")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "linkcopy")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "linktodir")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "copied-link")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "test-dir" / "in-directory.txt")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "test-dir" / "symlink")); + Fs.rmIfExistsExn(Fp.At.(test_data_dir / "test-dir" / "newfile.txt")); + switch (Fs.rmDir(Fp.At.(test_data_dir / "newdir"))) { + | Ok(_) | Error(Invalid_argument(_)) => () + | Error(exn) => raise(exn) + } + switch (Fs.rmDir(Fp.At.(test_data_dir / "dir2"))) { + | Ok(_) | Error(Invalid_argument(_)) => () + | Error(exn) => raise(exn) + } + switch (Fs.rmDir(Fp.At.(test_data_dir / "copied-dir"))) { + | Ok(_) | Error(Invalid_argument(_)) => () + | Error(exn) => raise(exn) + } + switch (Fs.rmDir(Fp.At.(test_data_dir / "copied-link-to-dir"))) { + | Ok(_) | Error(Invalid_argument(_)) => () + | Error(exn) => raise(exn) + } +}; + describe("stdlib", ({test, testSkip}) => { let test_or_skip = Sys.backend_type == Other("js_of_ocaml") ? testSkip : test; @@ -81,7 +114,9 @@ describe("stdlib", ({test, testSkip}) => { assertStdlib("float32.test"); assertStdlib("float64.test"); - // assertStdlib("fs.test"); + cleanupFsTest(); + assertStdlib("fs.test"); + cleanupFsTest(); assertStdlib("hash.test"); assertStdlib("int8.test"); diff --git a/compiler/test/test-data/.gitignore b/compiler/test/test-data/.gitignore new file mode 100644 index 0000000000..c59b919563 --- /dev/null +++ b/compiler/test/test-data/.gitignore @@ -0,0 +1,17 @@ +baz.txt +foobar.txt +foocopy.txt +boofar.txt +newfile.txt +contentscopy.txt +symlink +linkcopy +linktodir +copied-link +test-dir/in-directory.txt +test-dir/symlink +test-dir/newfile.txt +newdir/ +dir2/ +copied-dir/ +copied-link-to-dir/ \ No newline at end of file