make test output stuff clickable inside urxvt

This commit is contained in:
Dustin Carlino 2018-11-26 12:01:42 -08:00
parent 5fbd5e1546
commit b260de1d50
3 changed files with 40 additions and 3 deletions

18
clickable_links.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/python
#
# Put this in your ~/.Xdefaults:
#
# URxvt.perl-ext-common: default,matcher
# URxvt.url-launcher: /home/dabreegster/abstreet/clickable_links.py
# URxvt.matcher.button: 1
import os
import sys
arg = sys.argv[1]
if arg.startswith('http://most/'):
os.execvp('gedit', ['gedit', arg[len('http://most/'):]])
elif arg.startswith('http://ui/'):
os.execvp('urxvt', ['urxvt', '-e', 'sh', '-c', 'cd ~/abstreet/editor; cargo run ' + arg[len('http://ui/'):]])
else:
os.execvp('xdg-open', ['xdg-open', arg])

View File

@ -5,6 +5,7 @@ release_mode=""
filter="" filter=""
test_names="" test_names=""
keep_output="" keep_output=""
clickable_links="--clickable_links"
for arg in "$@"; do for arg in "$@"; do
if [ "$arg" == "--release" ]; then if [ "$arg" == "--release" ]; then
@ -15,10 +16,12 @@ for arg in "$@"; do
filter="--filter=Slow"; filter="--filter=Slow";
elif [ "$arg" == "--keep_output" ]; then elif [ "$arg" == "--keep_output" ]; then
filter="--keep_output"; filter="--keep_output";
elif [ "$arg" == "--noclickable_links" ]; then
clickable_links="";
else else
test_names="--test_names=$arg"; test_names="--test_names=$arg";
fi fi
done done
cd tests; cd tests;
RUST_BACKTRACE=1 cargo run $release_mode -- $filter $keep_output $test_names RUST_BACKTRACE=1 cargo run $release_mode -- $filter $keep_output $clickable_links $test_names

View File

@ -23,6 +23,10 @@ pub struct Flags {
/// Keep the log and savestate even for passing tests. /// Keep the log and savestate even for passing tests.
#[structopt(long = "keep_output")] #[structopt(long = "keep_output")]
keep_output: bool, keep_output: bool,
/// Print debug output as clickable HTTP links.
#[structopt(long = "clickable_links")]
clickable_links: bool,
} }
pub struct TestRunner { pub struct TestRunner {
@ -58,9 +62,21 @@ impl TestResult {
); );
} }
if !self.pass || flags.keep_output { if !self.pass || flags.keep_output {
println!(" {}", Paint::cyan(&self.output_path)); if flags.clickable_links {
println!(
" {}",
Paint::cyan(&format!("http://most/{}", self.output_path))
);
} else {
println!(" {}", Paint::cyan(&self.output_path));
}
if let Some(ref path) = self.debug_with_savestate { if let Some(ref path) = self.debug_with_savestate {
println!(" {}", Paint::yellow(path)); if flags.clickable_links {
println!(" {}", Paint::yellow(format!("http://ui/{}", path)));
} else {
println!(" {}", Paint::yellow(path));
}
} }
} }
} }