Commit Graph

144 Commits

Author SHA1 Message Date
Seth Hillbrand f265a52c96 Enforce build order with qa system
The QA objects link to the direct kiface objects, which creates a second
dependency on the generated lexer files.  To ensure that the primary
apps are finished building them in a (potentially) different thread, we
set a false dependency on the final build product in the qa CMake.

Fixes: lp:1833851
* https://bugs.launchpad.net/kicad/+bug/1833851

(cherry picked from commit 172542cfc4)
2019-06-23 12:53:19 -07:00
John Beard 20c8b094d6 SHAPE_ARC: Fix bug introduced in 5813164d1.
This fixes the bug exposed in the previous commit.
The tests which exposed it now pass and expected failures
removed.

(cherry picked from commit d89d0e6b74)
2019-04-25 23:51:01 +01:00
John Beard 552ddfbdfa SHAPE_ARC: Expose bug introduced by 5813164d1 in tests
The angle needs to be added to the start angle.

Add tests to cover this:

* Check end point is correct
* Check midpoints are within tolerance

This would have prevented the bug fixed in 5813164d1,
as well as the bug fixed in this commit.

As well as failed tests, this manifests when routing across
Edge.Cuts arcs (unless they happen to start at 0 degrees
staritng angle).

Expose as expected failure to prove tests catch it.
Fix to follow in separate commit.

(cherry picked from commit 183f4fe9a5)
2019-04-25 23:51:01 +01:00
Seth Hillbrand b6c9d4a88c Add missing header to qa
(cherry picked from commit 9c00a7a5c3)
2019-04-24 14:33:28 +01:00
John Beard 440e135e3a QA: Remove expected failure from fixed tests
Commit 55fcbddde8 fixed a couple of
failures in the SHAPE_POLY_SET tests, so these no longer
need the expected failure markers.

(cherry picked from commit 371149756d)
2019-04-17 11:48:11 +01:00
John Beard ab39f06003 SHAPE_ARC: fix polyline conversion when radius=0
Prevent a divide-by-zero bug in SHAPE_ARC::ConvertToPolyline.

When the radius is zero, just use the initial angle (it makes
no different anyway, the result is the centre point, which is
the start point.

(cherry picked from commit e312e2b286)
2019-04-17 11:29:28 +01:00
John Beard 98f78f534c QA: Test arc to polylines - this has a bug
Add unit test of SHAPE_ARC::ConvertToPolyline.

This function has a bug when the arc is of zero radius. This
test shows the bug, but does not fix it yet.

(cherry picked from commit ce84c19a38)
2019-04-17 11:29:28 +01:00
John Beard 322524101d Libeval: consistent formatting for NaN
On some platforms like MSVC, NaN prints as "-nan(ind)". This
is a bit needlessly ugly, so print "NaN" on all platforms
consistently.

This fixes a test failure on MSVC.

(cherry picked from commit dd17f24c04)
2019-04-08 16:29:24 +01:00
John Beard fd698653d9 QA: numeric evaluator: add a context to tests
This allows a failing test to report which case failed more clearly.

Add a quick helper to make an "in -> out" context string.

(cherry picked from commit 3f32dc9a64)
2019-04-08 15:58:59 +01:00
John Beard b2e54a432b QA: Use own unit test headers for eagle test
These include the appropriate "polyfills" for things like
Boost versions.

(cherry picked from commit 20d36c18350fcccb1bee835553a68da8a0c96b0b)
2019-04-02 23:31:33 +01:00
John Beard e766732020 QA: Eagle test: look up test data in the source tree
Also provide a utility function to get this path, and
a way to override at run time to quickly sub in alternative
data.

The test itself is still broken, as this plugin won't accept
a call to Load() without a KiWay.

(cherry picked from commit 88faac309f)
2019-04-02 19:08:26 +01:00
John Beard 3a5e01c44a QA: Enable eeschema tests
Redesignate the eagle test as eeschema tests and build
more like the other unit tests.

Enable as a test in Ctest now that the test executes without
crashing.

The loading of the file with the hardocded part is still
not enabled, as this needs more infrastructure to support it.

(cherry picked from commit 4eb30f6b85)
2019-04-02 19:08:26 +01:00
Michael Kavanagh 9ad352d4bd Fix 'hokey' -> 'hotkey' typo
(cherry picked from commit fe6bc411dd)
2019-04-02 13:17:18 -04:00
John Beard 0655280f2c QA: nullptr_t -> std::nullptr_t
This fixes a build failure on some systems.

(cherry picked from commit 49d75e2383)
2019-03-29 12:49:16 +00:00
John Beard 2793578dcb QA: Allow BOOST_CHECKing of nullptr_t
Before Boost 1.64, there was no test logging function
for std::nullptr_t.

Add a logging struct to Boost to deal with this, and some
macros to assist in similar cases. These macros are bit
untidy-looking, but due to GCC bug #56480, we can't use
namespace aliasing to solve this. From Boost 1.64 onwards,
these namespaces are not needed at all.

Remove some code added to work around lack of nullptr printing
in the past.

These macros, and the nullptr printer, can be removed when
the Boost min version is 1.64 or greater.

(cherry picked from commit ad76ebd82a)
2019-03-29 10:11:19 +00:00
Wayne Stambaugh 8d26b07f67 Fix potential string iterator issue.
Added checks to StrCmpNum() function in common/sting.cpp to prevent
iterating past the end of the sting.  Also removed length of string
parameter since it did not seem to be used anywhere.

Fixes lp:1818157

https://bugs.launchpad.net/kicad/+bug/1818157
2019-03-02 08:20:53 -05:00
Seth Hillbrand 16b3c80a7c qa: Add StrNumCmp test 2019-03-01 11:22:35 -08:00
John Beard 346f813814 QA: Add WX_FILENAME split tests
Add some tests of the filename splitting of WX_FILENAME objects.

Interestingly, the result of GetFuillPath on an empty path is
likely wrong as it will imply an absolute path from /. But this is
probably not a used code path. Document the current behaviour as passing
the test.

This unit tests covers the code reported by Coverity 183884 and 183894
(improper use of negative). The find_last_of can return "npos" (-1), but
it's stored as a size_t. This is correct according the WX docs,
and the substr() method it is passed to can handle npos too.
2019-02-25 12:43:31 +00:00
John Beard 3fe8214d20 QA: Comment unused var in test_gal_pixel_alignment
p4 is not used (the code that uses it is commented out). So
also comment it out to keep the compiler quiet.
2019-02-18 17:06:48 +00:00
jean-pierre charras 3b97961ccb minor fixes (Coverity warnings and compil warning) 2019-02-17 15:33:20 +01:00
Tomasz Włostowski bbee30671a gal: pixel alignment hacks, works for Retina display too now.
gal: pixel alignment for Cairo.
gal: pixel alignment for OpenGL

Cleanup of pixel alignment patches

gal/opengl: more pixel alignment patches:
- works on Retina displays now
- pixel alignment for circles
- correct 1-pixel strokes
- fixed unfinished 1-pixel line ends

GAL: Restore antialiasing options in Cairo
GAL: Fix arc drawing

Removes DrawArcSegment, which drew arcs whose edge was optionally
stroked (a feature that we did not use).  Fixes Cairo arc drawing issue
where arcs were not visible in pcbnew.

gal: further cleanup
gal: removed unused shader parameter
2019-02-16 20:03:13 +01:00
Seth Hillbrand 7b3ef1b7ed colors: Add HSL conversion and tune colors
When adding colors to length tuner, we depend on the window background
color, which can be set by the user, resulting in an unreadable text.
This uses the HSL conversion to detect which shade it should use for the
coloring.

Also adds test cases for round-trip HSL and HSV conversion

Fixes: lp:1814530
* https://bugs.launchpad.net/kicad/+bug/1814530
2019-02-11 22:08:41 -08:00
John Beard edc73de023 Pcbnew: ignore start values in "first available" grid numbering
The using the "first available" numbering option, force an
artifical linear numbering scheme starting at '1'.

Start the pad name provider at the 0'th pad index.

Also adds a few related tests and adjusts tests affected by
this change to reflect that the offset still applies.

This can be expanded in future to be more general by skipping
pad (which would allow a custom start and numbering scheme
while still avoiding duplication), but for now,
this does what the UI says and avoids string changes in 5.1rc.

Fixes: lp:1814918
* https://bugs.launchpad.net/kicad/+bug/1814918

Fixes: lp:1814917
* https://bugs.launchpad.net/kicad/+bug/1814917
2019-02-08 12:15:02 +00:00
jean-pierre charras 507229809c Fix a compil issue in test_lib_table.cpp, with some boost versions. 2019-02-06 09:18:57 +01:00
John Beard 0c6ec7dbb3 LIB_TABLE_BASE: Const and unsigned fixes
* Make LIB_TABLE_BASE::GetCount() return unsigned. This is more
  consistent with the behaviour of STL containers (especially the
  boost::ptr_vector this is really accessing). Sadly
  wxGridTableBase() forces an int, so a cast is still required
  at the WX interface.
* Make LIB_TABLE_BASE::At() return a reference. First, this is more
  consistent with normal STL indexing operator[]'s, and secondly, it
  allows an idiomatic const index method (so you can access const
  LIB_TABLE_ROWs from a const LIB_TABLE_BASE).

The motivation is to allow use of this class and LIB_TABLE_ROW
in a test program, where the LIB_TABLE_BASE is const.
2019-02-05 08:49:52 -08:00
John Beard 84d79ec10d QA: LIB_TABLE tests
Some basic tests on LIB_TABLE and LIB_TABLE_ROW that demonstrate
the behaviour of fallbacks and various access methods.

Also add a few LIB_TABLE_BASE comments and changed some NULLs to
nullptr.
2019-02-04 19:44:54 -08:00
John Beard e6a6266f3d Build: libpolygon provides its own includes
Libpolygon can provide its own includes via target_include_dirs PUBLIC.
This means any linking targets do not need to specifiy them manually.

As common requires polygon, the polygon dep is also now no longer
required downstream of libcommon, as it's transisitvely implied
by libcommon's target_link_libraries.

This resolves a circular dependency previously detected and also
simplifies CMakeLists.
2019-02-04 19:29:31 -08:00
John Beard bb2ae8e13b Bitmaps: move bitmap defs to bitmaps library
The bitmap definitions (BITMAP_DEF and so on) do not
have any dependencies on other libs, including WX. This
means the bitmaps library can be isolated from the other
dependencies.

Common now depends on bitmaps, and libraries that depend
on common can pick it up from the common target_link_libraries,
as it is PUBLIC. This means a lot of targets no longer
need manual bitmap linkage.

This avoids a circular dependency that was previously reported
by static analysis.

Avoiding pulling in WX and other headers into the include
tree of each bitmap .cpp is a huge speed up (around 10x) in
compilation, and the generated static library is also 10x
smaller (20MB vs 200MB)

Add common as a link library to pnsrouter,connectivity.
THese library do still use common code (including bitmaps,
via base_screen.h) and this allows them to pick up the libcommon
includes correctly.
2019-02-04 19:29:31 -08:00
John Beard bb4d3faad7 QA: Add Distance, Collide, Collinear tests on SEG
SEG collisions and distances are a fundamental part of SHAPE collision testing
and are therefore critical for DRC correctness.

Also a few Collinear tests.
2019-02-03 06:57:37 +01:00
John Beard 0415c89c5b Fix broken GetReferencePrefix function
This function was incorrectly processing refdeses like "U1000".

Change the algorithm to a simpler STL-compatible one and
update the tests.

Fixes: lp:1813669
* https://bugs.launchpad.net/kicad/+bug/1813669
2019-01-30 15:41:36 -08:00
John Beard 88f9f6f072 Break out ref-des-centric functions to own header
This breaks the following functions out to a general-purposed refdes utils
header:

* MODULE::GetReferencePrefix()
* kicad_string.h RefDesStringCompare()

This acheives:

* Slimming of MODULE interface
* Placement of refdes code in common rather than pcbnew
** Testing of this code in qa_common
* Tighter and smaller includes for code that only needed refdes functions

Note: there are failing tests commited (as expected failures). These
are the cause of lp:1813669 and will be fixed as a follow-up commit.
2019-01-30 15:41:36 -08:00
John Beard dc20521cb9 Break out getTrailingInt from MODULE
This is not logic specific to MODULE. Breaking it out to
kicad_string.h acheives:

* Slimming of the MODULE interface
* Enables reuse of the function
* Enables testing of the function

Also add a test under qa_common for this function.
2019-01-30 15:41:36 -08:00
John Beard 453a91f661 Pcbnew: arrays skip existing names
The current module cannot be queried for existing pads as we
add them (because we never commit, until we finish the whole array).

Instead, pre-gather the names and check as we add, skipping any existing
names.

Note: this will not prevent arrays becoming "mis-ordered", but there
is not a lot we can do to prevent all possible errors.

Fixes: 1808706
* https://bugs.launchpad.net/kicad/+bug/1808706

The same principle could be used to skip existing ref-des'es on PCBs.
2019-01-30 15:41:35 -08:00
John Beard 5504981d00 Separate ARRAY_OPTIONS to own class in common
The geometry and numbering logic is separate to the dialog, and
can be separated for clearer logic and better testability.

Moreover, refactor it to avoid any dependency on pcbnew
classes, so it can be move to common for potential re-use in
eeschema and friends in future.

Also convert all wxPoint logic in these classes to VECTOR2I and
fix some function visibilities.

Add some unit tests of the ARRAY_OPTIONS geometry and numbering.
2019-01-30 15:41:35 -08:00
Jeff Young ca0164aa07 Unify library browser terminology.
Fixes: lp:1813882
* https://bugs.launchpad.net/kicad/+bug/1813882
2019-01-30 19:52:15 +00:00
John Beard 9a41fd060b QA: Account for eeschema tests unit rounding 2019-01-30 11:55:11 +01:00
John Beard 8e75f6029c QA: Mark failing SHAPE_POLY_SET tests as expected failures
This allows the tests to remain sensitive to other errors.

When SHAPE_POLY_SET is fixed, these expected failures should be
removed.
2019-01-30 11:55:10 +01:00
John Beard 33bc74a4a2 QA: Tidy qa_utils headers
Move into own include directory for clarity. Also allows qa_utils
to use its own private headers in qa/qa_utils without exposing them
through the target_include_directories directive.
2019-01-29 18:16:00 -05:00
John Beard 47ec2fd5ba QA: Add some tests on SHAPE_POLY_SET::Distance
These tests pick up the bug fixed in: 90178eb681
(as it is already fixed there is no failure).
2019-01-29 18:12:06 -05:00
John Beard 55fcbddde8 QA: Fix faulty test of SHAPE_POLY_SET Collision
This test assumed points on a edge are counted as colliding.
This is not true: points on an edge are NOT counted at inside
the poly_set.

THe test does still consider points on a *hole* edge as collisions.
The API to SHAPE_POLY_SET is unclear on if this is correct.
2019-01-29 18:06:16 -05:00
John Beard 9bd7ea815c QA: Centralise BOARD reading functions in pcbnew_utils
Several pcbnew_tools utilities read a file from the command line.
Instead of replicating this code, centralise the code in
qa_pcbnew_utils, which allows simpler reuse.

THe utilities are:

* polygon_triangulation
* polygon_generator
* drc_tool

pcb_parser keeps its own function, as that is the focus of the tool,
and its likely to have its own instrumention.

This also adds the ability to read from stdin for the above tools,
which means fuzz testers could theoretically work with them, and it
also can make life easier if you can pipe a board to the executable
directly.
2019-01-29 08:16:02 -05:00
John Beard adddc41bc5 QA: Reinstate polygon_triangulation utility
This utility has been disabled since the eeschema GAL merge. It
can be reinstated as part of the qa_pcbnew_tools framework.
2019-01-29 08:15:51 -05:00
John Beard 11745f8f44 QA: Move contents qa_shape_poly_set_refactor to qa_common
The "refactor" element of qa_shape_poly_set_refactor has been
previously removed, so these tests are now just regular tests on
libcommon classes. These can therefore be moved to qa_common
and the qa_shape_poly_set_refactor unit test suit can finally be
totally removed.
2019-01-29 08:15:44 -05:00
John Beard e4b4230bcf QA: Put UTILITY_PROGRAM in KI_TEST
Also expand some documentation of some other KI_TEST functions.
2019-01-29 08:15:37 -05:00
John Beard b690658972 QA: Add coroutine unit test
This adds a simple unit test to qa_common to check coroutines
produce expected events in the right order.

This is an automated analogue to the user-facing tool in
qa/common_tools.
2019-01-24 13:01:44 -05:00
John Beard 6729842441 QA: Reinstate polygon_generator as a sub-util of qa_pcbnew_tools
This program has been disabled for some time, but it's not
broken (even if the CMake was!).

Merging into the pcbnew_tools QA program reduces the CMake burden
and puts this tool in the same place as the others.
2019-01-24 13:01:44 -05:00
jean-pierre charras ebdc383cc3 QA test: add missing boost library (boost system).
This missing lib created link issues on some systems.
2019-01-24 09:03:58 +01:00
John Beard e8afb14046 QA: Move PCB parse util to combined tools exec
This means all the current Pcbnew utilities are all in a single
executable.

The tool is now run by:

$ qa/pcbnew_tools/qa_pcbnew_tools pcb_parser <same arguments as before>
2019-01-23 13:27:52 -05:00
John Beard d7563c55c4 QA: Pcbnew utility tools: DRC tool
Add a tool that allows a user to run DRC functions
on a given KiCad PCB file.

The first available functions are the courtyard functions.

Also move most of the utility program logic into qa_util for
better reusability.
2019-01-23 13:27:52 -05:00
John Beard 8297ab24e4 DRC: Break out courtyard overlap function
Introduce the concept of a DRC_PROVIDER which allows
to separate the various DRC functions to their own
areas. This allows, amongst other things, a slimmer core
DRC class, and allows DRC functions to be separately testable.

The courtyard DRCs (overlap, missing and malformed)
are the first victims, so instrumentation can be added to this function.

Add some unit tests on this DRC function, as well a few re-usable PCB-based
utility functions in a library (qa_pcbnew_utils) that could be shared between
unit tests and other utilities.
2019-01-23 13:27:52 -05:00