?login_element?

Subversion Repositories NedoOS

Rev

Rev 539 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #!/usr/bin/env bash
  2.  
  3. echo -e "\033[91mThis script will try to build all tests 'in place' => may and will overwrite files used to verify test results."
  4. echo -e "\033[93mTo just run the tests use the \"runner\" script '\033[96mtest_folder_tests.sh\033[93m'.\n\033[96m"
  5. read -p "Are you sure? (y/n) " -n 1 -r
  6. echo -e "\033[0m"
  7. [[ ! $REPLY == "y" ]] && exit 0
  8.  
  9. ## script init + helper functions
  10. PROJECT_DIR=$PWD
  11. exitCode=0
  12. totalTests=0        # +1 per ASM
  13.  
  14. # verify the directory structure is set up as expected and the working directory is project root
  15. [[ ! -f "${PROJECT_DIR}/ContinuousIntegration/build_tests_in_place.sh" ]] && echo -e "\033[91munexpected working directory\033[0m" && exit 1
  16.  
  17. source ContinuousIntegration/common_fn.sh
  18.  
  19. [[ -n "$EXE" ]] && echo -e "Using EXE=\033[96m$EXE\033[0m as assembler binary"
  20.  
  21. ## find the most fresh executable
  22. #[[ -z "$EXE" ]] && find_newest_binary sjasmplus "$PROJECT_DIR" \
  23. #    && echo -e "The most fresh binary found: \033[96m$EXE\033[0m"
  24. # reverted back to hard-coded "sjasmplus" for binary, as the date check seems to not work on some windows machines
  25.  
  26. [[ -z "$EXE" ]] && EXE=sjasmplus
  27.  
  28. # seek for files to be processed (either provided by user argument, or default tests/ dir)
  29. echo -e "Searching directory \033[96m${PROJECT_DIR}/tests/\033[0m for '.asm' files..."
  30. OLD_IFS=$IFS
  31. IFS=$'\n'
  32. TEST_FILES=($(find "$PROJECT_DIR/tests/$1"* -type f | grep -v -E '\.i\.asm$' | grep -E '\.asm$'))
  33. IFS=$OLD_IFS
  34. # check if some files were found, print help message if search failed
  35. [[ -z $TEST_FILES ]] && echo -e "\033[91mno files found\033[0m\n" && exit 1
  36.  
  37. ## go through all asm files in tests directory and build them "in place" (rewriting result files)
  38. for f in "${TEST_FILES[@]}"; do
  39.     ## standalone .asm file was found, try to build it
  40.     totalTests=$((totalTests + 1))
  41.     # set up various "test-name" variables for file operations
  42.     src_dir=`dirname "$f"`          # source directory
  43.     file_asm=`basename "$f"`        # just "file.asm" name
  44.     src_base="${f%.asm}"            # source directory + base ("src_dir/file"), to add extensions
  45.     dst_base="${file_asm%.asm}"     # local-directory base (just "file" basically), to add extensions
  46.     [[ -d "${src_base}.config" ]] && CFG_BASE="${src_base}.config/${dst_base}" || CFG_BASE="${src_base}"
  47.     OPTIONS_FILE="${CFG_BASE}.options"
  48.     LIST_FILE="${CFG_BASE}.lst"
  49.     # see if there are extra options defined (and read them into array)
  50.     options=()
  51.     [[ -s "${OPTIONS_FILE}" ]] && options=(`cat "${OPTIONS_FILE}"`)
  52.     # check if .lst file already exists, set up options to refresh it + delete it
  53.     [[ -s "${LIST_FILE}" ]] && options+=("--lst=${LIST_FILE}") && rm "${LIST_FILE}"
  54.     # enforce all symbol dumps to be sorted in any case (even when no --lst)
  55.     options+=('--lstlab=sort')
  56.     ## built it with sjasmplus (remember exit code)
  57.     echo -e "\033[95mAssembling\033[0m file \033[96m${file_asm}\033[0m in test \033[96m${src_dir}\033[0m, options [\033[96m${options[@]}\033[0m]"
  58.     # switch to test directory and run assembler
  59.     pushd "${src_dir}"
  60.     "$EXE" --nologo --msg=none --fullpath "${options[@]}" "$file_asm"
  61.     last_result=$?
  62.     popd
  63.     # non-empty LST file overrides assembling exit code => OK
  64.     [[ -s "${LIST_FILE}" ]] && last_result=0
  65.     # report assembling exit code problem here
  66.     if [[ $last_result -ne 0 ]]; then
  67.         echo -e "\033[91mError status $last_result returned by $EXE\033[0m"
  68.         exitCode=$((exitCode + 1))
  69.     else
  70.         echo -e "\033[92mOK: assembling (+listing)\033[0m"
  71.     fi
  72.     #read -p "press..."      # DEBUG helper
  73. done # end of FOR (go through all asm files)
  74. # display OK message if no error was detected
  75. [[ $exitCode -eq 0 ]] \
  76.     && echo -e "\033[92mFINISHED: OK, $totalTests tests built \033[91m\u25A0\033[93m\u25A0\033[32m\u25A0\033[96m\u25A0\033[0m" \
  77.     && exit 0
  78. # display error summary and exit with error code
  79. echo -e "\033[91mFINISHED: $exitCode/$totalTests tests failed to build \033[91m\u25A0\033[93m\u25A0\033[32m\u25A0\033[96m\u25A0\033[0m"
  80. echo "(few tests are expected to fail to build by this script, they need manual build using extra options)"
  81. exit $exitCode
  82.