summaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)Author
2016-11-06Add -m/--max-count flag.Andrew Gallant
This flag limits the number of matches printed *per file*. Closes #159
2016-11-06Fixes a bug with --smart-case.Andrew Gallant
This was a subtle bug, but the big picture was that the smart case information wasn't being carried through to the literal extraction in some cases. When this happened, it was possible to get back an incomplete set of literals, which would therefore miss some valid matches. The fix to this is to actually parse the regex and determine whether smart case applies before doing anything else. It's a little extra work, but parsing is pretty fast. Fixes #199
2016-11-05Use the bytecount crate for fast line counting.Andre Bogus
Fixes #128
2016-10-31Fixes a matching bug in the glob override matcher.Andrew Gallant
This was probably a transcription error when moving the ignore matcher code out of ripgrep core. Specifically, the override glob matcher should not ignore directories if they don't match. Fixes #206
2016-10-29Move all gitignore matching to separate crate.Andrew Gallant
This PR introduces a new sub-crate, `ignore`, which primarily provides a fast recursive directory iterator that respects ignore files like gitignore and other configurable filtering rules based on globs or even file types. This results in a substantial source of complexity moved out of ripgrep's core and into a reusable component that others can now (hopefully) benefit from. While much of the ignore code carried over from ripgrep's core, a substantial portion of it was rewritten with the following goals in mind: 1. Reuse matchers built from gitignore files across directory iteration. 2. Design the matcher data structure to be amenable for parallelizing directory iteration. (Indeed, writing the parallel iterator is the next step.) Fixes #9, #44, #45
2016-10-16Fix bug when processing parent gitignore files.Andrew Gallant
This particular bug was triggered whenever a search was run in a directory with a parent directory that contains a relevant .gitignore file. In particular, before matching against a parent directory's gitignore rules, a path's leading `./` was not stripped, which results in errant matching. We now make sure `./` is stripped. Fixes #184.
2016-10-10Update regex-syntax for bug fix.Andrew Gallant
The bug fix was in expression pretty printing. ripgrep parses the regex into an AST and may do some modifications to it, which requires the ability to go from string -> AST -> string' -> AST' where string == string' implies AST == AST'. Also, add a regression test for the specific regex that tripped the bug. Fixes #156.
2016-10-10Update darwin cfg attributes.Andrew Gallant
2016-10-10Disable regression_131 test on darwin.Andrew Gallant
It's not clear why it's failing. Maybe it doesn't permit certain characters in file paths?
2016-10-10Fix symlink test.Andrew Gallant
We attempt to run it on Windows, but I'm getting "access denied" errors when trying to create a file symlink. So we disable the test on Windows.
2016-10-10style nitsAndrew Gallant
2016-10-10Finish overhaul of glob matching.Andrew Gallant
This commit completes the initial move of glob matching to an external crate, including fixing up cross platform support, polishing the external crate for others to use and fixing a number of bugs in the process. Fixes #87, #127, #131
2016-10-08Always follow symlinks on explicit file arguments.Ian Kerins
2016-10-04Refactor and test glob sets.Andrew Gallant
This commit goes a long way toward refactoring glob sets so that the code is easier to maintain going forward. In particular, it makes the literal optimizations that glob sets used a lot more structured and much easier to extend. Tests have also been modified to include glob sets. There's still a bit of polish work left to do before a release. This also fixes the immediate issue where large gitignore files were causing ripgrep to slow way down. While we don't technically fix it for good, we're a lot better about reducing the number of regexes we compile. In particular, if a gitignore file contains thousands of patterns that can't be matched more simply using literals, then ripgrep will slow down again. We could fix this for good by avoiding RegexSet if the number of regexes grows too large. Fixes #134.
2016-09-28Add -s/--case-sensitive flag.Andrew Gallant
This flag overrides both --smart-case and --ignore-case. Closes #124.
2016-09-27add a max-depth option for directory traversalGarrett Squire
CR and add integration test
2016-09-26Don't print empty lines in single threaded mode.Andrew Gallant
Fixes #99.
2016-09-26Add a --null flag.Andrew Gallant
This flag causes a NUL byte to follow any file path in ripgrep's output. Closes #89.
2016-09-26Fix an off-by-one error with --column.Andrew Gallant
Fixes #105.
2016-09-25Don't replace NUL bytes when searching binary files as text.Andrew Gallant
This was a result of misinterpreting a feature in grep where NUL bytes are replaced with \n. The primary reason for doing this is to avoid excessive memory usage on truly binary data. However, grep only does this when searching binary files as if they were binary, and which only reports whether the file matched or not. When grep is told to search binary data as text (the -a/--text flag), then it doesn't do any replacement so we shouldn't either. In general, this makes sense, because the user is essentially asserting that a particular file that looks like binary is actually text. In that case, we shouldn't try to replace any NUL bytes. ripgrep doesn't actually support searching binary data for whether it matches or not, so we don't actually need the replace_buf function. However, it does seem like a potentially useful feature.
2016-09-25Don't union inner literals of repetitions.Andrew Gallant
If we do, this results in extracting `foofoofoo` from `(\wfoo){3}`, which is wrong. This does prevent us from extracting `foofoofoo` from `foo{3}`, which is unfortunate, but we miss plenty of other stuff too. Literal extracting needs a good rethink (all the way down into the regex engine). Fixes #93
2016-09-25Permit whitelisting hidden files in ignores.Andrew Gallant
Fixes #90
2016-09-25Fix tests on Windows.Andrew Gallant
Mostly this is just using \\ instead of / in paths reported by the OS.
2016-09-24Add --files-with-matches flag.Andrew Schwartzmeyer
Closes #26. Acts like --count but emits only the paths of files with matches, suitable for piping to xargs. Both mmap and no-mmap searches terminate after the first match is found. Documentation updated and tests added.
2016-09-24Add --smart-case.Andrew Gallant
It does what it says on the tin. Closes #70.
2016-09-24Add --no-ignore-vcs flag.Andrew Gallant
This flag will respect .ignore but not .gitignore. Closes #68.
2016-09-24Don't ignore first path when using --files.Andrew Gallant
This is a docopt oddity, but probably not a bug. If --files is given, then just interpret the pattern (if not empty) as the first file path. Fixes #64.
2016-09-24Fix directory whitelisting.Andrew Gallant
There was a bug in the translation from a gitignore pattern to a standard glob where `!/dir` wasn't being interpreted as an absolute path. Fixes #67.
2016-09-24Fix trailing recursive globs in gitignore.Andrew Gallant
A standard glob of `foo/**` will match `foo`, but gitignore semantics specify that `foo/**` should only match the contents of `foo` and not `foo` itself. We capture those semantics by translating `foo/**` to `foo/**/*`. Fixes #30.
2016-09-24Add --no-filename flag.Andrew Gallant
When this flag is set, a filename is never shown for a match. Closes #20
2016-09-24Change the default output of --files to elide './'.Andrew Gallant
This is kind of a ticky-tack change. I do think ./ as a prefix is reasonable default, *but* we strip ./ when showing search results, so it does make sense to be consistent. Fixes #21.
2016-09-24Fix handling of absolute patterns in parent gitignore files.Andrew Gallant
If a gitignore file in a *parent* directory is used, then it must be matched relative to the directory it's in. ripgrep wasn't actually adhering to this rule. Consider an example: .gitignore src llvm foo Where `.gitignore` contains `/llvm/` and `foo` contains `test`. When running `rg test` at the top-level directory, `foo` is correctly searched. If you `cd` into `src` and re-run the same search, `foo` is ignored because the `/llvm/` pattern is interpreted with respect to the current working directory, which is wrong. The problem is that the path of `llvm` is `./llvm`, which makes it look like it should match. We fix this by rebuilding the directory path of each file when traversing gitignores in parent directories. This does come with a small performance hit. Fixes #25.
2016-09-24Fix a bug in the translation from a gitignore pattern to a glob.Andrew Gallant
We were erroneously neglecting to prefix a pattern like `foo/` with `**/` (to make `**/foo/`) because it had a slash in it. In fact, the only reason to neglect a **/ prefix is if the pattern already starts with **/, or if the pattern is absolute. Fixes #16, #49, #50, #65
2016-09-23Switch from .rgignore to .ignore.Andrew Gallant
But don't actually remove support for .rgignore until the next semver bump. Note that this puts us in line with the silver searcher: https://github.com/ggreer/the_silver_searcher/pull/974 Fixes #40
2016-09-23Column numbers should start at 1.Andrew Gallant
ripgrep was documented to do 1-based indexing, so this is a bug and not a breaking change. Fixes #18
2016-09-22Add --vimgrep flag.Andrew Gallant
The --vimgrep flag forces a line to be printed for every match, with line and column numbers.
2016-09-21fix -uuu test on WindowsAndrew Gallant
2016-09-20Add "unrestricted" flag.Andrew Gallant
I don't like having multiple flags do the same thing, but -u, -uu and -uuu are much easier to remember, particularly with -uuu meaning "search everything."
2016-09-17Add support for searching multiple patterns with -e.0.1.4Andrew Gallant
Also, change -Q/--literal to -F/--fixed-strings because compatibility with grep is probably better.
2016-09-11Make file type filtering a lot faster.Andrew Gallant
We do this by avoiding using a RegexSet (*sigh*). In particular, file type matching has much simpler semantics than gitignore files, so we don't actually need to care which file type matched. Therefore, we can get away with a single regex with a giant alternation.
2016-09-09Fix test that relied on non-deterministic order of results.Andrew Gallant
2016-09-09Fix `files` test. What a pain.Andrew Gallant
2016-09-09Add integration tests.Andrew Gallant