From 8bc810a444dd2179a1cbe00db57f983011432876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 10 May 2022 12:14:37 +0200 Subject: [PATCH] Fix file tests --- .../{subdirectory/a.txt => tree/sample.csv} | 0 .../nested/b.txt => tree/sample.txt} | 0 test/Tests/data/tree/subdirectory/a.txt | 0 .../Tests/data/tree/subdirectory/nested/b.txt | 0 test/Tests/src/System/File_Spec.enso | 19 +++++++++++-------- 5 files changed, 11 insertions(+), 8 deletions(-) rename test/Tests/data/{subdirectory/a.txt => tree/sample.csv} (100%) rename test/Tests/data/{subdirectory/nested/b.txt => tree/sample.txt} (100%) create mode 100644 test/Tests/data/tree/subdirectory/a.txt create mode 100644 test/Tests/data/tree/subdirectory/nested/b.txt diff --git a/test/Tests/data/subdirectory/a.txt b/test/Tests/data/tree/sample.csv similarity index 100% rename from test/Tests/data/subdirectory/a.txt rename to test/Tests/data/tree/sample.csv diff --git a/test/Tests/data/subdirectory/nested/b.txt b/test/Tests/data/tree/sample.txt similarity index 100% rename from test/Tests/data/subdirectory/nested/b.txt rename to test/Tests/data/tree/sample.txt diff --git a/test/Tests/data/tree/subdirectory/a.txt b/test/Tests/data/tree/subdirectory/a.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/test/Tests/data/tree/subdirectory/nested/b.txt b/test/Tests/data/tree/subdirectory/nested/b.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/test/Tests/src/System/File_Spec.enso b/test/Tests/src/System/File_Spec.enso index 93cb92273936a..545a489a4f5a8 100644 --- a/test/Tests/src/System/File_Spec.enso +++ b/test/Tests/src/System/File_Spec.enso @@ -142,22 +142,25 @@ spec = Test.specify "should list files in a directory" <| immediate = Enso_Project.data.list . map .to_text - immediate.sort.should_equal (resolve ["books.json", "sample.txt", "subdirectory", "windows.txt"]) + immediate.sort.should_equal (resolve ["books.json", "sample.txt", "transient", "tree", "windows.txt"]) filtered1 = Enso_Project.data.list name_filter="s[a-cw]mple.{t?t,md}" . map .to_text filtered1.should_equal (resolve ["sample.txt"]) - filtered2 = File.list Enso_Project.data name_filter="*dir*" . map .to_text - filtered2.should_equal (resolve ["subdirectory"]) + filtered2 = File.list Enso_Project.data name_filter="*re*" . map .to_text + filtered2.should_equal (resolve ["tree"]) Test.specify "should list files in a directory recursively" <| - all = Enso_Project.data.list recursive=True . map .to_text - all.sort.should_equal (resolve ["", "books.json", "sample.txt", "subdirectory", "subdirectory/a.txt", "subdirectory/nested", "subdirectory/nested/b.txt", "windows.txt"]) + root = Enso_Project.data / "tree" + resolve files = files.map str-> (root / str) . to_text - filtered1 = Enso_Project.data.list name_filter="**.txt" recursive=True . map .to_text - filtered1.sort.should_equal (resolve ["sample.txt", "subdirectory/a.txt", "subdirectory/nested/b.txt", "windows.txt"]) + all = root.list recursive=True . map .to_text + all.sort.should_equal (resolve ["", "sample.csv", "sample.txt", "subdirectory", "subdirectory/a.txt", "subdirectory/nested", "subdirectory/nested/b.txt"]) - filtered2 = Enso_Project.data.list name_filter="*/*/*" recursive=True . map .to_text + filtered1 = root.list name_filter="**.txt" recursive=True . map .to_text + filtered1.sort.should_equal (resolve ["sample.txt", "subdirectory/a.txt", "subdirectory/nested/b.txt"]) + + filtered2 = root.list name_filter="*/*/*" recursive=True . map .to_text filtered2.should_equal (resolve ["subdirectory/nested/b.txt"]) main = Test.Suite.run_main here.spec