Uncrustify: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
(showing diff on tests)
 
Line 66: Line 66:
To run the tests:
To run the tests:
  ./run_tests.sh c-sharp
  ./run_tests.sh c-sharp
To show diff on failure, use the parameter -g when calling uncrustify:
./run_tests.sh c-sharp -d


You can add new tests with these steps:
You can add new tests with these steps:
Line 71: Line 74:
* add an expected output file to https://github.com/uncrustify/uncrustify/tree/master/tests/output/cs
* add an expected output file to https://github.com/uncrustify/uncrustify/tree/master/tests/output/cs
* add the test in https://github.com/uncrustify/uncrustify/blob/master/tests/c-sharp.test
* add the test in https://github.com/uncrustify/uncrustify/blob/master/tests/c-sharp.test
You can change the log_level to 7 in https://github.com/uncrustify/uncrustify/blob/master/tests/run_tests.py#L84 so that you see the difference of the result of uncrustify compared to your expected output, if the test fails.


If uncrustify has an exception, you only get message like this:
If uncrustify has an exception, you only get message like this:

Latest revision as of 05:39, 8 June 2017

about uncrustify

"Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA"

"The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier."

See sources at Github: https://github.com/uncrustify/uncrustify

current version used

  • Currently we still use version 0.56.

our own installer for Windows

it is easier to have an installer for Windows, instead of the zip file provided by the uncrustify project.

build installer from git master

  • need a Fedora 25 64 bit virtual machine
dnf install git automake gcc-c++ make zip python cmake
git clone https://github.com/uncrustify/uncrustify.git
cd uncrustify
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
# resulting linux binary is build/uncrustify
cd ..

dnf install mingw32-gcc-c++ mingw32-winpthreads-static 
mkdir buildwin-32
cd buildwin-32
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake \
   -DCMAKE_EXE_LINKER_FLAGS="-static -s" ..
make
cpack
# Result in: buildwin-32/uncrustify-Uncrustify-0.64-574-bc4307b-win32.zip

Release ICT_OpenPetra_2016_06

git clone -b ICT_OpenPetra_2016_06 https://github.com/tpokorra/uncrustify.git uncrustify.ICT_OpenPetra_2016_06

Debugging uncrustify and adding tests

For C# 6 support we noticed that even version 0.62 did not support all new C# 6 features. see https://sourceforge.net/p/uncrustify/bugs/672/ for details.

On Linux, I cloned the git master of uncrustify, to see if those issues had already been fixed there.

git clone https://github.com/uncrustify/uncrustify.git
cd uncrustify
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
cd ../src/
ln -s ../build/uncrustify
cd ..

To run the tests:

./run_tests.sh c-sharp

To show diff on failure, use the parameter -g when calling uncrustify:

./run_tests.sh c-sharp -d

You can add new tests with these steps:

If uncrustify has an exception, you only get message like this:

RUN: /home/timotheusp/dev/uncrustify.tpokorra/src/uncrustify -q -c config/ben.cfg -f input/cs/exception-filters.cs  > results/cs/10160-exception-filters.cs
FAILED: 10160

Then you should run this on the commandline, but without the -q:

cd tests
/home/timotheusp/dev/uncrustify.tpokorra/src/uncrustify -c config/ben.cfg -f input/cs/exception-filters.cs  > results/cs/10160-exception-filters.cs

Some hints for debugging:

  • does the parsing work? brace_cleanup.cpp, combine.cpp
  • does the output work? space.cpp, newlines.cpp
  • chunk_t, see uncrustify_types.h.
  printf("my message %s\n", pc->str.c_str());
  printf("my message %s\n", pc->next->str.c_str());