Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Nov 14, 2023
1 parent 9919e32 commit 1226662
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 85 deletions.
24 changes: 4 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,6 @@ jobs:
if: matrix.target != ''
run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET_FLAGS }}

- name: Test for existence of build artifacts (Windows)
if: matrix.os == 'windows-2022'
shell: bash
run: |
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
ls "$outdir/_rg.ps1" && file "$outdir/_rg.ps1"
- name: Test for existence of build artifacts (Unix)
if: matrix.os != 'windows-2022'
shell: bash
run: |
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
# TODO: Check for the man page generation here. For whatever reason,
# it seems to be intermittently failing in CI. No idea why.
# for f in rg.bash rg.fish rg.1; do
for f in rg.bash rg.fish; do
# We could use file -E here, but it isn't supported on macOS.
ls "$outdir/$f" && file "$outdir/$f"
done
- name: Test zsh shell completions (Unix, sans cross)
# We could test this when using Cross, but we'd have to execute the
# 'rg' binary (done in test-complete) with qemu, which is a pain and
Expand All @@ -197,6 +177,10 @@ jobs:
shell: bash
run: ${{ env.CARGO }} test --manifest-path crates/cli/Cargo.toml ${{ env.TARGET_FLAGS }} --lib print_hostname -- --nocapture

- name: Print available short flags
shell: bash
run: ${{ env.CARGO }} test --bin rg flags::defs::tests::available_shorts -- --nocapture

rustfmt:
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 0 additions & 11 deletions crates/core/flags/complete/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,3 @@ pub(crate) fn generate() -> String {
.trim_start()
.to_string()
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn todo_remove() {
std::fs::create_dir_all("/tmp/rg-test").unwrap();
std::fs::write("/tmp/rg-test/rg.bash", generate().as_bytes()).unwrap();
}
}
11 changes: 0 additions & 11 deletions crates/core/flags/complete/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,3 @@ pub(crate) fn generate() -> String {
}
out
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn todo_remove() {
std::fs::create_dir_all("/tmp/rg-test").unwrap();
std::fs::write("/tmp/rg-test/rg.fish", generate().as_bytes()).unwrap();
}
}
11 changes: 0 additions & 11 deletions crates/core/flags/complete/powershell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,3 @@ pub(crate) fn generate() -> String {
}
TEMPLATE.trim_start().replace("!FLAGS!", &flags)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn todo_remove() {
std::fs::create_dir_all("/tmp/rg-test").unwrap();
std::fs::write("/tmp/rg-test/_rg.ps1", generate().as_bytes()).unwrap();
}
}
2 changes: 1 addition & 1 deletion crates/core/flags/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7442,7 +7442,7 @@ mod tests {

for byte in 0..=0x7F {
if total[usize::from(byte)] && !taken[usize::from(byte)] {
eprintln!("{:?}", char::from(byte));
eprintln!("{}", char::from(byte));
}
}
}
Expand Down
17 changes: 0 additions & 17 deletions crates/core/flags/doc/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,3 @@ fn remove_roff(v: &str) -> String {
.replace(r"\-", "-")
.replace(r"\\", r"\")
}

#[cfg(test)]
mod tests {
use std::path::PathBuf;

use super::*;

#[test]
fn todo_remove() {
let dir = PathBuf::from("/tmp/rg-test");
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("rg.short.help"), generate_short().as_bytes())
.unwrap();
std::fs::write(dir.join("rg.long.help"), generate_long().as_bytes())
.unwrap();
}
}
14 changes: 0 additions & 14 deletions crates/core/flags/doc/man.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,3 @@ fn flag_long_doc(flag: &'static dyn Flag) -> String {
out.push_str(&original[last_match..]);
out
}

#[cfg(test)]
mod tests {
use std::path::PathBuf;

use super::*;

#[test]
fn todo_remove() {
let dir = PathBuf::from("/tmp/rg-test");
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("rg.1"), generate().as_bytes()).unwrap();
}
}
15 changes: 15 additions & 0 deletions crates/core/flags/midargs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,21 @@ impl MidArgs {
Ok(PatternMatcher::RustRegex(m))
}

/// Returns true if some non-zero number of matches is believed to be
/// possible.
///
/// When this returns false, it is impossible for ripgrep to ever report
/// a match.
pub(crate) fn matches_possible(&self) -> bool {
if self.patterns.patterns.is_empty() {
return false;
}
if self.max_count == Some(0) {
return false;
}
true
}

pub(crate) fn overrides(
&self,
) -> anyhow::Result<ignore::overrides::Override> {
Expand Down
1 change: 1 addition & 0 deletions crates/core/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fn run(result: flags::ParseResult<Args>) -> anyhow::Result<ExitCode> {
ParseResult::Ok(args) => args,
};
let matched = match args.mode {
Mode::Search(_) if !args.matches_possible() => false,
Mode::Search(mode) if args.threads == 1 => search(&args, mode)?,
Mode::Search(mode) => search_parallel(&args, mode)?,
Mode::Files if args.threads == 1 => files(&args)?,
Expand Down

0 comments on commit 1226662

Please sign in to comment.