Skip to content
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

Add "-all" flag to diff command. #379

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion opt/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ pub struct Diff {
/// Whether or not `items` should be treated as regular expressions.
#[structopt(long = "regex")]
using_regexps: bool,

/// Displays all items. Overrides -n <max_items>
#[structopt(short = "a", long = "all")]
all_items: bool,
}

impl Default for Diff {
Expand All @@ -554,6 +558,7 @@ impl Default for Diff {
items: Default::default(),
max_items: 20,
using_regexps: false,
all_items: false,
}
}
}
Expand All @@ -572,7 +577,7 @@ impl Diff {
impl Diff {
/// The maximum number of items to display.
pub fn max_items(&self) -> u32 {
self.max_items
if self.all_items { u32::MAX } else { self.max_items }
}

/// Whether or not `items` should be treated as regular expressions.
Expand All @@ -583,6 +588,7 @@ impl Diff {
/// Set the maximum number of items to display.
pub fn set_max_items(&mut self, n: u32) {
self.max_items = n;
self.all_items = false;
}

/// Set whether or not `items` should be treated as regular expressions.
Expand Down
14 changes: 11 additions & 3 deletions twiggy/tests/all/diff_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ test!(
"5"
);

// TODO: Update this test once `--all` flag is added.
test!(
diff_wee_alloc_all,
"diff",
"./fixtures/wee_alloc.wasm",
"./fixtures/wee_alloc.2.wasm",
"-n",
"100"
"-a"
);

test!(
diff_wee_alloc_all_json,
"diff",
"./fixtures/wee_alloc.wasm",
"./fixtures/wee_alloc.2.wasm",
"-a",
"-f",
"json"
);

test!(
Expand Down
1 change: 1 addition & 0 deletions twiggy/tests/all/expectations/diff_wee_alloc_all_json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"delta_bytes":-1034,"name":"data[3]"},{"delta_bytes":-593,"name":"\"function names\" subsection"},{"delta_bytes":396,"name":"wee_alloc::alloc_first_fit::he2a4ddf96981c0ce"},{"delta_bytes":243,"name":"goodbye"},{"delta_bytes":-226,"name":"wee_alloc::alloc_first_fit::h9a72de3af77ef93f"},{"delta_bytes":-153,"name":"wee_alloc::alloc_with_refill::hb32c1bbce9ebda8e"},{"delta_bytes":146,"name":"<wee_alloc::neighbors::Neighbors<'a, T>>::remove::hc9e5d4284e8233b8"},{"delta_bytes":-137,"name":"<wee_alloc::size_classes::SizeClassAllocPolicy<'a> as wee_alloc::AllocPolicy>::new_cell_for_free_list::h3987e3054b8224e6"},{"delta_bytes":-77,"name":"<wee_alloc::LargeAllocPolicy as wee_alloc::AllocPolicy>::new_cell_for_free_list::h8f071b7bce0301ba"},{"delta_bytes":-25,"name":"data[1]"},{"delta_bytes":-25,"name":"data[2]"},{"delta_bytes":15,"name":"hello"},{"delta_bytes":15,"name":"import env::rust_oom"},{"delta_bytes":-12,"name":"elem[0]"},{"delta_bytes":10,"name":"custom section 'linking' headers"},{"delta_bytes":8,"name":"global[0]"},{"delta_bytes":-8,"name":"type[4]: (i32, i32, i32, i32, i32) -> nil"},{"delta_bytes":-7,"name":"<wee_alloc::LargeAllocPolicy as wee_alloc::AllocPolicy>::min_cell_size::hc7cee2a550987099"},{"delta_bytes":7,"name":"alloc::alloc::oom::h45ae3f22a516fb04"},{"delta_bytes":-6,"name":"<wee_alloc::size_classes::SizeClassAllocPolicy<'a> as wee_alloc::AllocPolicy>::min_cell_size::h6f746be886573355"},{"delta_bytes":-6,"name":"type[0]: (i32, i32, i32) -> nil"},{"delta_bytes":-6,"name":"type[1]: (i32, i32) -> i32"},{"delta_bytes":-5,"name":"__wasm_nullptr"},{"delta_bytes":5,"name":"type[1]: (i32) -> i32"},{"delta_bytes":-4,"name":"core::ptr::drop_in_place::h4e5cdfd7b9310648.18"},{"delta_bytes":-4,"name":"core::ptr::drop_in_place::h8e9fdc2437d43666"},{"delta_bytes":4,"name":"type[0]: () -> i32"},{"delta_bytes":-4,"name":"type[5]: () -> i32"},{"delta_bytes":3,"name":"custom section 'linking'"},{"delta_bytes":-3,"name":"element section headers"},{"delta_bytes":3,"name":"global section headers"},{"delta_bytes":3,"name":"import section headers"},{"delta_bytes":2,"name":"data[0]"},{"delta_bytes":-1,"name":"data section headers"},{"delta_bytes":-1476,"name":"Σ [34 Total Rows]"}]