Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Mar 15, 2020
1 parent 9c8f9e2 commit 9b6eaae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- zlib1g-dev
update: true
before_script:
- cargo install cargo-tarpaulin
- cargo install cargo-tarpaulin --git https://github.com/xd009642/tarpaulin --branch develop
script:
- cargo tarpaulin --workspace --features "yaml unstable" --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
script:
Expand Down
6 changes: 2 additions & 4 deletions clap_derive/src/derives/into_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
// MIT/Apache 2.0 license.

use std::env;

use proc_macro2::TokenStream;
use proc_macro_error::abort;
use quote::{quote, quote_spanned};
Expand Down Expand Up @@ -56,7 +54,7 @@ pub fn gen_for_struct(
}

pub fn gen_for_enum(name: &syn::Ident) -> TokenStream {
let app_name = env::var("CARGO_PKG_NAME").ok().unwrap_or_default();
let app_name = option_env!("CARGO_PKG_NAME").unwrap_or_default();

quote! {
#[allow(dead_code, unreachable_code, unused_variables)]
Expand Down Expand Up @@ -86,7 +84,7 @@ pub fn gen_for_enum(name: &syn::Ident) -> TokenStream {
}

fn gen_into_app_fn(attrs: &[syn::Attribute]) -> GenOutput {
let app_name = env::var("CARGO_PKG_NAME").ok().unwrap_or_default();
let app_name = option_env!("CARGO_PKG_NAME").unwrap_or_default();

let attrs = Attrs::from_struct(
proc_macro2::Span::call_site(),
Expand Down
12 changes: 12 additions & 0 deletions clap_derive/tests/macro-errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed

use std::env;

#[rustversion::attr(any(not(stable), before(1.42)), ignore)]
#[test]
fn ui() {
let not_present = env::var("CARGO_PKG_NAME").is_err();

if not_present {
env::set_var("CARGO_PKG_NAME", "test");
}

let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");

if not_present {
env::remove_var("CARGO_PKG_NAME");
}
}

1 comment on commit 9b6eaae

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 9b6eaae Previous: 9c8f9e2 Ratio
build_empty 85 ns/iter (+/- 2) 105 ns/iter (+/- 1) 0.81
parse_empty 844 ns/iter (+/- 25) 1020 ns/iter (+/- 11) 0.83
parse_simple_with_complex 3362 ns/iter (+/- 93) 4232 ns/iter (+/- 99) 0.79
parse_simple_with_pos 2718 ns/iter (+/- 118) 3250 ns/iter (+/- 49) 0.84
parse_simple_with_opt 2816 ns/iter (+/- 92) 3524 ns/iter (+/- 58) 0.80
parse_simple_with_flag 2438 ns/iter (+/- 55) 3056 ns/iter (+/- 51) 0.80
build_with_pos_ref 219 ns/iter (+/- 5) 238 ns/iter (+/- 2) 0.92
build_with_pos 175 ns/iter (+/- 3) 183 ns/iter (+/- 3) 0.96
build_with_opt_ref 303 ns/iter (+/- 7) 353 ns/iter (+/- 5) 0.86
build_with_opt 232 ns/iter (+/- 5) 284 ns/iter (+/- 6) 0.82
build_with_flag_ref 255 ns/iter (+/- 5) 305 ns/iter (+/- 4) 0.84
build_with_flag 199 ns/iter (+/- 4) 243 ns/iter (+/- 3) 0.82
build_simple 626 ns/iter (+/- 15) 925 ns/iter (+/- 17) 0.68
build_from_usage 3608 ns/iter (+/- 90) 4643 ns/iter (+/- 72) 0.78
build_from_builder 2206 ns/iter (+/- 69) 2563 ns/iter (+/- 42) 0.86
build_from_macros 2321 ns/iter (+/- 58) 2850 ns/iter (+/- 41) 0.81
parse_complex 6616 ns/iter (+/- 195) 7811 ns/iter (+/- 130) 0.85
parse_complex_with_flag 7354 ns/iter (+/- 208) 9206 ns/iter (+/- 173) 0.80
parse_complex_with_opt 7843 ns/iter (+/- 179) 9608 ns/iter (+/- 149) 0.82
parse_complex_with_pos 7762 ns/iter (+/- 181) 9394 ns/iter (+/- 206) 0.83
parse_complex_with_sc 9125 ns/iter (+/- 257) 11526 ns/iter (+/- 431) 0.79
parse_complex_with_sc_flag 10177 ns/iter (+/- 330) 11855 ns/iter (+/- 139) 0.86
parse_complex_with_sc_opt 10212 ns/iter (+/- 255) 11991 ns/iter (+/- 214) 0.85
parse_complex_with_sc_pos 10150 ns/iter (+/- 317) 11748 ns/iter (+/- 187) 0.86
parse_complex1 12360 ns/iter (+/- 361) 14895 ns/iter (+/- 245) 0.83
parse_complex2 13532 ns/iter (+/- 384) 17022 ns/iter (+/- 264) 0.79
parse_args_negate_scs 13481 ns/iter (+/- 404) 15787 ns/iter (+/- 174) 0.85
parse_complex_with_sc_complex 11060 ns/iter (+/- 276) 12845 ns/iter (+/- 232) 0.86
example1 13643 ns/iter (+/- 373) 17536 ns/iter (+/- 496) 0.78
example2 414053 ns/iter (+/- 42,741) 364450 ns/iter (+/- 38,114) 1.1
example3 15260 ns/iter (+/- 506) 18466 ns/iter (+/- 215) 0.83
example4 10208 ns/iter (+/- 239) 13759 ns/iter (+/- 373) 0.74
example5 518599 ns/iter (+/- 39,143) 459755 ns/iter (+/- 41,848) 1.1
example6 8083 ns/iter (+/- 209) 10131 ns/iter (+/- 186) 0.80
example7 11550 ns/iter (+/- 362) 14180 ns/iter (+/- 178) 0.81
example8 11452 ns/iter (+/- 221) 14292 ns/iter (+/- 237) 0.80
example10 455847 ns/iter (+/- 42,211) 406031 ns/iter (+/- 38,922) 1.1
example4_template 9921 ns/iter (+/- 380) 11969 ns/iter (+/- 191) 0.83
build_rg_with_short_help 9969 ns/iter (+/- 246) 12207 ns/iter (+/- 155) 0.82
build_rg_with_long_help 10293 ns/iter (+/- 238) 13324 ns/iter (+/- 186) 0.77
write_rg_short_help 92047 ns/iter (+/- 1,818) 121574 ns/iter (+/- 2,964) 0.76
write_rg_long_help 205709 ns/iter (+/- 6,048) 251581 ns/iter (+/- 7,112) 0.82
parse_rg 21800 ns/iter (+/- 728) 27205 ns/iter (+/- 586) 0.80
parse_rg_with_complex 30839 ns/iter (+/- 684) 38920 ns/iter (+/- 517) 0.79
parse_rg_with_lots 688020 ns/iter (+/- 15,621) 901209 ns/iter (+/- 13,114) 0.76
build_rustup 12249 ns/iter (+/- 530) 14588 ns/iter (+/- 348) 0.84
parse_rustup 14447 ns/iter (+/- 333) 17893 ns/iter (+/- 179) 0.81
parse_rustup_with_sc 15019 ns/iter (+/- 554) 17729 ns/iter (+/- 195) 0.85

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.