From deca981fa3ff434c156ac1434136d7359b05321e Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Mon, 30 Sep 2024 12:17:18 +0200 Subject: [PATCH] Ignore files that start with a `.` (#3072) - Closes #3068 --- src/Juvix/Data/FileExt.hs | 5 ++++- test/Scope/Positive.hs | 4 ++++ tests/positive/issue3068/.hidden.juvix | 1 + tests/positive/issue3068/Package.juvix | 9 +++++++++ tests/positive/issue3068/main.juvix | 1 + tests/smoke/Commands/typecheck.smoke.yaml | 9 +++++++++ 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/positive/issue3068/.hidden.juvix create mode 100644 tests/positive/issue3068/Package.juvix create mode 100644 tests/positive/issue3068/main.juvix diff --git a/src/Juvix/Data/FileExt.hs b/src/Juvix/Data/FileExt.hs index 3165869937..1f34568a27 100644 --- a/src/Juvix/Data/FileExt.hs +++ b/src/Juvix/Data/FileExt.hs @@ -156,11 +156,14 @@ instance Show FileExt where instance Pretty FileExt where pretty = pretty . fileExtToText +isHidden :: Path b File -> Bool +isHidden = (== ".") . take 1 . toFilePath + isJuvixOrJuvixMdFile :: Path b File -> Bool isJuvixOrJuvixMdFile = isJuvixFile .||. isJuvixMarkdownFile isJuvixFile :: Path b File -> Bool -isJuvixFile = (== Just juvixFileExt) . fileExtension +isJuvixFile = (not . isHidden) .&&. ((== Just juvixFileExt) . fileExtension) isJuvixMarkdownFile :: Path b File -> Bool isJuvixMarkdownFile p = case splitExtension p of diff --git a/test/Scope/Positive.hs b/test/Scope/Positive.hs index 895e142829..999613e30a 100644 --- a/test/Scope/Positive.hs +++ b/test/Scope/Positive.hs @@ -269,5 +269,9 @@ tests = posTest "Proper formatting of import module path" $(mkRelDir "issue2737") + $(mkRelFile "main.juvix"), + posTest + "Ignore dot files" + $(mkRelDir "issue3068") $(mkRelFile "main.juvix") ] diff --git a/tests/positive/issue3068/.hidden.juvix b/tests/positive/issue3068/.hidden.juvix new file mode 100644 index 0000000000..7c591551da --- /dev/null +++ b/tests/positive/issue3068/.hidden.juvix @@ -0,0 +1 @@ +nothing to see here diff --git a/tests/positive/issue3068/Package.juvix b/tests/positive/issue3068/Package.juvix new file mode 100644 index 0000000000..bbc6001160 --- /dev/null +++ b/tests/positive/issue3068/Package.juvix @@ -0,0 +1,9 @@ +module Package; + +import PackageDescription.V2 open; + +package : Package := + defaultPackage@?{ + name := "issue3068"; + dependencies := [] + }; diff --git a/tests/positive/issue3068/main.juvix b/tests/positive/issue3068/main.juvix new file mode 100644 index 0000000000..8bffabe306 --- /dev/null +++ b/tests/positive/issue3068/main.juvix @@ -0,0 +1 @@ +module main; diff --git a/tests/smoke/Commands/typecheck.smoke.yaml b/tests/smoke/Commands/typecheck.smoke.yaml index 656fd9927a..e7830e1fa5 100644 --- a/tests/smoke/Commands/typecheck.smoke.yaml +++ b/tests/smoke/Commands/typecheck.smoke.yaml @@ -1,5 +1,14 @@ working-directory: ./../../../tests/ tests: + - name: ignore-dot-file + working-directory: ./../../../tests/positive/issue3068 + command: + - juvix + - typecheck + stderr: + equals: "Well done! It type checks\n" + exit-status: 0 + - name: flag-help-shows-juvix-file-for-autocompletion command: - juvix