mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 02:52:47 +08:00
fix(android): keep why a loose library failed
A protected library added on its own whose restore failed reported an empty error list, and its failure profile carried an empty reason in both the route and the profile errors. The report now records the error it already printed, so the text report shows the reason and --json carries it in all three places.
This commit is contained in:
1 parent
3b28f1aaa4
commit
b2286dec1c
1 file changed
+26
@@ -2248,6 +2248,10 @@ fn android_library_input_with_error(
|
||||
let mut entry = InputReport::new(input, Role::Content);
|
||||
entry.status = status;
|
||||
entry.analysis_incomplete = error.is_some_and(analysis_incomplete);
|
||||
// The failure profile below takes its detail from the first error.
|
||||
if let Some(error) = error {
|
||||
entry.error(of_error(error));
|
||||
}
|
||||
match status {
|
||||
InputStatus::Ok => {
|
||||
entry.profile = Some(crate::report::android_recovered_profile());
|
||||
@@ -2947,6 +2951,28 @@ mod incomplete_analysis_tests {
|
||||
assert!(!reported.analysis_incomplete);
|
||||
}
|
||||
|
||||
/// A loose library that failed keeps its error, in the report and as the
|
||||
/// failure profile's detail.
|
||||
#[test]
|
||||
fn a_failed_android_library_reports_its_error() {
|
||||
let td = tempfile::tempdir().unwrap();
|
||||
let path = td.path().join("libil2cpp.so");
|
||||
std::fs::write(&path, b"not really an ELF").unwrap();
|
||||
let error = anyhow::anyhow!("6 unresolved slots").context("restore protected library");
|
||||
let reported = android_library_input_with_error(
|
||||
&path,
|
||||
InputStatus::Error,
|
||||
&path,
|
||||
Instant::now(),
|
||||
Some(&error),
|
||||
);
|
||||
let texts: Vec<&str> = reported.errors.iter().map(Message::text).collect();
|
||||
assert_eq!(texts, ["restore protected library: 6 unresolved slots"]);
|
||||
let profile = reported.profile.expect("a failure profile");
|
||||
let detail: Vec<&str> = profile.errors.iter().map(Message::text).collect();
|
||||
assert_eq!(detail, texts);
|
||||
}
|
||||
|
||||
/// A container whose entry hit a ceiling is incomplete as a whole.
|
||||
#[test]
|
||||
fn a_container_inherits_an_incomplete_entry() {
|
||||
|
||||
Reference in new issue
Block a user