Skip to content

Commit c7dab35

Browse files
committed
Add more complex test
1 parent 1dd7d25 commit c7dab35

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/builder.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ fn parse_rewrite_rule<'s>(conditions: &[&'s str], actions: &[&'s str]) -> Option
175175
return None;
176176
}
177177
if let Some(rest) = condition.strip_prefix("throws(") {
178-
let Some(descriptor) = rest.strip_suffix(')') else {
179-
return None;
180-
};
178+
let descriptor = rest.strip_suffix(')')?;
181179
if descriptor.is_empty() {
182180
return None;
183181
}
@@ -194,9 +192,7 @@ fn parse_rewrite_rule<'s>(conditions: &[&'s str], actions: &[&'s str]) -> Option
194192
return None;
195193
}
196194
if let Some(rest) = action.strip_prefix("removeInnerFrames(") {
197-
let Some(count_str) = rest.strip_suffix(')') else {
198-
return None;
199-
};
195+
let count_str = rest.strip_suffix(')')?;
200196
let count = count_str.parse().ok()?;
201197
parsed_actions.push(RewriteAction::RemoveInnerFrames(count));
202198
} else {

tests/r8.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ static MAPPING_R8_SYMBOLICATED_FILE_NAMES: &[u8] =
1010
include_bytes!("res/mapping-r8-symbolicated_file_names.txt");
1111
static MAPPING_OUTLINE: &[u8] = include_bytes!("res/mapping-outline.txt");
1212
static MAPPING_OUTLINE_COMPLEX: &[u8] = include_bytes!("res/mapping-outline-complex.txt");
13+
static MAPPING_REWRITE_COMPLEX: &str = include_str!("res/mapping-rewrite-complex.txt");
1314

1415
static MAPPING_WIN_R8: LazyLock<Vec<u8>> = LazyLock::new(|| {
1516
MAPPING_R8
@@ -330,3 +331,32 @@ fn test_outline_frame_retracing() {
330331
);
331332
assert_eq!(mapped.next(), None);
332333
}
334+
335+
#[test]
336+
fn rewrite_frame_complex_stacktrace() {
337+
let mapper = ProguardMapper::from(MAPPING_REWRITE_COMPLEX);
338+
339+
let input = "\
340+
java.lang.NullPointerException: Primary issue
341+
at a.start(SourceFile:10)
342+
at b.dispatch(SourceFile:5)
343+
at c.draw(SourceFile:20)
344+
Caused by: java.lang.IllegalStateException: Secondary issue
345+
at b.dispatch(SourceFile:5)
346+
at c.draw(SourceFile:20)
347+
";
348+
349+
let expected = "\
350+
java.lang.NullPointerException: Primary issue
351+
at com.example.flow.Initializer.start(SourceFile:42)
352+
at com.example.flow.StreamRouter$Inline.internalDispatch(<unknown>:30)
353+
at com.example.flow.StreamRouter.dispatch(SourceFile:12)
354+
at com.example.flow.UiBridge.render(SourceFile:200)
355+
Caused by: java.lang.IllegalStateException: Secondary issue
356+
at com.example.flow.StreamRouter.dispatch(SourceFile:12)
357+
at com.example.flow.UiBridge.render(SourceFile:200)
358+
";
359+
360+
let actual = mapper.remap_stacktrace(input).unwrap();
361+
assert_eq!(actual, expected);
362+
}

0 commit comments

Comments
 (0)