Unit-testing client code

1 view
Skip to first unread message

Nicolas Alvarez

unread,
Jan 16, 2010, 5:43:13 PM1/16/10
to synecdo...@googlegroups.com
Before touching the config file code, I'd like to add unit tests. Which
probably mean refactoring the existing code a bit to be "testable".

But there is a problem with linking. I can't write a unit test program and
link it to log_flags.C alone, because it uses the global CLIENT_STATE gstate
variable, so I need to link client_state.C too. Once I do that, I get a
zillion undefined references, and to solve them I end up bringing in 90% of
the core client code.

What do you think about putting all of the core client code except main.C in
a static library, and synecd having main.C and linking the static library?
This way I can have the unit test link to the same static library, and it
could test most of it.

--
Nicolas

(I read mailing lists through Gmane. Please don't Cc me on replies; it makes
me get one message on my newsreader and another on email.)

Nicolas Alvarez

unread,
Apr 12, 2010, 8:24:10 PM4/12/10
to synecdo...@googlegroups.com
Nicolas Alvarez wrote:
> Before touching the config file code, I'd like to add unit tests. Which
> probably mean refactoring the existing code a bit to be "testable".
>
> But there is a problem with linking. I can't write a unit test program and
> link it to log_flags.C alone, because it uses the global CLIENT_STATE
> gstate variable, so I need to link client_state.C too. Once I do that, I
> get a zillion undefined references, and to solve them I end up bringing in
> 90% of the core client code.
>
> What do you think about putting all of the core client code except main.C
> in a static library, and synecd having main.C and linking the static
> library? This way I can have the unit test link to the same static
> library, and it could test most of it.

On absence of comments, I have done this in r1339 (split client into library
and app with main()).

However, I haven't added the actual unit tests yet.

Reply all
Reply to author
Forward
0 new messages