Skip to content

Request: Format change for doc test cli output #6927

@phrohdoh

Description

@phrohdoh

When running cargo test on a project with some doc tests I see the following output:

$ cargo test   
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running target/debug/deps/tq_parser-9edae091aa940c1c

running 1 test
test tokenizer::tests::string_literal::simple ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests tq-parser

running 3 tests
test src/tokenizer.rs - tokenizer::Tokenizer<'text>::new (line 158) ... ok
test src/tokenizer.rs - tokenizer::Tokenizer (line 36) ... ok
test src/tokenizer.rs - tokenizer::Token (line 122) ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

This ticket is focusing on this portion:

   Doc-tests tq-parser

running 3 tests
test src/tokenizer.rs - tokenizer::Tokenizer<'text>::new (line 158) ... ok
test src/tokenizer.rs - tokenizer::Tokenizer (line 36) ... ok
test src/tokenizer.rs - tokenizer::Token (line 122) ... ok

I believe this output could be more useful, perhaps at the cost of being 'pretty', if the line numbers were joined to the source file path with a : to produce a clickable (in some environments) path.

For example, if the output were the following

   Doc-tests tq-parser

running 3 tests
test src/tokenizer.rs:158 - tokenizer::Tokenizer<'text>::new ... ok
test src/tokenizer.rs:36 - tokenizer::Tokenizer ... ok
test src/tokenizer.rs:122 - tokenizer::Token ... ok

I could cmd-click on src/tokenizer.rs:158 and be taken, in my editor, directly to the doc test instead of having to open the file then navigate to the line.

This is more useful in the case of errors.

If I change the tokenizer::Tokenizer<'text>::new test to fail I get

test src/tokenizer.rs - tokenizer::Tokenizer<'text>::new (line 158) ... FAILED

Which could be

test src/tokenizer.rs:158 - tokenizer::Tokenizer<'text>::new ... FAILED

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions