[programs/robocopy.exe] How to do unit test correctly?

Zebediah Figura (she/her) zfigura at codeweavers.com
Sat Jun 26 10:52:37 CDT 2021


Hello Weiwen,

On 6/26/21 6:38 AM, Weiwen Chen wrote:
> Hi everyone:
> I'm Weiwen Chen from Fudan University and I'm working on adding
> `robocopy.exe` into wine. I stage my work on my github fork
> <https://github.com/ofey404/wine/tree/robocopy>.
> 
> This program accepts complex command line arguments, so I'm trying to
> implement my own `getopt` function which accepts dos-style flags(beginning
> with slash, like `/x`).

Well, you could, but it may be easier to copy the structure from a 
different program, e.g. programs/ping/ping_main.c.

> The dummy code is under programs/robocopy
> <https://github.com/ofey404/wine/tree/robocopy/programs/robocopy>
> directory. And I want to add some unittest of `getopt_long()`, in
> robocopy/tests/getopt.c
> <https://github.com/ofey404/wine/blob/fe4a71850b023eefadab5ce357ce4671c1fffc72/programs/robocopy/tests/getopt.c#L21>.
> I try to import my source code of `getopt.c` relatively into unit test
> file, but I failed with error message like this:
> 
> ../wine-git/programs/robocopy/tests/getopt.c:20: error: #include directive
> with relative path not allowed
> 
> How can I include my source file correctly into the test? Maybe I should
> configure something in the `configure` script, but I don't know how to do
> it.
> 
> I've read some of the builtin programs, but they seldom have a separate
> `test/` directory, and I don't find examples of unit tests.

We don't really do unit tests of internal functions at all. Maybe 
there's an argument for it, but I suspect in this case at least it's not 
really necessary.



More information about the wine-devel mailing list