Skip to content

Libtest produces invalid JSONs for doctests on Windows #76151

Closed
@mchernyavsky

Description

@mchernyavsky

Example project:

  • lib.rs
/// ```
/// ```
fn _foo() {}

I run the following command:

$ cargo test -- -Z unstable-options --format=json

This produces the following output:

    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running target\debug\deps\untitled-d6b954951d0421be.exe
{ "type": "suite", "event": "started", "test_count": 0 }
{ "type": "suite", "event": "ok", "passed": 0, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0 }
   Doc-tests untitled
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "src\lib.rs - _foo (line 1)" }
{ "type": "test", "name": "src\lib.rs - _foo (line 1)", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 1, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0 }

For example, this JSON

{ "type": "test", "event": "started", "name": "src\lib.rs - _foo (line 1)" }

can't be parsed, because contains unescaped \ character.

Meta

rustc --version --verbose:

rustc 1.46.0 (04488afe3 2020-08-24)
binary: rustc
commit-hash: 04488afe34512aa4c33566eb16d8c912a3ae04f9
commit-date: 2020-08-24
host: x86_64-pc-windows-msvc
release: 1.46.0
LLVM version: 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions