Skip to content

Hyperlink failed examples

gitlab-qa-bot requested to merge github/fork/swebb/hyperlink_output into master

Created by: swebb

Allow users to click on failed examples and have them open in their editor. Uses terminal hyperlinks to encode the file path in the output.

Unfortunately the file:// uri scheme doesn't have a way to specify line numbers. To get around this I've had to use a custom rspec:// uri scheme (naming open suggestions). The user registers a custom handler for the rspec:// uri scheme. E.g.,

[Desktop Entry]
Name=RSpec uri scheme
GenericName=Open spec failures in your faviourite text editor
TryExec=gvim
Exec=rspec-scheme-handler %u
Terminal=false
Type=Application
Keywords=Text;editor;
Icon=gvim
Categories=Utility;TextEditor;
StartupNotify=true
MimeType=x-scheme-handler/rspec
X-Desktop-File-Install-Version=0.23

and write a wrapper to extract the path and line number like so:

#!/bin/bash

url=${1#rspec://}
filename=${url%%:*}
line=${url##*:}

gvim --servername GVIM --remote-tab +$line $filename

Merge request reports