-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance diff.sh to include file difference #5607
Open
sophia-guo
wants to merge
2
commits into
adoptium:master
Choose a base branch
from
sophia-guo:diff
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,104 +1,147 @@ | ||
#!/bin/bash | ||
|
||
setup() | ||
{ | ||
setup() { | ||
VERSION1=$(echo "$REPO1" | sed 's/[^0-9]*//g') | ||
VERSION2=$(echo "$REPO2" | sed 's/[^0-9]*//g') | ||
|
||
if [[ $VERSION1 == $VERSION2 ]] ; then | ||
if [[ "$VERSION1" == "$VERSION2" ]] ; then | ||
echo "Please provide two different repositories to compare" | ||
exit 1; | ||
fi | ||
|
||
if [[ "$VERSION1" -eq 8 ]] ; then | ||
VERSION_VALUE1="$VERSION1"c | ||
else | ||
VERSION_VALUE1="$VERSION1" | ||
fi | ||
fi | ||
|
||
if [[ "$VERSION2" -eq 8 ]] ; then | ||
VERSION_VALUE2="$VERSION2"c | ||
else | ||
VERSION_VALUE2="$VERSION2" | ||
fi | ||
if [[ "$VERSION1" > "$VERSION2" ]]; then | ||
temp="$VERSION1" | ||
VERSION1="$VERSION2" | ||
VERSION2="$temp" | ||
temp="$REPO1" | ||
REPO1="$REPO2" | ||
REPO2="$temp" | ||
fi | ||
|
||
WORKDIR=$(pwd)/workspace | ||
|
||
echo "WORKDIR=$WORKDIR" | ||
echo "REPO1=$REPO1" | ||
echo "REPO2=$REPO2" | ||
|
||
[ ! -d "$WORKDIR" ] && mkdir -p "$WORKDIR" | ||
if [ ! -d "$WORKDIR/logs" ] ; then | ||
mkdir -p "$WORKDIR/logs" | ||
else | ||
rmdir "$WORKDIR/logs" | ||
mkdir -p "$WORKDIR/logs" | ||
fi | ||
fi | ||
} | ||
|
||
clone() | ||
{ | ||
cd $WORKDIR | ||
cd "$WORKDIR" || exit1 | ||
version=$1 | ||
repo=$2 | ||
if [ -d "$WORKDIR/$version" ] ; then | ||
echo "Using existing test repo at: $WORKDIR/$version" | ||
else | ||
echo "Git cloning test materials from $repo..." | ||
git clone --depth 1 -q $repo $version | ||
git clone --depth 1 -q "$repo" "$version" | ||
if [[ $? != 0 ]]; then | ||
exit 1; | ||
fi | ||
fi | ||
} | ||
|
||
compare() | ||
getVersionValue() | ||
{ | ||
VERSION_VALUE1=$(find "${WORKDIR}/${VERSION1}" -maxdepth 1 -mindepth 1 -type d -name "JCK-runtime*" | awk -F'-' '{print $NF}') | ||
VERSION_VALUE2=$(find "${WORKDIR}/${VERSION2}" -maxdepth 1 -mindepth 1 -type d -name "JCK-runtime*" | awk -F'-' '{print $NF}') | ||
} | ||
|
||
compareGroups() | ||
{ | ||
dirName=$1 | ||
cd $WORKDIR/$VERSION1/JCK-$dirName-$VERSION_VALUE1/tests | ||
echo "Listing test directories under $dirName at: `pwd`" | ||
find . -maxdepth 2 -mindepth 2 -type d > $WORKDIR/logs/$dirName-$VERSION_VALUE1.txt | ||
|
||
cd $WORKDIR/$VERSION2/JCK-$dirName-$VERSION_VALUE2/tests | ||
echo "Listing test directories under $dirName at: `pwd`" | ||
find . -maxdepth 2 -mindepth 2 -type d > $WORKDIR/logs/$dirName-$VERSION_VALUE2.txt | ||
|
||
if cmp -s $WORKDIR/logs/$dirName-$VERSION_VALUE1.txt $WORKDIR/logs/$dirName-$VERSION_VALUE2.txt; then | ||
echo "SAME : '$dirName' folder identical in both given versions: $VERSION1 & $VERSION2" | ||
else | ||
diff $WORKDIR/logs/$dirName-$VERSION_VALUE1.txt $WORKDIR/logs/$dirName-$VERSION_VALUE2.txt > $WORKDIR/logs/$dirName-diff.txt | ||
echo "DIFFERENT : '$dirName' folder content are different in two given versions: $VERSION1 & $VERSION2" | ||
jdkVersion1TestDir="${WORKDIR}/${VERSION1}/JCK-${dirName}-${VERSION_VALUE1}/tests" | ||
jdkVersion2TestDir="${WORKDIR}/${VERSION2}/JCK-${dirName}-${VERSION_VALUE2}/tests" | ||
|
||
rc=0 | ||
find "${jdkVersion1TestDir}" -maxdepth 2 -mindepth 2 -type d | sed "s|${jdkVersion1TestDir}||" | sort > "$WORKDIR/logs/$dirName-groups-${VERSION_VALUE1}.txt" | ||
find "${jdkVersion2TestDir}" -maxdepth 2 -mindepth 2 -type d | sed "s|${jdkVersion2TestDir}||" | sort > "$WORKDIR/logs/$dirName-groups-${VERSION_VALUE2}.txt" | ||
|
||
if [[ "${dirName}" == "runtime" ]]; then | ||
find "${jdkVersion1TestDir}/vm/verifier" -maxdepth 1 -mindepth 1 -type d | sed "s|${jdkVersion1TestDir}||" | sort >> "$WORKDIR/logs/$dirName-groups-${VERSION_VALUE1}.txt" | ||
find "${jdkVersion2TestDir}/vm/verifier" -maxdepth 1 -mindepth 1 -type d | sed "s|${jdkVersion2TestDir}||" | sort >> "$WORKDIR/logs/$dirName-groups-${VERSION_VALUE2}.txt" | ||
fi | ||
|
||
# Compare if playlist test groups are different | ||
diff "$WORKDIR/logs/$dirName-groups-$VERSION_VALUE1.txt" "$WORKDIR/logs/$dirName-groups-$VERSION_VALUE2.txt" > "$WORKDIR/logs/$dirName-groups-diff.txt" || rc=$? | ||
if [ $rc -eq 0 ]; then | ||
echo "SAME GROUPS : Groups under '$dirName' are identical in given versions: $VERSION1 & $VERSION2" | ||
else | ||
echo "DIFFERENT GROUPS: Groups under '$dirName' are different in two given versions: $VERSION1 & $VERSION2" | ||
echo "Please manually investigate the following differences in the two given repositories:" | ||
cat $WORKDIR/logs/$dirName-diff.txt | ||
return 1 | ||
fi | ||
cat "$WORKDIR/logs/$dirName-groups-diff.txt" | ||
fi | ||
return $rc | ||
} | ||
|
||
compareNewTestsInSubGroups() { | ||
subGroups=("vm.verifier.instructions" "lang.CLSS" "lang.EXPR" "lang.CONV" "lang.INTF" "lang.LMBD" "lang.DASG" "lang.NAME" "lang.TYPE" "lang.ANNOT" "lang.STMT") | ||
touch "$WORKDIR/logs/NewTestsInSubGroups.txt" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we guarantee this file doesn't exist from a previous run? |
||
for group in "${subGroups[@]}"; do | ||
grep "${group}" "${WORKDIR}/${VERSION2}/JCK-compiler-${VERSION_VALUE2}/NewTests.txt" | sort | uniq >> "$WORKDIR/logs/NewTestsInSubGroups.txt" | ||
done | ||
rc=0 | ||
if [ ! -s "$WORKDIR/logs/NewTestsInSubGroups.txt" ]; then | ||
echo " No Subdir Group changes." | ||
else | ||
touch "$WORKDIR/logs/DiffsInSubGroups.txt" | ||
while IFS= read -r line; do | ||
subdir=$(echo "$line" | tr '.' '/' | sed 's/[[:blank:]]//g') | ||
component="compiler" | ||
if [[ "$subdir" == *"verifier"* ]]; then | ||
component="runtime" | ||
fi | ||
diff "${WORKDIR}/${VERSION1}/JCK-${component}-${VERSION_VALUE1}/tests/${subdir}" "${WORKDIR}/${VERSION2}/JCK-${component}-${VERSION_VALUE2}/tests/${subdir}" >> "$WORKDIR/logs/DiffsInSubGroups.txt" | ||
done < "$WORKDIR/logs/NewTestsInSubGroups.txt" | ||
sed -n '/Only in /p' "$WORKDIR/logs/DiffsInSubGroups.txt" | sort > "$WORKDIR/logs/tmp.txt" && mv "$WORKDIR/logs/tmp.txt" "$WORKDIR/logs/DiffsInSubGroups.txt" | ||
echo "NOTE: ACTION TO DO - Delete tests Only in ${WORKDIR}/${VERSION1}/ from jck/subdirs/jck${VERSION_VALUE2}.mk" | ||
echo "NOTE: ACTION TO DO - Add tests Only in ${WORKDIR}/${VERSION2}/ to jck/subdirs/jck${VERSION_VALUE2}.mk" | ||
cat "$WORKDIR/logs/DiffsInSubGroups.txt" | ||
rc=1 | ||
fi | ||
return $rc | ||
} | ||
|
||
jobTime() { | ||
end_time="$(date -u +%s)" | ||
date | ||
elapsed="$((end_time-begin_time))" | ||
echo "Total analysis took ~ $elapsed seconds." | ||
} | ||
|
||
date | ||
echo "Starting test materials scan.." | ||
begin_time="$(date -u +%s)" | ||
|
||
begin_time="$(date -u +%s)" | ||
REPO1=$1 | ||
REPO2=$2 | ||
diffFound=0 | ||
|
||
setup | ||
|
||
clone $VERSION1 $REPO1 | ||
clone $VERSION2 $REPO2 | ||
|
||
compare runtime | ||
diffFound=$? | ||
compare compiler | ||
setup | ||
clone "$VERSION1" "$REPO1" | ||
clone "$VERSION2" "$REPO2" | ||
getVersionValue | ||
|
||
echo "Compare per playlist TestCases ==================================================" | ||
echo "" | ||
for comp in "runtime" "compiler"; do | ||
compareGroups "${comp}" | ||
diffFound=$(( diffFound + $? )) | ||
done | ||
echo "Compare per playlist TestCases Done ==============================================" | ||
echo "" | ||
echo "Compare New Tests with Sub Groups in jckversion.mk ===============================" | ||
# Check if new tests are part of subdir make targets to ensure tests groups are updated | ||
compareNewTestsInSubGroups | ||
diffFound=$(( diffFound + $? )) | ||
|
||
end_time="$(date -u +%s)" | ||
echo "Done!" | ||
date | ||
elapsed="$(($end_time-$begin_time))" | ||
echo "Total analysis took ~ $elapsed seconds." | ||
echo "Compare New Tests with Sub Groups in jckversion.mk Done ===============================" | ||
echo "" | ||
jobTime | ||
|
||
if [[ $diffFound != 0 ]]; then | ||
exit 1; | ||
exit 1 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space missing