Timple / ament_black

Python auto formatting tool ament package
Apache License 2.0
5 stars 5 forks source link

Various fixes to pass all unit tests #3

Closed asymingt closed 1 year ago

asymingt commented 2 years ago

Right now we cant integrate ament_black into any other workspace because colcon test fails. The reason is down to some formatting inconsistencies in conjunction with the pep8 and pep257 tests. Also, there are some incorrect copyright headers in this repo, and two of the unit tests are actually testing clang-format, not black. This PR fixes all of the above.

Here are some instructions to show the unit tests passing.

$ source /opt/ros/rolling/setup.bash
$ mkdir -p ~/ament_black_ws/src
$ cd ~/ament_black_ws/src
$ git clone https://github.com/asymingt/ament_black.git 
$ git checkout asymingt/pass-unit-tests
$ cd ..
$ colcon build --symlink-install
$ colcon test --packages-select ament_cmake_black --event-handlers console_direct+
...
100% tests passed, 0 tests failed out of 2

Label Time Summary:
copyright     =   0.45 sec*proc (1 test)
lint_cmake    =   0.09 sec*proc (1 test)
linter        =   0.54 sec*proc (2 tests)

Total Test time (real) =   0.54 sec
Finished <<< ament_cmake_black [0.60s]          

Summary: 1 package finished [0.86s]

$ colcon test --packages-select ament_black --event-handlers console_direct+
...
collected 3 items                                                              

test/test_copyright.py .                                                 [ 33%]
test/test_flake8.py .                                                    [ 66%]
test/test_pep257.py .                                                    [100%]

- generated xml file: /usr/local/home/asymingt/development/ament_black_ws/build/ament_black/pytest.xml -
============================== 3 passed in 0.79s ===============================
Finished <<< ament_black [1.82s]          

Summary: 1 package finished [2.08s]

The majority of these changes are switching from double to single quotes, per the flake8-quotes extension. I know this is a contentious issue, so there might be a turnaround on this PR to revert these changes. The consequence would be that any uses who have pip3 install falke8-quotes will see unit test failures.