Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/test/stdlib/fs.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 36 additions & 1 deletion compiler/test/suites/stdlib.re
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down
17 changes: 17 additions & 0 deletions compiler/test/test-data/.gitignore
Original file line number Diff line number Diff line change
@@ -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/
Loading