Skip to content

Tests for AndroidTraceLayer (tracing_android_trace) #10

Description

@DJMcNab

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:

  1. Enabling mocking AndroidTrace for testing, somehow (either with a trait, or by specifying the function calls directly)
  2. Creating a layer which uses this mocked AndroidTrace
  3. Running tests with different timings of enabled/disabled and span creation/exiting
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions