Skip to content

Commit

Permalink
Auto merge of #255 - pch07/ffmpeg_io_tests, r=TroyKomodo
Browse files Browse the repository at this point in the history
added test coverage for ffmpeg io
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide: https://github.com/ScuffleCloud/.github/blob/main/CONTRIBUTING.md
-->

## Motivation

<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? If a new feature is being added, describe the intended
use case that feature fulfills.
-->
Added test coverage to ffmpeg io files.
## Solution

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->
I added tests, and one function for the dictionary file for testing purposes (just to check if it's empty). Note that I was unable to figure out how to make tests for the `io/output.rs` file, namely the `write_xyz()` functions.

There was one strange case I ran into with the `flags()` function which returned a value of `2097152`. I did my best to look into it but I have no idea why it does that, so I left the test commented out in the file.
## Tickets

<!--
Link any relevant tickets. Remember to not specify the ticket ids in the commit messages.
-->
n/a

Requested-by: TroyKomodo <[email protected]>
Reviewed-by: TroyKomodo <[email protected]>
  • Loading branch information
scuffle-brawl[bot] authored Jan 18, 2025
2 parents e87073a + bf553e6 commit 5447007
Show file tree
Hide file tree
Showing 16 changed files with 3,496 additions and 33 deletions.
10 changes: 8 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ test *args:
set -euo pipefail

INSTA_FORCE_PASS=1 cargo +{{RUST_TOOLCHAIN}} llvm-cov clean --workspace
INSTA_FORCE_PASS=1 cargo +{{RUST_TOOLCHAIN}} llvm-cov nextest --include-build-script --no-report -- {{args}}
INSTA_FORCE_PASS=1 cargo +{{RUST_TOOLCHAIN}} llvm-cov nextest --include-build-script --no-report --all-features -- {{args}}
# Coverage for doctests is currently broken in llvm-cov.
# Once it fully works we can add the `--doctests` flag to the test and report command again.
cargo +{{RUST_TOOLCHAIN}} llvm-cov test --doc --no-report -- {{args}}
cargo +{{RUST_TOOLCHAIN}} llvm-cov test --doc --no-report --all-features -- {{args}}

# Do not generate the coverage report on CI
cargo insta review
Expand Down
2 changes: 1 addition & 1 deletion crates/av1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ scuffle-bytes-util.workspace = true
scuffle-workspace-hack.workspace = true

[dev-dependencies]
insta = "1.2"
insta = "1.42"
2 changes: 1 addition & 1 deletion crates/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ scuffle-bootstrap-derive.workspace = true
scuffle-workspace-hack.workspace = true

[dev-dependencies]
insta = "1.42.0"
insta = "1.42"
postcompile = { workspace = true, features = ["prettyplease"] }
scuffle-future-ext.workspace = true
scuffle-signal = { workspace = true, features = ["bootstrap"] }
2 changes: 1 addition & 1 deletion crates/bootstrap/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ darling = "0.20"
scuffle-workspace-hack.workspace = true

[dev-dependencies]
insta = "1"
insta = "1.42"
prettyplease = "0.2"
8 changes: 8 additions & 0 deletions crates/ffmpeg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license = "MIT OR Apache-2.0"
description = "FFmpeg bindings for Rust."
keywords = ["ffmpeg", "video", "audio", "media"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

[dependencies]
libc = "0.2"
bytes = { optional = true, version = "1" }
Expand All @@ -19,6 +22,11 @@ tracing = { optional = true, version = "0.1" }
arc-swap = { version = "1.7" }
ffmpeg-sys-next = { version = "7.1.0" }
scuffle-workspace-hack.workspace = true
rand = "0.8"

[dev-dependencies]
insta = {version = "1.42", features = ["filters"]}
tempfile = "3.15"

[features]
channel = ["dep:bytes"]
Expand Down
4 changes: 4 additions & 0 deletions crates/ffmpeg/src/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ impl Dictionary {
}
}

pub fn is_empty(&self) -> bool {
self.iter().next().is_none()
}

pub fn iter(&self) -> DictionaryIterator {
DictionaryIterator::new(self)
}
Expand Down
Loading

0 comments on commit 5447007

Please sign in to comment.