-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationgood first issueGood for newcomersGood for newcomers
Description
Add main function with anyhow to doctests and create actual temp file or directory to pass tests.
Right now if call cargo test:
running 5 tests
test test::test_ls_file ... ok
test test::test_ls_dir ... ok
test test::test_ls_rec_file ... ok
test test::test_ls_rec_dir ... ok
test test::test_size ... ok
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
running 3 tests
test src/lib.rs - size (line 86) ... FAILED
test src/lib.rs - ls (line 12) ... FAILED
test src/lib.rs - ls_rec (line 46) ... FAILED
failures:
---- src/lib.rs - size (line 86) stdout ----
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> src/lib.rs:91:63
|
4 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_86_0() {
| ---------------------------------- this function should return `Result` or `Option` to accept `?`
...
8 | let total_size = size(Path::new("/path/to/file_or_directory"))?;
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, anyhow::Error>>` is not implemented for `()`
help: consider adding return type
|
4 ~ fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_86_0() -> Result<(), Box<dyn std::error::Error>> {
5 | use durs::size;
...
9 | println!("Total size: {} bytes", total_size);
10+ Ok(())
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
Couldn't compile the test.
---- src/lib.rs - ls (line 12) stdout ----
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> src/lib.rs:17:48
|
4 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_12_0() {
| ---------------------------------- this function should return `Result` or `Option` to accept `?`
...
8 | let files = ls(Path::new("/path/to/directory"))?;
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, anyhow::Error>>` is not implemented for `()`
help: consider adding return type
|
4 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_12_0() -> Result<(), Box<dyn std::error::Error>> {
| +++++++++++++++++++++++++++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
Couldn't compile the test.
---- src/lib.rs - ls_rec (line 46) stdout ----
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> src/lib.rs:51:52
|
4 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_46_0() {
| ---------------------------------- this function should return `Result` or `Option` to accept `?`
...
8 | let files = ls_rec(Path::new("/path/to/directory"))?;
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, anyhow::Error>>` is not implemented for `()`
help: consider adding return type
|
4 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_46_0() -> Result<(), Box<dyn std::error::Error>> {
| +++++++++++++++++++++++++++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
Couldn't compile the test.
failures:
src/lib.rs - ls (line 12)
src/lib.rs - ls_rec (line 46)
src/lib.rs - size (line 86)
test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationgood first issueGood for newcomersGood for newcomers