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

Core: Snapshot Testing for Output of Observe Session #2139

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

AmmarAbouZor
Copy link
Member

@AmmarAbouZor AmmarAbouZor commented Oct 29, 2024

This PR provides new tests for the process of reading from binary files (DLT, Pcapng, Pcap legacy), then parsing with (DLT, SomeIP, DLT and SomeIP) parsers, then writing the output to Chipmunk temporary directory. By reading those temp files and having a snapshot for them as a reference to compare to of future changes.

  • The crate insta is used to handle snapshot testing. It's preferred to be used with its CLI tool cargo-insta.
  • Output files will be read and represented as serializable struct which is written to the snapshot files via yaml format (The suggested format by insta crate) because it's clear to when diffing the snapshots
  • Integration of the tool are built into Build CLI Tool with the option to accept all the changes at once. However, using cargo insta provides more benefits with colored diffs and reviewing each item snapshot at once.
  • CI checks adjusted accordingly by adding CI environment flag as needed for insta crate.
  • Documentation is added to the test file directly to make it easier to find for developers when tests are failing.
  • Small fix to creating tmp directory in case .chipmunk directory doesn't exist has been added.

* Create test modules and their helper modules
* Implement function to run session and return the created temporary
  session file
* Add pretty assertion to be used to compare session files.
* Create a struct to represent and load the temp output files generated
  by an observe session, with serialization functions to be used in
  snapshot testing.
* Ensure the generated session files are removed after running the test
* Renaming & Refactoring
* Add the crate `insta` for snapshot testing
* Integrate insta functions with DLT function to create a snapshot test
* Small refactoring & Add newly created files to gitignore
* Rename tests directory & Adjust snapshots accordingly.
* Apply clippy tests
* Add support for snapshot testing via command line argument to accept
  the changes in snapshots
* Default test will set environment variables to prevent snapshot
  testing from creating new snapshot files.
* Use trim_end() when printing the logs instead of trim() to avoid
  trimming suffixes of log lines
* Increment tool version & Update change log.
* Add needed environment variable to CI pipeline for snapshot tests.
* Replace unwrap() calls with more context.
* Add Documentation in code.
* Fix typos.
* Fix case when `tmp` directory needs to be created before creating
  `.chipmunk` in home directory
* This case could occur rarely like in integration tests.
* Avoid false positives on detecting changes due to changing in orders
  on attachments.
* TODO to remove cleaning up temporary files manually when cleanup
  improvements are merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant