Commit Graph

163 Commits

Author SHA1 Message Date
James Raphael Tiovalen
b0bcdb56c1 Add support for randomizing test execution order
This commit reintroduces the option to shuffle the test execution order
into the test runner. This has been tested with the temp_sensor example
project in Ceedling. Unit tests have also been successfully executed.

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
2025-03-11 00:10:05 +08:00
Mark VanderVoord
1a29024cc7 It's a New Year 2025-01-01 11:46:30 -05:00
Mark VanderVoord
c546414657 - Protect against people not defining UNITY_USE_COMMAND)LINES_ARGS but enabling cmd_lines in test runner generator. (Cherry-pick PR 739)
- Fix UNITY_NORETURN usage (Cherry-pick PR 742)
- Other standards and formatting tweaks.
2024-08-01 16:01:09 -04:00
Mark VanderVoord
18fb33921f add strict match option as '-n' again.
fix style while I'm at it.
2024-06-12 22:59:08 -04:00
andre-lei
c3a3843f4c Merge branch 'ThrowTheSwitch:master' into dev/gen-testrunner-use-begin-end-macro 2024-03-20 16:00:13 -07:00
Mark VanderVoord
671f8d25f1 Update all the boilerplates 2024-03-16 23:15:00 -04:00
andre-lei
ef7f968331 Merge branch 'ThrowTheSwitch:master' into dev/gen-testrunner-use-begin-end-macro 2024-02-21 10:28:28 -08:00
Mark VanderVoord
64939db64e generate test runner: clean injected defines so the ifndef doesn't use the assignment when it exists. 2024-01-19 11:44:48 -05:00
Lei, Andre
3911b01d81 Update generate test runner to leverage custom UNITY_END() 2023-11-16 19:40:45 +00:00
Mark VanderVoord
3f7564ea3b Catch up on Ruby style and formatting changes. 2023-11-12 19:07:32 -05:00
Mark VanderVoord
bd32847abf Merge branch 'master' into platform_matrix 2023-11-08 00:16:40 -05:00
Mark VanderVoord
f9c4038341 Merge pull request #690 from ThrowTheSwitch/feature/updated-build-directives
Add/update build directives
2023-08-16 10:15:59 -04:00
Mike Karlesky
5109be3881 Missed renames of TEST_FILE() directive 2023-08-15 21:16:02 -04:00
Jon Hanghøj Henneberg
d593817630 Add TEST_MATIX option for parameterization
Added matrix option for parameterization that generates cases based on
the product of the given arguments.
2023-07-13 22:39:58 +02:00
Jon Hanghøj Henneberg
6a8e03b5a9 Fix filename sanitization with command line option
When enabling the command line option the file name added to the runner
did not escape the slashes on windows in the same way other paths where
sanitized. Copied the sanitization from the other filename uses.
2023-04-17 18:23:20 +02:00
Mark VanderVoord
a7639eeb54 Bump rubocop up to newer ruby versions (in progress) 2023-02-16 16:40:23 -05:00
Mark VanderVoord
5204c1bacf Merge pull request #550 from jannisbaudisch/fix_test_parameterization_regex
Improve regex for test parameterization to support function pointers
2023-02-06 15:31:49 -05:00
Mark VanderVoord
ae4ab78c47 Merge pull request #551 from pmembrey/add-meson-generator-for-test-runner
Enhance meson support so that it can automatically generate a test runner
2023-02-06 14:56:17 -05:00
Erik Flodin
563786f97c Add support for TEST_RANGE with exclusive end
If the range is <start, end, step> instead of [start, end, step], the
end value will not be included in the range.

This can be useful if you have a define that defines e.g. the size of
something and you want to use this define as the end value. As the
pre-processor doesn't evalutate expressions (unless you do some macro
magic) you can't specify the range as [0, MY_SIZE - 1, 1]. With this
change you can then instead give the range <0, MY_SIZE, 1>.
2022-10-14 18:51:45 +02:00
Erik Flodin
76b7e359cc Improve handling of space in TEST_CASE/RANGE
The fix in 285bb6e282 didn't completly fix the issue.
2022-10-13 22:13:03 +02:00
Mark VanderVoord
37b61d2be2 Merge pull request #555 from erijo/test-case-space
Ignore space around parameter in TEST_CASE()
2022-10-11 16:25:05 -04:00
Mark VanderVoord
de73f1fcbf Merge pull request #554 from erijo/single-test-range
Make TEST_RANGE handle a single range
2022-10-04 21:57:38 -04:00
Martyn Jago
5dd3aa40dc Fix call to ERB.new to avoid deprecation warnings.
On later Rubies calling create_run_test() causes the generation of warnings of the following form:

warning: Passing safe_level with the 2nd argument of ERB.new is deprecated...
warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated...

This patch removes the noise.
2022-05-28 12:35:22 +01:00
Martyn Jago
b44c2dd095 Fix broken YAML parsing on later Rubies with Psych >=4.0
YAML.load is now interpreted as YAML.safe_load, which breaks where the
YAML file contains aliases. If we can assume our yaml files are
trusted (since this a development tool), we can check for the presence
of YAML.unsafe_load and use it instead if it exists.
2022-05-27 15:08:11 +01:00
Erik Flodin
285bb6e282 Ignore space around parameter in TEST_CASE()
This makes it possible to use defines that expand to something that
includes space, e.g. TEST_CASE(true).
2021-12-03 17:35:51 +01:00
Erik Flodin
72ffe691cd Make TEST_RANGE handle a single range
Before this change a single range such as TEST_RANGE([5, 100, 5]) would
generate the following error:

undefined method `flatten' for 5:Integer (NoMethodError)

The problem is that reduce called on an array with a single element
returns that element which isn't an array of arrays as expected by the
following block.
2021-12-03 17:33:56 +01:00
Daniele Nardi
29617c7ecd Added -externcincludes option in order to build unit test executable in mixed C/C++ environment 2021-07-15 13:10:07 +02:00
Peter Membrey
31f5b47fc5 Add generator code to build file and make script executable 2021-04-04 01:54:43 +08:00
Jannis Baudisch
b51303a65b Improve regex for test parameterization to support function pointers
The regex to match function names for the test parameterization used the
wildcard '.*'. This lead to an error when you try to add a function
pointer as arguement.

The regex will now only match the word characters a-z A-Z 0-9 and
underscore (which are all characers that are accepted by the C standard)
2021-04-01 10:29:22 +02:00
Kin Numaru
63fef7dd10 Enlarge the TEST_RANGE() regex to accept more spaces
This commit change the regex to accept more spaces inside the brackets
of the TEST_RANGE().

I use clang-format through vscode "editor.formatOnSave": true feature and it produce
padding spaces inside the array brackets by default.

```c
int a[] = [1, 2];
```

is changed into

```c
int a[] = [ 1, 2 ];
```

Also, every time I save a file containing a TEST_RANGE() with ctrl + s,
it breaks it.
2021-02-12 20:39:05 +01:00
Fabian Weik
c3afe99a77 parse mock files correctly 2020-08-27 13:21:45 +02:00
Jakob Olesen
dcb30731f8 Fixed suiteTearDown not matching prototype
Fixed suiteTearDown to match prototype in unity.h
2020-05-04 20:34:45 +02:00
Gavriil Pascalau
ff479e9aa0 Fix small typo 2020-03-28 18:31:43 +01:00
mvandervoord
371e062555 Fixed issue #480 - better protection against bad pattern matching. 2020-03-17 16:24:25 -04:00
Mark VanderVoord
a67cb27dd4 Merge pull request #472 from jlindgren90/master
auto: Only create run_test() function if it's needed.
2020-03-17 15:35:47 -04:00
mvandervoord
3e4dfec147 Add support for alternate forms of header and source files to test runner generator. This borrows heavily from #477 (Thanks @Tuc-an) but maintains the ability to sort files that don't need to be relinked. 2020-03-17 14:02:54 -04:00
Andrei Korigodskii
218fa2cbe8 Add TEST_RANGE to specify arg ranges in parameterized tests
TEST_RANGE([start, stop, step]) generates following runs of the test
function: test(start), test(start + step), ..., test(start + n * step),
where start + n * step <= stop. The step must be positive.

If the test function takes several arguments, the following syntax must be used:
TEST_RANGE([arg1_start, arg1_stop, arg1_step], ..., [argN_start, argN_stop, argN_step])

This addresses issues #53 and #144.

Reported-by: Alex Rodriguez <alejmrm@gmail.com>
Reported-by: Hiroaki Yamazoe <PastelParasol@gmail.com>
2020-02-02 22:28:21 +03:00
John Lindgren
f39c856a37 auto: Only create run_test() function if it's needed.
Also fix some whitespace consistency issues.
Use 2 newlines (not 1 or 3) before /*====Heading====*/ comments.
2019-12-12 12:53:49 -05:00
mvandervoord
c5c36ab29f Do NOT include the default test runner if a custom runner has been defined.
Cleanup some style issues.
2019-12-05 13:19:43 -05:00
anon
a303e08859 Option to omit UnityBegin/UnityEnd calls in generate_test_runner
By passing --omit_begin_end=1 to generate_test_runner.rb, the script
will now omit calls to UnityBegin and UnityEnd when running tests in a
suite.

This allows multiple suites to be executed in a row, and then have an overall
summary of the tests which were executed across all suites.
2019-10-29 20:32:06 +00:00
John Lindgren
cf5b2d2568 Make verifyTest() leave Ignores and Callbacks intact. 2019-10-29 13:21:34 -04:00
mvandervoord
be87d790c7 Add verifyTest option to go with resetTest.
Fix docs.
2019-10-28 10:32:22 -04:00
mvandervoord
eb0bd42f0d Updated to newer coding standard 2019-10-24 15:33:41 -04:00
John Lindgren
277e844bed Convert RUN_TEST() to a function (generated from an ERB template).
Converting RUN_TEST() from a macro to a function significantly reduces the size
of the compiled binary.  On amd64, the largest test runner in the test suite
(testsample_DefaultsThroughCommandLine_runner.o) was reduced from 3.4 kB to 2.4
kB (stripped).
2019-10-22 15:18:20 -04:00
John Lindgren
d10cf6645d Remove unnecessary #includes. 2019-10-22 15:05:34 -04:00
John Lindgren
68cc45a918 Make sure setUp/tearDown are always defined. 2019-10-22 15:04:03 -04:00
Mark VanderVoord
5fc72fbca1 fix name of teardown function 2019-10-22 06:52:25 -04:00
Mark VanderVoord
ff697ad29c suite setup and teardown no longer static (simplifies test-supplied instance) 2019-10-22 06:45:47 -04:00
Mark VanderVoord
ac427b28fc Fixed backwards case. 2019-10-22 06:37:28 -04:00
Mark VanderVoord
2d8a69e0d1 update handling of when suite_setup/teardown in use 2019-10-22 06:27:26 -04:00