Report doctest line numbers in a clickable format#143839
Report doctest line numbers in a clickable format#143839Vrajs16 wants to merge 3 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
rustbot has assigned @GuillaumeGomez. Use |
| if let Some((left, _)) = s.split_once(" - ") { | ||
| let path_with_line = left.rsplit("test ").next().unwrap(); | ||
| let (path, line_number) = | ||
| path_with_line.rsplit_once(":").expect("line number not found"); | ||
| let path = fs::canonicalize(&path).expect("failed to canonicalize"); | ||
| let path = path.to_str().unwrap().replace('\\', "/"); | ||
| if let Some(ref mut v) = files.get_mut(&path) { | ||
| tested += 1; | ||
| let mut iter = right.split("(line "); | ||
| iter.next(); | ||
| let line = iter | ||
| .next() | ||
| .unwrap_or(")") | ||
| .split(')') | ||
| .next() | ||
| .unwrap_or("0") | ||
| .parse() | ||
| .unwrap_or(0); | ||
| if let Ok(pos) = v.binary_search(&line) { | ||
| if let Ok(pos) = v.binary_search(&line_number.parse::<usize>().unwrap_or(0)) { |
There was a problem hiding this comment.
Discussion: hm, this seems rather fragile 🤔 But I don't feel like blocking on this.
There was a problem hiding this comment.
What would you recommend? Didn't want to change much of the logic here since s is the entire test name.
| running 2 tests | ||
| test doctest.rs - (line 4) ... ok | ||
| test doctest.rs - init (line 8) ... ok | ||
| test doctest.rs:4 ... ok |
There was a problem hiding this comment.
The output is much less good though...
GuillaumeGomez
left a comment
There was a problem hiding this comment.
The new output is less good.
|
Hmm, what would you recommend? Keep the Currently regular test don't show this line text at all. So wanted to see if we could make them have similar output |
|
Doctests and unit tests are very different: doctests are based on the location of a doc comment and therefore need better indication, therefore can reuse (imo) the same display as unit test to make it easier to understand where it's coming from. |
|
☔ The latest upstream changes (presumably #144692) made this pull request unmergeable. Please resolve the merge conflicts. |
|
What are the next steps now? Should we close this PR, issue #142984 (2025) and #60706 (2019) as not planned? The impl of this PR is definitely unfortunate having to split and rearrange strings (I assume the more principled approach would be to extend the (unstable) API of Another approach could be terminal links ("OSC 8" IIRC (does that support LINE / COL?)) but that would also require |
|
@Vrajs16 |
closes #60706
closes #142984
Added a change to the add the line number to the file name to make it clickable