Index: build/build.sh =================================================================== diff -u -rc2636ef8b23e14b09520f1a49890b1fc82e6443a -r613144c7d383418cf0f04bbe07d70572f883bc7b --- build/build.sh (.../build.sh) (revision c2636ef8b23e14b09520f1a49890b1fc82e6443a) +++ build/build.sh (.../build.sh) (revision 613144c7d383418cf0f04bbe07d70572f883bc7b) @@ -75,6 +75,96 @@ echo } +function getManualCases() +{ + currentDir=$(pwd) + # Create a temporary folder + manualCasesFolder=tempManualCases + mkdir $manualCasesFolder + cd $manualCasesFolder + + # Clone the application just for checking the manual cases + git clone ssh://git@dvm-linux02:7999/ui/application.git + cd application + + # Declare and associatvie array + declare -A listOfFiles + + # List all the files and replace any space in the name of the files with _ + # If there is any space in the name of the files, it is confused with multiple file names + find . -depth -name '* *' | while IFS= read -r f ; do mv -i \ + "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done + + # Find all the files in the application folder (recursively) + # and put it in a an array + allFiles=($(find . -type f) + for i in ${allFiles[@]} + do + # In the files, look for the term "coco begin validated" and get its line number + data=$(cat $i | awk '/coco begin validated:/ { print NR }') + # If anything was found + if [[ ! -z $data ]] + then + # Insert it in the associative array with key=filename, element=array of line numbers + # i.e. allFiles[./source/guiThread.cpp]=[12 34 56 123 456] + listOfFiles[$i]=${data[@]} + fi + done + + # Adding title to this section of the status report + echo "File, Line Number, Function" >> $STATUS_REPORT + # In the function names, there might be , so the csv file separate them. In the code, + # those commas are replaced with - to prevent that + echo " "," ", "NOTE: In the manual cases commas were replaced with" \ + "- to ensure they will not be separated in a csv file" >> $STATUS_REPORT + + # Loop through the list of the files + for file in ${!listOfFiles[@]} + do + previousLine=1 + # For each file, loop through the list of the line numbers + for line in ${listOfFiles[$file]} + do + # From previous line number to the current line number, search for "{" and get its line number in a list + # This is done in a range, for instance, if the list of the lines that contain "coco begin validated" in a file + # is [12, 24, 56], the scan will be from previous to the current line. previousLine starts from 1 + # In the list of the line numbers that contain "{", only the last item is needed since it is closest to the current + # line number. + localLine=($(cat $file | awk "NR==$previousLine, NR==$line" | awk '/{/ {print NR}')) + # The line numbers that are found are offset from the start line that has been provided in the awk command + # Also, the screen starts from one line after so the line calculation is subtracted by 1 + # So the line that contains "{" from the beginning of the file is calculated below + line=$(( $previousLine + ${localLine[-1]} - 1 )) + # Go to the calculated line number, look for "{", separate the "{" from the rest, print the first column, and + # remove all the unseen characters + manualCase=$(cat $file | awk "NR==$line" | awk '/{/' | awk -F"{" '{print $1}' | tr -cd '[:alnum:]._-') + # If there was nothing in the line (i.e { ) so there is nothing else + if [[ -z $manualCase ]] + then + # Go another line above: + # void test () + #{ + line=$(( $line - 1 )) + # Get the value of the line + manualCase=$(cat $file | awk "NR==$line" | awk '{print}') + fi + # Some of the functions might have multiple arguments that are comma separated, + # therefore, the csv file puts them into the other column. The commas in the functions + # are replaced with - to prevent that + # i.e void test(QString &a, bool b) -> void test(QString &a - bool b) + manualCase=$(echo $manualCase | sed "s/,/ -/") + # Write the values to the statu report + echo $file, $line, $manualCase >> $STATUS_REPORT + # Set the current line as the previous line and get ready for the next check + previousLine=$line + done + done + + echo "", "", "" >> $STATUS_REPORT + cd $currentDir + rm -rf $manualCasesFolder +} + #check if the out folders already exists if [[ -e $out_path ]]; then rm -frd $out_path @@ -210,5 +300,7 @@ # Generate code review project getCodeReviewReport "UI" $REMOTE_DIR +getManualCases +