Skip to content

refactor!: port Python tests to Rust #106

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

Merged
merged 54 commits into from
Mar 16, 2022
Merged

refactor!: port Python tests to Rust #106

merged 54 commits into from
Mar 16, 2022

Conversation

Shadow53
Copy link
Owner

Fixes #100 (and then some).

This ports the Python tests to Rust and includes some fixes to the main code to make the tests pass, as appropriate.

A lot of stuff ended up being reworked as part of this, so the merge commit message with contain a record of everything touched.

- fix: fix logic for check_files_are_same
- refactor: remove OperationV2::hoards_root
- refactor: make private things public
- refactor: make more things public
- fix: make upgrade logic more reliable
Some tests were failing because they were running in parallel while
depending on environment variables that were being changed by other
tests.

This fixes those tests and updates CI and such to run tests
single-threaded for now.
@netlify
Copy link

netlify bot commented Mar 16, 2022

✔️ Deploy Preview for hoard-docs ready!

🔨 Explore the source changes: 20cb3e2

🔍 Inspect the deploy log: https://app.netlify.com/sites/hoard-docs/deploys/62326743858c1c0008ec998a

😎 Browse the preview: https://deploy-preview-106--hoard-docs.netlify.app

@Shadow53 Shadow53 added this to the 0.5.0 milestone Mar 16, 2022
@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #106 (20cb3e2) into main (a246b72) will decrease coverage by 4.89%.
The diff coverage is 88.55%.

@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
- Coverage   94.56%   89.66%   -4.90%     
==========================================
  Files          35       61      +26     
  Lines        1988     4666    +2678     
==========================================
+ Hits         1880     4184    +2304     
- Misses        108      482     +374     
Impacted Files Coverage Δ
src/command/mod.rs 28.57% <ø> (-71.43%) ⬇️
src/config/builder/environment/envvar.rs 100.00% <ø> (ø)
src/config/builder/environment/mod.rs 100.00% <ø> (ø)
src/filters/ignore.rs 100.00% <ø> (ø)
src/filters/mod.rs 100.00% <ø> (ø)
src/hoard/mod.rs 0.00% <ø> (-79.68%) ⬇️
src/hoard/pile_config.rs 100.00% <ø> (ø)
src/lib.rs 100.00% <ø> (ø)
src/checkers/history/operation/v1.rs 52.72% <52.72%> (ø)
src/command/diff.rs 72.41% <57.89%> (-20.69%) ⬇️
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f350c5b...20cb3e2. Read the comment docs.

Copy link
Owner Author

@Shadow53 Shadow53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving comments with TODOs and notes for the merge commit

strategy:
matrix:
# Linux is handled by the coverage check
os: ["windows-latest", "macos-latest", "ubuntu-latest"]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci: merge integration tests job into testing/coverage job

@@ -1,3 +1,4 @@
.idea/
/target
*.profraw
.vscode/
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: add .vscode to gitignore

@@ -2,7 +2,7 @@
name = "hoard"
version = "0.4.0"
authors = ["Michael Bryant <[email protected]>"]
edition = "2018"
edition = "2021"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: upgrade to 2021 edition

@@ -30,17 +29,26 @@ serde_yaml = { version = "0.8", optional = true }
sha2 = "0.10"
similar = { version = "2.1", default-features = false, features = ["text"] }
structopt = "0.3.26"
tempfile = "3.3"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feat: edit temporary copy of configuration file

@@ -18,6 +18,16 @@ You can find all documentation at https://hoard.rs.

See [`config.toml.sample`](config.toml.sample) for a documented example configuration file.

## Testing
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc: add testing section to README

"foo".into() => "${HOME}/something".into()
},
#[cfg(windows)]
items: btreemap! {
"foo".into() => "${USERPROFILE}/something".into()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test(windows): use USERPROFILE env var, not HOME

@@ -352,10 +371,10 @@ mod tests {
fn multiple_entry_no_config() {
let hoard = Hoard::Multiple(MultipleEntries {
config: None,
items: hashmap! {
items: btreemap! {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor: use BTreeMap instead of HashMap for ordered iteration

@@ -51,7 +51,7 @@ impl Filter for Filters {
#[cfg(test)]
mod tests {
use super::*;
use crate::hoard_file::ChecksumType;
use crate::hoard_item::ChecksumType;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor: rename hoard_file -> hoard_item

@@ -300,6 +311,7 @@ impl HoardDiffIter {
};

Ok(ProcessedFile {
deleted_remotely,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: revise file diff analysis logic

@Shadow53 Shadow53 merged commit 89dc5c2 into main Mar 16, 2022
@Shadow53 Shadow53 deleted the 100-rust-tests branch March 16, 2022 22:47
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.

Rewrite integration tests in Rust
1 participant