The sync layer has some nasty code to manage the stack. E.g. (up-to-date at the time of writing):
|
for id in stack[index_of_this..].iter() { |
|
if let Some(id) = id { |
|
let span = ctx.span(id).expect("Span not found, this is a bug"); |
|
let extensions = span.extensions(); |
|
if let Some(ext) = extensions.get::<ATraceExtension>() { |
|
self.trace.begin_section(&ext.name); |
|
} else { |
|
eprintln!("Unexpectedly had item in stack without ATraceExtension"); |
|
} |
|
} else { |
|
self.trace.begin_section(EXTRA_STR); |
|
} |
|
} |
We should find a way to test this code. This would involve:
- Enabling mocking AndroidTrace for testing, somehow (either with a trait, or by specifying the function calls directly)
- Creating a layer which uses this mocked AndroidTrace
- Running tests with different timings of enabled/disabled and span creation/exiting
- Saving the resulting trees, and seeing if they make sense (probably with a kind of snapshot testing), + that each open of a span is met with a matching close
This is not a high priority
The sync layer has some nasty code to manage the stack. E.g. (up-to-date at the time of writing):
android_trace/tracing_android_trace/src/sync_layer.rs
Lines 227 to 239 in d4bd04d
We should find a way to test this code. This would involve:
This is not a high priority