-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to get paths to
.ajava
files from WPI results (#6231)
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
|
||
# Given the name of a directory containing the results produced by an | ||
# invocation of wpi-many.sh, output the human-readable paths to the .ajava | ||
# files to stdout. | ||
|
||
# Usage: | ||
# wpi-annotation-paths TARGETDIR | ||
|
||
TARGETDIR="$1" | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $(basename "$0") TARGETDIR" >&2 | ||
exit 1 | ||
fi | ||
|
||
# First, count the number of WPI log files in the given directory. | ||
WPI_LOG_FILE_COUNT=$(find "${TARGETDIR}"/*-wpi-stdout.log 2> /dev/null | wc -l) | ||
|
||
if [ "$WPI_LOG_FILE_COUNT" -ne 0 ]; then | ||
# WPI log files exist, find the latest annotation files corresponding to | ||
# each of them. | ||
for wpi_log_file in "$TARGETDIR"/*-wpi-stdout.log; | ||
do | ||
echo "Log file: $wpi_log_file" | ||
|
||
# The latest match from grep should be reported, as the latest match | ||
# in the file corresponds to the final (and most precise) set of annotations | ||
# generated by whole-program inference. | ||
FULL_AJAVA_MATCH=$(grep -oE 'Aajava=/[^ ]+' "$wpi_log_file" | tail -1 | tr -d "'") | ||
AJAVA_PATH="" | ||
if [ -z "$FULL_AJAVA_MATCH" ]; then | ||
AJAVA_PATH="No .ajava files generated" | ||
else | ||
AJAVA_PATH=$(echo "$FULL_AJAVA_MATCH" | cut -d "=" -f 2 | tr -d "'" ) | ||
fi | ||
|
||
echo "Annotated file(s): $AJAVA_PATH" | ||
done | ||
else | ||
echo "No WPI log files found in $TARGETDIR" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters