Skip to content

Commit

Permalink
scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibylau committed Feb 15, 2024
1 parent ae350ea commit ff6ae7c
Show file tree
Hide file tree
Showing 8 changed files with 3,875 additions and 0 deletions.
115 changes: 115 additions & 0 deletions scripts/clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Get grading directory
gradingDir="/home/ro99/Grading/netidsRepo"
paName="pa2-dstruct"
submissionTag=$paName-submission

mkdir clangResults
clangDir=$(pwd)/clangResults

# Get netid list
netids=$( cat ../admin/ece2400-netids.txt )

paReleaseDir=/home/ro99/Grading/ece2400-pa-release/$paName

srcFiles=$( ls $paReleaseDir/src )
testFiles=$( ls $paReleaseDir/test )

countComments() {
# $1 is destination folder
cd $1
count=0

files=$( ls )
for file in $files
# Check all the original files in source and test folders only
do if [[ $file != "." && ( $srcFiles == *"$file"* || $testFiles == *"$file"* ) ]]
then
commentCount=$( grep -o "//" $file | wc -l )
count=$(( $count + $commentCount ))
fi
done
}

# Function for finding number of changes after clang-format
gitClang () {
# $1 is netid, $2 is destination folder
dest=$gradingDir/$1/$paName/$2
cd $dest
files=$( find . )

# Reset counters for exectuable and core files
if [ $2 == src ]
then
otherFiles=0
fi

for file in $files
# Check if file is executable
do if [[ $file == *".c" ]] || [[ $file == *".h" ]]
then
clang-format -i "$file"
elif [[ $file != "." ]]
then (( otherFiles+=1 ))
fi
done

# Get last line of stat summary that contains num of files changed, lines inserted, and lines deleted
stats=$( git diff --stat --summary | tail -1 )

# If stats is null
if [ -z "$stats" ]
then stats="0,0,0,"
else
# Extract the numbers and delimit with commas
stats=$( echo $stats | tr -dc '0-9 ' | tr -s '[:blank:]' ',')
fi

# Reset clang-format changes
git reset --hard
}

# Git clone all student directories
for netid in $netids
# If netid is not in gradingDir
do if [ ! -d $gradingDir/$netid ]
then
git clone git@github.com:cornell-ece2400/"$netid".git $gradingDir/$netid
cd $gradingDir/$netid
git checkout $submissionTag
else
cd $gradingDir/$netid

# Reset all changes made previously
git reset --hard
fi
done

# Check clang formatting & count comments

countComments $paReleaseDir/src
# Original counts are based on the number of comments with "Assignment Task" deleted
origSourceCount=$count

countComments $paReleaseDir/test
origTestCount=$count

echo "Netid,Source File Changed,Source Lines Inserted,Source Lines Deleted,\
Test Files Changed,Test Lines Inserted,Test Lines Deleted,Other Files Count,Source Comments Count, Test Comments Count"\
> $clangDir/ece2400-$paName-clang.csv

for netid in $netids
do
gitClang $netid src
results=$stats

gitClang $netid test
results="$results$stats"

countComments $gradingDir/$netid/$paName/src
sourceCount=$(( $count - $origSourceCount ))

countComments $gradingDir/$netid/$paName/test
testCount=$(( $count - $origTestCount ))

echo "$netid,$results$otherFiles,$sourceCount,$testCount" >> $clangDir/ece2400-$paName-clang.csv
done
68 changes: 68 additions & 0 deletions scripts/clangResults/ece2400-pa2-dstruct-clang.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Netid,Source File Changed,Source Lines Inserted,Source Lines Deleted,Test Files Changed,Test Lines Inserted,Test Lines Deleted,Other Files Count,Source Comments Count, Test Comments Count
abg227,8,93,105,7,277,256,0,-94,-1
akk72,6,45,50,7,296,303,1,-1,6
an474,8,121,118,7,320,276,1,14,223
az292,6,49,51,7,322,289,0,-18,165
ba394,8,158,167,7,124,108,0,-88,10
by277,8,83,88,7,183,160,0,29,112
cgc98,8,97,114,7,229,245,0,-13,-20
co253,5,24,24,3,55,44,0,-5,168
cw655,8,72,75,7,133,111,0,16,91
ewh73,6,72,75,5,90,80,2,22,93
gb438,8,71,74,7,158,133,0,14,87
gx55,7,81,104,7,176,161,0,18,44
hl865,8,38,44,7,78,62,0,47,32
hp298,8,93,106,7,170,142,0,22,83
jcn84,10,642,634,7,178,167,204,42,72
jcz42,8,104,103,7,240,215,0,27,112
jf832,8,63,67,7,209,180,0,-6,152
jl3945,8,128,131,5,62,51,8,13,-1
jro77,8,116,131,7,300,288,0,17,178
jt847,8,141,154,7,342,328,0,-6,177
kae87,8,98,111,7,168,142,2,-4,66
kr397,8,102,132,7,232,246,2,22,159
kw573,2,5,5,0,0,0,0,25,76
lh479,8,81,91,7,177,151,0,-8,103
lmm343,8,100,97,7,171,146,0,-2,147
mac497,8,148,168,7,319,290,0,27,86
mhg99,4,19,19,1,48,36,6,-10,55
ml2359,8,119,124,7,262,235,0,2,155
mt633,8,108,125,7,221,193,1,5,69
my474,8,101,101,7,342,298,0,10,166
nl475,8,161,165,7,134,115,0,-11,-14
nmv33,8,112,120,9,753,716,192,14,44
pl568,8,59,61,7,110,88,0,46,65
ps978,2,5,5,5,65,54,0,22,67
qd39,4,23,29,4,57,45,0,-12,148
qy95,8,112,114,7,215,183,0,9,97
rm756,8,74,77,7,340,288,0,4,299
rpg78,8,139,147,7,141,131,0,12,11
rt457,8,96,99,7,215,180,0,10,128
sjz38,8,91,117,7,265,265,0,7,117
sl3295,8,101,101,7,186,156,0,22,107
ssp92,8,79,85,7,188,177,0,69,155
svo6,8,106,139,7,182,165,0,10,28
ta326,8,86,93,7,270,226,2,-21,30
tkb42,8,108,116,7,231,193,0,-86,-44
tl676,7,22,28,4,61,52,0,19,86
vae4,8,101,119,7,229,206,0,-8,151
xf78,7,37,37,7,136,98,0,63,152
xl764,4,19,19,3,60,49,0,9,215
xl792,4,19,19,5,61,51,0,21,189
xo28,8,87,90,7,179,158,0,-11,122
xy425,8,38,44,7,106,93,0,47,44
yc2563,8,103,112,7,208,172,0,17,9
ym474,5,17,17,6,279,235,0,59,331
yn224,8,64,68,7,182,148,0,23,163
zc444,8,83,101,7,150,130,0,-18,0
zl766,8,92,95,7,199,162,0,10,167
zl768,8,94,99,7,313,272,0,40,217
zm235,5,26,27,7,126,110,0,11,66
zx278,5,35,38,4,56,44,0,-9,130
zy393,5,25,26,1,48,36,0,11,87
pg476,8,101,108,7,245,216,0,-27,92
sl3282,8,104,108,7,203,172,2,-5,71
sz592,8,73,85,7,96,71,0,8,91
ss3969,8,151,158,7,401,354,0,29,209
yz2583,8,91,99,7,182,148,0,27,95
zw627,8,42,47,4,63,53,0,-1,113
Loading

0 comments on commit ff6ae7c

Please sign in to comment.