Skip to content

Commit

Permalink
Add -c|--compare to specify target
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaghubi committed Aug 11, 2023
1 parent 78100b0 commit 8d45efd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
25 changes: 20 additions & 5 deletions libs/show_results_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,34 @@
rsort($results);

$index = 0;
if (!empty($argv[1]) && $argv[1] < count($results)) {
$index = intval($argv[1]);

if (!empty($results[$argv[1]])) {
$index = $argv[1];
}

if (preg_match("/output\/(\S+)/", @$results[$index], $match)) {
echo "Results: " . @$match[1] . PHP_EOL;
echo " Results:\t\t" . @$match[1] . PHP_EOL;
}

$compareTo = -1;

if (!empty($results[$argv[2]])) {
$compareTo = $argv[2];
} else if (!empty($results[$index+1])) {
$compareTo = $index+1;
}

if ($compareTo>=0 && preg_match("/output\/(\S+)/", @$results[$compareTo], $match)) {
echo " Compare to:\t\t" . @$match[1] . PHP_EOL;
}

echo '|-------------------|------------------------:|-------------:|----------:|-------------:|'.PHP_EOL;

$pr = parse_results(@$results[$index] . '/results.log');

if ($index + 1 >= count($results)) {
if ($compareTo<0) {
echo build_table($pr);
} else {
$prComp = parse_results(@$results[$index+1] . '/results.log');
$prComp = parse_results(@$results[$compareTo] . '/results.log');
echo build_table($pr, $prComp);
}
14 changes: 12 additions & 2 deletions results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ function showHelp()
{
cat << HEREDOC
Usage: bash results.sh [-l] [-t 1] [-d 2]
Usage: bash results.sh [-t 0] [-c 3]
Optional Arguments:
-c [index], --compare [index] Compare current results with (use --list)
-d [index], --delete [index] Delete by index id (use --list)
-dall, --deleteall Delete all results
-h, --help Show this help message and exit
Expand All @@ -33,12 +34,20 @@ IFS=$oldIFS

results=(`ls ./output/`)
index=0
compare_to=1
for option in "${params[@]}"
do
case "$option" in
-dall|--deleteall)
rm -rf ./output/*
;;
-c*|--compare*)
compare=${option//--compare /}
compare=${option//-c /}
if [ ${#compare} -ge 0 ]; then
compare_to="$compare"
fi
;;
-d*|--delete*)
delete=${option//--delete /}
delete=${option//-d /}
Expand Down Expand Up @@ -66,6 +75,7 @@ do
top=${option//-t /}
if [ ${#top} -ge 0 ]; then
index="$top"
compare_to=$index+1
fi
;;
-h|--help)
Expand All @@ -80,4 +90,4 @@ do
esac
done

php ./libs/show_results_table.php $index
php ./libs/show_results_table.php $index $compare_to

0 comments on commit 8d45efd

Please sign in to comment.