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: Switch to test_log #450

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ cargo run --example custom_resolver

Available [here](https://docs.rs/lofty)

## Testing

As some formats are complex, Lofty makes use of [test-log](https://crates.io/crates/test-log) to get
the detailed debug/trace logging for failures. To run the tests, do:

```shell
RUST_LOG=trace cargo test
```

## Benchmarking

There are benchmarks available [here](./benches). To run them, do:
Expand Down
1 change: 1 addition & 0 deletions lofty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ hound = { git = "https://github.com/ruuda/hound.git", rev = "02e66effb33683d
# tag_writer example
structopt = { version = "0.3.26", default-features = false }
tempfile = "3.10.1"
test-log = "0.2.16"
iai-callgrind = "0.12.0"

[lints]
Expand Down
38 changes: 19 additions & 19 deletions lofty/src/ape/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ mod tests {
use crate::picture::{MimeType, Picture, PictureType};
use std::io::Cursor;

#[test]
#[test_log::test]
fn parse_ape() {
let mut expected_tag = ApeTag::default();

Expand Down Expand Up @@ -636,7 +636,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn ape_re_read() {
let tag_bytes = crate::tag::utils::test_utils::read_path("tests/tags/assets/test.apev2");
let mut reader = Cursor::new(tag_bytes);
Expand Down Expand Up @@ -664,7 +664,7 @@ mod tests {
assert_eq!(parsed_tag, temp_parsed_tag);
}

#[test]
#[test_log::test]
fn ape_to_tag() {
let tag_bytes = crate::tag::utils::test_utils::read_path("tests/tags/assets/test.apev2");
let mut reader = Cursor::new(tag_bytes);
Expand All @@ -680,7 +680,7 @@ mod tests {
crate::tag::utils::test_utils::verify_tag(&tag, true, true);
}

#[test]
#[test_log::test]
fn tag_to_ape() {
fn verify_key(tag: &ApeTag, key: &str, expected_val: &str) {
assert_eq!(
Expand All @@ -701,7 +701,7 @@ mod tests {
verify_key(&ape_tag, "Genre", "Classical");
}

#[test]
#[test_log::test]
fn set_track() {
let mut ape = ApeTag::default();
let track = 1;
Expand All @@ -712,7 +712,7 @@ mod tests {
assert!(ape.track_total().is_none());
}

#[test]
#[test_log::test]
fn set_track_total() {
let mut ape = ApeTag::default();
let track_total = 2;
Expand All @@ -723,7 +723,7 @@ mod tests {
assert_eq!(ape.track_total().unwrap(), track_total);
}

#[test]
#[test_log::test]
fn set_track_and_track_total() {
let mut ape = ApeTag::default();
let track = 1;
Expand All @@ -736,7 +736,7 @@ mod tests {
assert_eq!(ape.track_total().unwrap(), track_total);
}

#[test]
#[test_log::test]
fn set_track_total_and_track() {
let mut ape = ApeTag::default();
let track_total = 2;
Expand All @@ -749,7 +749,7 @@ mod tests {
assert_eq!(ape.track().unwrap(), track);
}

#[test]
#[test_log::test]
fn set_disk() {
let mut ape = ApeTag::default();
let disk = 1;
Expand All @@ -760,7 +760,7 @@ mod tests {
assert!(ape.disk_total().is_none());
}

#[test]
#[test_log::test]
fn set_disk_total() {
let mut ape = ApeTag::default();
let disk_total = 2;
Expand All @@ -771,7 +771,7 @@ mod tests {
assert_eq!(ape.disk_total().unwrap(), disk_total);
}

#[test]
#[test_log::test]
fn set_disk_and_disk_total() {
let mut ape = ApeTag::default();
let disk = 1;
Expand All @@ -784,7 +784,7 @@ mod tests {
assert_eq!(ape.disk_total().unwrap(), disk_total);
}

#[test]
#[test_log::test]
fn set_disk_total_and_disk() {
let mut ape = ApeTag::default();
let disk_total = 2;
Expand All @@ -797,7 +797,7 @@ mod tests {
assert_eq!(ape.disk().unwrap(), disk);
}

#[test]
#[test_log::test]
fn track_number_tag_to_ape() {
let track_number = 1;

Expand All @@ -814,7 +814,7 @@ mod tests {
assert!(tag.track_total().is_none());
}

#[test]
#[test_log::test]
fn track_total_tag_to_ape() {
let track_total = 2;

Expand All @@ -831,7 +831,7 @@ mod tests {
assert_eq!(tag.track_total().unwrap(), track_total);
}

#[test]
#[test_log::test]
fn track_number_and_track_total_tag_to_ape() {
let track_number = 1;
let track_total = 2;
Expand All @@ -854,7 +854,7 @@ mod tests {
assert_eq!(tag.track_total().unwrap(), track_total);
}

#[test]
#[test_log::test]
fn disk_number_tag_to_ape() {
let disk_number = 1;

Expand All @@ -871,7 +871,7 @@ mod tests {
assert!(tag.disk_total().is_none());
}

#[test]
#[test_log::test]
fn disk_total_tag_to_ape() {
let disk_total = 2;

Expand All @@ -888,7 +888,7 @@ mod tests {
assert_eq!(tag.disk_total().unwrap(), disk_total);
}

#[test]
#[test_log::test]
fn disk_number_and_disk_total_tag_to_ape() {
let disk_number = 1;
let disk_total = 2;
Expand All @@ -911,7 +911,7 @@ mod tests {
assert_eq!(tag.disk_total().unwrap(), disk_total);
}

#[test]
#[test_log::test]
fn skip_reading_cover_art() {
let p = Picture::new_unchecked(
PictureType::CoverFront,
Expand Down
8 changes: 4 additions & 4 deletions lofty/src/id3/v1/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ mod tests {
use crate::prelude::*;
use crate::tag::{Tag, TagType};

#[test]
#[test_log::test]
fn parse_id3v1() {
let expected_tag = Id3v1Tag {
title: Some(String::from("Foo title")),
Expand All @@ -481,7 +481,7 @@ mod tests {
assert_eq!(expected_tag, parsed_tag);
}

#[test]
#[test_log::test]
fn id3v2_re_read() {
let tag = crate::tag::utils::test_utils::read_path("tests/tags/assets/test.id3v1");
let parsed_tag = crate::id3::v1::read::parse_id3v1(tag.try_into().unwrap());
Expand All @@ -496,7 +496,7 @@ mod tests {
assert_eq!(parsed_tag, temp_parsed_tag);
}

#[test]
#[test_log::test]
fn id3v1_to_tag() {
let tag_bytes = crate::tag::utils::test_utils::read_path("tests/tags/assets/test.id3v1");
let id3v1 = crate::id3::v1::read::parse_id3v1(tag_bytes.try_into().unwrap());
Expand All @@ -506,7 +506,7 @@ mod tests {
crate::tag::utils::test_utils::verify_tag(&tag, true, true);
}

#[test]
#[test_log::test]
fn tag_to_id3v1() {
let tag = crate::tag::utils::test_utils::create_tag(TagType::Id3v1);

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/audio_text_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn atxt_decode() {
let expected = expected();

Expand All @@ -261,7 +261,7 @@ mod tests {
assert_eq!(parsed_atxt, expected);
}

#[test]
#[test_log::test]
fn atxt_encode() {
let to_encode = expected();

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/encapsulated_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn geob_decode() {
let expected = expected();

Expand All @@ -155,7 +155,7 @@ mod tests {
assert_eq!(parsed_geob, expected);
}

#[test]
#[test_log::test]
fn geob_encode() {
let to_encode = expected();

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/event_timing_codes_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn etco_decode() {
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.etco");

Expand All @@ -318,7 +318,7 @@ mod tests {
assert_eq!(parsed_etco, expected());
}

#[test]
#[test_log::test]
fn etco_encode() {
let encoded = expected().as_bytes();

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/ownership_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn owne_decode() {
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.owne");

Expand All @@ -164,7 +164,7 @@ mod tests {
assert_eq!(parsed_owne, expected());
}

#[test]
#[test_log::test]
fn owne_encode() {
let encoded = expected().as_bytes(false).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/popularimeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ mod tests {
assert_eq!(popm_bytes[email.len() + 2..].len(), counter_len);
}

#[test]
#[test_log::test]
fn write_popm() {
let popm_u32_boundary = PopularimeterFrame {
header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()),
Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/private_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn priv_decode() {
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.priv");

Expand All @@ -124,7 +124,7 @@ mod tests {
assert_eq!(parsed_priv, expected());
}

#[test]
#[test_log::test]
fn priv_encode() {
let encoded = expected().as_bytes().unwrap();

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn rva2_decode() {
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.rva2");

Expand All @@ -301,7 +301,7 @@ mod tests {
assert_eq!(parsed_rva2, expected());
}

#[test]
#[test_log::test]
#[allow(unstable_name_collisions)]
fn rva2_encode() {
let encoded = expected().as_bytes();
Expand Down
8 changes: 4 additions & 4 deletions lofty/src/id3/v2/items/sync_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ mod tests {
}
}

#[test]
#[test_log::test]
fn sylt_decode() {
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.sylt");

Expand All @@ -295,7 +295,7 @@ mod tests {
assert_eq!(parsed_sylt, expected(TextEncoding::Latin1));
}

#[test]
#[test_log::test]
fn sylt_encode() {
let encoded = expected(TextEncoding::Latin1).as_bytes().unwrap();

Expand All @@ -305,7 +305,7 @@ mod tests {
assert_eq!(encoded, expected_bytes);
}

#[test]
#[test_log::test]
fn sylt_decode_utf16() {
let cont =
crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test_utf16.sylt");
Expand All @@ -315,7 +315,7 @@ mod tests {
assert_eq!(parsed_sylt, expected(TextEncoding::UTF16));
}

#[test]
#[test_log::test]
fn sylt_encode_utf_16() {
let encoded = expected(TextEncoding::UTF16).as_bytes().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/unique_file_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ mod tests {

use std::borrow::Cow;

#[test]
#[test_log::test]
fn issue_204_invalid_ufid_parsing_mode_best_attempt() {
use crate::config::ParsingMode;
use crate::id3::v2::UniqueFileIdentifierFrame;
Expand Down
Loading
Loading