Comments (3)
Damn right, the docs are unfortunately out of date. Let me whip up an update during today's flight. Thanks for your patience!
from clar.
So, while @vmg is writing, some quick tips:
- Make a test folder in your project
- Copy
clar.c
,clar.h
, and theclar/
folder into the root of the test
folder. I suspect you could also figure out a way to use submodules for
this, but we generally don't. - Write a
main.c
for your test application. You can use
https://github.com/vmg/clar/blob/master/test/main.c as a starting point
and add in any special initialization and/or teardown that you need.
You can see an example of this in a "real world" project at
https://github.com/libgit2/libgit2/blob/development/tests-clar/main.c - Actually writing tests is still pretty much as documented in the
README. You create files with your tests organized however you like using
the clar naming conventions as documented. Again, you can look at
https://github.com/vmg/clar/blob/master/test/sample.c for an example. The
test functions are namedtest_<path_with_underscores>__<testname>
. So,
if you make a folder named "basics" and a file named "strings.c", the
tests in that file would bevoid test_basics_strings__mytest(void) {}
.
You can also use the "magic" functionstest_basics_strings__initialize
which will be called before each test andtest_basics_strings__cleanup
which will be called after each test. - Set up your build. Clar doesn't mandate a particular build system, but
before compilation you should runpython generate.py .
from the test
folder that you made in step one. That will generate theclar.suite
file which will be included byclar.c
. Your Makefile / whatever-you-use
should include the library you are testing, plus clar.c, all of the .c
files in the clar/ folder, and all of your test files, and should build a
command line executable. Again, you can see a pretty rudimentary version
of all this in https://github.com/vmg/clar/blob/master/test/Makefile - If you need mutable test data, you will probably want to use clar
fixtures. For that, you will need to defineCLAR_FIXTURE_PATH
when you
build the library to be the full path to the root of the test data
area. If you define that during the build, you will be able to use
cl_fixture_sandbox()
andcl_fixture_cleanup()
to clone the test data
for each test and to clean it up after. You can also usecl_fixture
just to get a path to the test data if you don't need to clone it. If you
are not using mutable test data that needs to be sandboxed for each test,
then this may not be important to you.
Anyhow, hopefully that helps (and hopefully I didn't forget any steps).
from clar.
Damn right, the docs are unfortunately out of date. Let me whip up an update during today's flight. Thanks for your patience!
Thanks for all the hard work. Looking forward to using clar. 😄
So, while @vmg is writing, some quick tips:
Awesome. This is exactly what I was looking for. 👍
from clar.
Related Issues (12)
- clay.py is not executable HOT 2
- clar didn't support for python3
- clar didn't support for python3 HOT 7
- Selecting a suite should look in all categories HOT 2
- Tap protocol output HOT 1
- Feature request: reporting (e.g. jUnit xml) HOT 2
- Idea on output HOT 2
- Print back trace upon failure HOT 2
- Run preprocessor before processing test declarations
- Specifier for a precise match using `-s`
- Request for slightly more portability - specifically c99 or c11 support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clar.