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

Tests for AndroidTraceLayer (tracing_android_trace) #10

Open
DJMcNab opened this issue Mar 29, 2024 · 0 comments
Open

Tests for AndroidTraceLayer (tracing_android_trace) #10

DJMcNab opened this issue Mar 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@DJMcNab
Copy link
Member

DJMcNab commented Mar 29, 2024

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

@DJMcNab DJMcNab added the enhancement New feature or request label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant