Chief. Windows
If you see this error:
Running unit tests:
: not foundtests.sh: 2: ./tests/runtests.sh:
./tests/runtests.sh: 4: ./tests/runtests.sh: Syntax error: word unexpected (expecting "do")
You have two options:
-
Open the file
tests/runtests.shin VS Code in whatever subproject folder you’re working in, e.g.fizzbuzz. Click on the lower right of the screen where it saysCRLF. ChooseLF. Save the file. Then the error should go away. -
You can do this from the command line with the
trcommand:
cd tests
cat runtests.sh | tr -d '\r' > runtests.tmp
mv runtests.tmp runtests.sh
The root of the problem is a setting in git that causes all newlines (LF) to
be converted to carriage-return/newline (CRLF). The script runtests.sh is a
bash script that bash runs, and bash hates \r and pukes everywhere.
To cause git to not do newline conversion for future clones, run the following:
git config --global core.autocrlf false
This is caused by an older version of the ar and ranlib packages being installed.
Sometimes these conflict with the versions installed with xcode.
If running MacPorts:
sudo port selfupdate
sudo port upgrade cctools
If running Brew:
sudo brew update
sudo brew upgrade gcc