KEINOS/Hello-Cobra

Bad indentation when `run-tests-coverage.sh`

KEINOS opened this issue · 1 comments

$ ./.github/run-tests-coverage.sh
* Running in regular mode. Use "-v" or "--verbose" option for verbose output.
* Moving current path to: /workspaces/QiiTask
* Current path is: /workspaces/QiiTask

- Static analysys: Scanning all the packages

  Success! All Go vet static analysis passed.

- Unit test: Testing all the packages
        ok      github.com/Qithub-BOT/QiiTask   0.004s  coverage: 100.0% of statements
        ok      github.com/Qithub-BOT/QiiTask/cmdlist   0.009s  coverage: 100.0% of statements
        ok      github.com/Qithub-BOT/QiiTask/cmdsort   0.004s  coverage: 100.0% of statements
        ok      github.com/Qithub-BOT/QiiTask/config    0.093s  coverage: 100.0% of statements
        --- FAIL: ExampleFmtAsAbout (0.00s)
        got:
        About:
        A longer description that spans multiple
        lines and likely
        contains examples and usage of using your command.
        want:
        About:
        A longer description that spans multiple
        lines and likely
        contains examples and usage of using your command.
        FAIL
        coverage: 100.0% of statements
        FAIL    github.com/Qithub-BOT/QiiTask/utils     0.004s
        FAIL

The above got: contents and want: contents contain spaces before each line. But it seems to be trimmed.

It is missing the IFS= to clear the white spaces list.

 function indentStdIn() { 
     indent="\t" 
-    while read -r line; do 
+    while IFS= read -r line; do 
         echo -e "${indent}${line}" 
     done 
     echo 
 } 
  • Wrong indent

# indentStdIn indents the STDIN given to the function
function indentStdIn() {
indent="\t"
while read -r line; do
echo -e "${indent}${line}"
done
echo
}

  • Right indent

function indentStdIn() {
indent="\t"
while IFS= read -r line; do
echo -e "${indent}${line}"
done
echo
}