Closed madebr closed 2 months ago
I am a little lost about how to produce these diagnostics. What I generally do is :
src> cake ../tests/unit-tests/*.c -test-mode
215 files in 0.27 seconds
9 errors 16 warnings 0 notes
10 tests of 215 failed
This run cake in all files in "test mode". 10 tests are failing (under development)
There is also -DTEST that compile cake in test mode runs 63 test functions. Most of it is preprocessor test.
cl -DTEST build.c && build
0 tests failed, 63 tests passed
0 expected to fail - waiting fixes
What is missing is running cake ../tests/unit-tests/*.c -test-mode
inside build.c.
There is also other samples that could be used in automatic test.
What -test-mode does is to pass test if we have 0 warnings 0 erros.
Sample:
#pragma safety enable
struct X {
int i;
};
void f(struct X* _Opt p)
{
int i = p ? p->i : 0; //no warning
int i3 = p->i;
#pragma cake diagnostic check "-Wanalyzer-null-dereference"
int i2 = p ? 0 : p->i; //warning
#pragma cake diagnostic check "-Wanalyzer-null-dereference"
}
pragma is used to dismiss the error/warning and check we have that error/warning.
#pragma cake diagnostic check "error or warning"
I misunderstood the -DTEST
option. I now understand that it can be used to build a unittest executable (let's call it cake-unittest).
So running a bare "cake-unittest" succeeds, but "cake" fails to parse certain sources (including SDL). https://github.com/madebr/cake/actions/runs/9943271740/job/27466699049
Did you add test files on CI? What I can do is separate in a folder the testes that are currently failing. I would like to integrate this.
tests\unit-tests <-- should work 100%, checked at CI
tests\unit-tests\failing <-- failing tests (TODO)
The directory
\tests\en-cpp-reference-c
\tests\sqlite
has a lot of source but not prepared to run in test mode.
I do a glob in tests/unit-tests
and assumed they should all succeed.
Separating them in ok/failing would be usable.
https://github.com/madebr/cake/actions/runs/9945512803 As a heuristic, if the directory ends on fail, it will expect the test to fail.
ctest expects the return code to be non-zero for a failing test.
I changed the meaning of -DTEST. Now DTEST is the same exe. The difference is function tests are included and they are called before any other execution. The object was to avoid to create two Exes. Now the same exe executes the tests and also compiler cake own source.
CI is not working with cake compiled with x64. But in my machine , with sanitizer etc..it works normally. then I changed to x86 and it worked.
something you must be aware is that cakeconfig.h is always the cakeconfig.h that is at same path of executable. I want to change that to search first the same path of each file.
cake folder
| cake.exe
| cakeconfig.h
mycode
| cakeconfig.h
| source.c
I thought the return code was fixed. At main()
if (report.test_mode)
{
return report.test_failed ? EXIT_FAILURE : EXIT_SUCCESS;
}
return report.error_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
I also found some weird behavior with pointer to "report". Maybe I need to refactory that. There this "global report" and "local report" for each file.
Windows x64 is failing but not on my machine. This is also weird.
About the includes, we list on GCC. But maybe we need to add some flag to x64 before? See -autoconfig / generate_config_file
Maybe this command line needs to be changed x86 x64
char* command = "echo | gcc -v -E - 2>&1";
by the way "en-cpp-reference-c" directory is not prepared for test-mode.. They are just files.. the ones that should compile without errors/warning will pass the test.
Also some samples are linux only.
About the includes, we list on GCC. But maybe we need to add some flag to x64 before? See -autoconfig / generate_config_file
Maybe this command line needs to be changed x86 x64
char* command = "echo | gcc -v -E - 2>&1";
I know some distros have separate include directories for different architectures (i686 vs x86_64).
Mine doesn't, but I think Ubuntu does. So the command should be CC
and CFLAGS
dependent.
by the way "en-cpp-reference-c" directory is not prepared for test-mode.. They are just files.. the ones that should compile without errors/warning will pass the test.
Also some samples are linux only.
Good to know. I think not-yet-implemented functionality should move to a failing
-like folder as well.
In the same spirit, the *nix-only samples should move to a nix-like folder.
For some reason, running cake on the cake sources times out. This only happens on Windows.
I ported the cakeconfig.h
generation to cmake, and I see a little difference between 32-bit vs 64-bit.
32-bit:
/*
* This file was generated reading the ouput of
*
* echo | /usr/bin/gcc -m32 -v -E - 2>&1
*
*/
#pragma dir "/usr/lib/gcc/x86_64-linux-gnu/11/include"
#pragma dir "/usr/local/include"
#pragma dir "/usr/include"
64-bit:
/*
* This file was generated reading the ouput of
*
* echo | /usr/bin/gcc -m64 -v -E - 2>&1
*
*/
#pragma dir "/usr/lib/gcc/x86_64-linux-gnu/11/include"
#pragma dir "/usr/local/include"
#pragma dir "/usr/include/x86_64-linux-gnu"
#pragma dir "/usr/include"
All tests in /tests/unit-test and /tests/en-cpp-reference-c/ are passing. The ones are not passing are inside failing. They are not necessarily error but need some work to move them.
Preprocessor errors where not reported to the pass test.. now they are.
(I added CMake project generation to
build.c
. Let me know if you are interested. ci)