• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kbknapp / clap-rs / 3093
89%
master: 94%

Build:
Build:
LAST BUILD BRANCH: issues-839,840
DEFAULT BRANCH: master
Ran 31 Jan 2017 12:18AM UTC
Jobs 5
Files 61
Run time 22min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
3093

push

travis-ci

homu
Auto merge of #832 - mgeisler:fix-wrapping-bugs, r=kbknapp

Fix wrapping bugs

I've been working towards integrating my [textwrap][1] crate and along the way, I found some small problems in the existing `wrap_help` function in clap. I basically added new code that calls both `textwrap::fill` and `wrap_help` and panicked on any difference:
```
fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
    let input = help.clone();
    let mut old = help.clone();
    old_wrap_help(&mut old, longest_w, avail_chars);

    let mut wrapped = String::with_capacity(help.len());
    for (i, line) in help.lines().enumerate() {
        if i > 0 {
            wrapped.push('\n');
        }
        wrapped.push_str(&textwrap::fill(line, avail_chars));
    }

    // TODO: move up, This keeps old behavior of not wrapping at all
    // if one of the words would overflow the line
    if longest_w < avail_chars {
        *help = wrapped;
    }

    if *old != *help {
        println!("********************************");
        println!("longest_w: {}, avail_chars: {}", longest_w, avail_chars);
        println!("help: {:3} bytes: {:?}", input.len(), input);
        println!("old:  {:3} bytes: {:?}", old.len(), old);
        println!("new:  {:3} bytes: {:?}", help.len(), help);
        println!("********************************");
        panic!("bad wrap");
    }
}

fn old_wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
    // ... as before
```

This PR fixes two small problems discovered this way, one of which became #828.

[1]: https://crates.io/crates/textwrap

11 of 11 new or added lines in 2 files covered. (100.0%)

7647 of 8585 relevant lines covered (89.07%)

4.04 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
100.0
src/args/group.rs
1
100.0
src/args/arg.rs
Jobs
ID Job ID Ran Files Coverage
1 3093.1 31 Jan 2017 12:24AM UTC 0
88.97
Travis Job 3093.1
2 3093.2 31 Jan 2017 12:21AM UTC 0
91.86
Travis Job 3093.2
3 3093.3 31 Jan 2017 12:19AM UTC 0
91.82
Travis Job 3093.3
4 3093.4 31 Jan 2017 12:18AM UTC 0
91.19
Travis Job 3093.4
5 3093.5 31 Jan 2017 12:40AM UTC 0
88.97
Travis Job 3093.5
Source Files on build 3093
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #3093
  • 2bb4cbe6 on github
  • Prev Build on homu-tmp (#3083)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc