Advertisement
tlarson07

getDetails

Jan 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.94 KB | None | 0 0
  1. # EXPLANATION
  2. # ==========================================================================
  3. # Populates the current directory with the appropriate: Makefile and tests
  4. # for projects and exercises in 357 Winter Quarter 2018.
  5. # Additionally this content will be printed conveniently to the terminal.
  6.  
  7. # I use the following directory naming scheme
  8. #        ~357/exercises/Exercise1/source/Makefile
  9. #        ~357/projects/Project1/evaluations/descCore
  10. #        ~357/projects/Project1/evaluations/descFeature
  11.  
  12. # USAGE
  13. # ==========================================================================
  14. # if current directory is 'Exercise1'
  15. # then it will get Makefile and tests for Exercise1
  16. getDetails
  17.  
  18. # ==========================================================================
  19. #!/bin/bash
  20.  
  21. # colors!
  22. RED='\033[0;31m'
  23. BLUE='\033[0;34m'
  24. CYAN='\033[0;36m'
  25. WHITE='\033[0;37m'
  26. RESET='\033[0m'
  27.  
  28. # get the current directory name
  29. name=${PWD##*/}
  30. kurt=~kmammen-grader/evaluations/W18/357/$name
  31.  
  32. # get Makefile, requirements and tests
  33. mkdir source
  34. mkdir evaluations
  35. tail -n +1 $kurt/Makefile > source/Makefile
  36. tail -n +1 $kurt/requirements > evaluations/requirements
  37. tail -n +1 $kurt/tests/core/**/description > evaluations/descCore
  38. tail -n +1 $kurt/tests/feature/**/description > evaluations/descFeature
  39.  
  40. # print requirements
  41. printf "${WHITE}Requirements\n${RESET}"
  42. echo ............
  43. cat $kurt/requirements
  44. echo
  45.  
  46. # print core tests with values
  47. if [ -e $kurt/tests/core/testList ]; then
  48.    NUM_CORE=$(cat $kurt/tests/core/testList | wc -l)
  49.    NUM_CORE_VAL=$(cat $kurt/tests/core/value)
  50.    ls $kurt/tests/core/
  51.    printf "${WHITE}Number of core tests: $NUM_CORE${RESET} | ${CYAN}value of core tests: $NUM_CORE_VAL\n${RESET}"
  52.    echo    ..................................................
  53.    let NUM_CORE+=1
  54.    COUNTER=1
  55.    while [  $COUNTER -lt $NUM_CORE ]; do
  56.       printf "${BLUE}core test0$COUNTER${RESET}\n"
  57.       cat $kurt/tests/core/test0$COUNTER/description
  58.       echo
  59.       let COUNTER+=1
  60.    done
  61. fi
  62.  
  63. # print feature tests with values
  64. if [ -e $kurt/tests/feature/testList ]; then
  65.    NUM_FEAT=$(cat $kurt/tests/feature/testList | wc -l)
  66.    ls $kurt/tests/feature/
  67.    printf "${WHITE}Number of feature tests: $NUM_FEAT${RESET}\n"
  68.    echo ..........................
  69.    let NUM_FEAT+=1
  70.    COUNTER=1
  71.    while [  $COUNTER -lt $NUM_FEAT ]; do
  72.       if (( $COUNTER < 10 ))
  73.       then
  74.          NUM_FEAT_VAL=$(cat $kurt/tests/feature/test0$COUNTER/value)
  75.          printf "${BLUE}feature test0$COUNTER${RESET} | ${CYAN}value of feature test0$COUNTER: $NUM_FEAT_VAL\n${RESET}"
  76.          cat $kurt/tests/feature/test0$COUNTER/description
  77.       else
  78.          NUM_FEAT_VAL=$(cat $kurt/tests/feature/test$COUNTER/value)
  79.          printf "${BLUE}feature test$COUNTER${RESET} | ${CYAN}value of feature test$COUNTER: $NUM_FEAT_VAL\n${RESET}"
  80.          cat $kurt/tests/feature/test$COUNTER/description
  81.       fi
  82.       echo
  83.       let COUNTER+=1
  84.    done
  85. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement