-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: gitignoringGlob stack safety + perf #1234
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0fc6581
fix: gitignoringGlob stack safety + perf
cakekindel bdeb14d
fix: formatting
cakekindel 4251576
fix: unused import
cakekindel 0b098be
fix: restore this old behavior, maybe it broke windows
cakekindel d7e5583
fix: unnecessary complexity
cakekindel e5c3d3b
fix: fmt
cakekindel c6ec574
fix: unnecessary do
cakekindel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,13 @@ module Test.Spago.Glob where | |
|
||
import Test.Prelude | ||
|
||
import Data.Foldable (intercalate) | ||
import Data.String.Gen (genAlphaLowercaseString) | ||
import Effect.Aff as Aff | ||
import Node.Path as Path | ||
import Spago.FS as FS | ||
import Spago.Glob as Glob | ||
import Test.QuickCheck.Gen (randomSample', resize) | ||
import Test.Spec (Spec) | ||
import Test.Spec as Spec | ||
import Test.Spec.Assertions as Assert | ||
|
@@ -26,11 +29,13 @@ globTmpDir m = Aff.bracket make cleanup m | |
base | ||
dir | ||
"fruits" | ||
[touch "apple", touch "orange", touch "banana"] | ||
base | ||
dir | ||
"sports" | ||
[touch "baseball", touch "scrabble"] | ||
[ touch "apple" | ||
, touch "orange" | ||
, touch "banana" | ||
, dir "special" | ||
[ touch "apple" | ||
] | ||
] | ||
base | ||
dir | ||
"src" | ||
|
@@ -45,17 +50,19 @@ spec = Spec.around globTmpDir do | |
Spec.describe "glob" do | ||
Spec.describe "gitignoringGlob" do | ||
Spec.it "when no .gitignore, yields all matches" \p -> do | ||
a <- Glob.gitignoringGlob p ["**/fruits/apple/**"] | ||
a `Assert.shouldEqual` ["fruits/apple", "src/fruits/apple"] | ||
|
||
b <- Glob.gitignoringGlob p ["sports/**"] | ||
b `Assert.shouldEqual` ["sports", "sports/baseball", "sports/scrabble"] | ||
a <- Glob.gitignoringGlob p ["**/apple"] | ||
a `Assert.shouldEqual` ["fruits/apple", "fruits/special/apple", "src/fruits/apple"] | ||
|
||
Spec.it "respects a .gitignore pattern that doesn't conflict with search" \p -> do | ||
FS.writeTextFile (Path.concat [p, ".gitignore"]) "/fruits" | ||
a <- Glob.gitignoringGlob p ["src/fruits/apple/**"] | ||
a <- Glob.gitignoringGlob p ["**/apple"] | ||
a `Assert.shouldEqual` ["src/fruits/apple"] | ||
|
||
Spec.it "respects a negated .gitignore pattern" \p -> do | ||
FS.writeTextFile (Path.concat [p, ".gitignore"]) "!/fruits/special/apple\n/fruits/apple" | ||
a <- Glob.gitignoringGlob p ["**/apple"] | ||
a `Assert.shouldEqual` ["fruits/special/apple", "src/fruits/apple"] | ||
|
||
Spec.it "does not respect a .gitignore pattern that conflicts with search" \p -> do | ||
for_ ["/fruits", "fruits", "fruits/", "**/fruits", "fruits/**", "**/fruits/**"] \gitignore -> do | ||
FS.writeTextFile (Path.concat [p, ".gitignore"]) gitignore | ||
|
@@ -66,3 +73,9 @@ spec = Spec.around globTmpDir do | |
FS.writeTextFile (Path.concat [p, ".gitignore"]) """/fruits\n/src""" | ||
a <- Glob.gitignoringGlob p ["fruits/apple/**"] | ||
a `Assert.shouldEqual` ["fruits/apple"] | ||
|
||
Spec.it "is stacksafe" \p -> do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fails on |
||
hugeGitignore <- liftEffect $ intercalate "\n" <$> randomSample' 10000 (resize 4 $ genAlphaLowercaseString) | ||
FS.writeTextFile (Path.concat [p, ".gitignore"]) hugeGitignore | ||
a <- Glob.gitignoringGlob p ["fruits/apple/**"] | ||
a `Assert.shouldEqual` ["fruits/apple"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change allows us to accumulate with
append
ing arrays instead of||
ing functions.Fun fact for those who may not be aware, if all of a record's fields are
Semigroup
, the record isSemigroup
so you can<>
these :)