<div dir="ltr"><span style="color:rgb(61,133,198)">> Well, you could, but it may be easier to copy the structure from a <br></span><div><span style="color:rgb(61,133,198)">
different program, e.g. programs/ping/ping_main.c.</span><span class="gmail-im"><br></span></div><div><br></div><div>I considered this choice at first, and I read some of the command line parsing patterns from other files. But robocopy has covered almost all kinds of dos-style command line flags:</div><div>- flag with no argument, eg: /x</div><div>- colon separated argument, eg: /x:10</div><div>- space separated argument list, eg: /x arg1 arg2</div><div><br></div><div>The three types are all needed by Waves Central or Scoop.<br></div><div><br></div><div>I didn't find a program which has to deal with such complex parsing, and the complexity to write a structure to parse all three kinds of flags seems to be similar to implementing a dos-style `getopt`. Besides, `getopt` is something standard, and I can refer to lots of implementations. If a dos-style `getopt` is done, maybe it could help new programs or improve existing programs.</div><div><br></div><div>I think I could do my test of `getopt` somewhere else, and copy tested code to the wine project. `getopt` is not hard/complex, and there are standard implementations which are proved to be right.</div><div><br></div><div>Unittest of such a little program may be too cumbersome. ;)<br></div><div><br></div><div>Weiwen<br></div><div><span class="gmail-im"></span></div><div><span class="gmail-im"></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Zebediah Figura (she/her) <<a href="mailto:zfigura@codeweavers.com">zfigura@codeweavers.com</a>> 于2021年6月26日周六 下午11:52写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Weiwen,<br>
<br>
On 6/26/21 6:38 AM, Weiwen Chen wrote:<br>
> Hi everyone:<br>
> I'm Weiwen Chen from Fudan University and I'm working on adding<br>
> `robocopy.exe` into wine. I stage my work on my github fork<br>
> <<a href="https://github.com/ofey404/wine/tree/robocopy" rel="noreferrer" target="_blank">https://github.com/ofey404/wine/tree/robocopy</a>>.<br>
> <br>
> This program accepts complex command line arguments, so I'm trying to<br>
> implement my own `getopt` function which accepts dos-style flags(beginning<br>
> with slash, like `/x`).<br>
<br>
Well, you could, but it may be easier to copy the structure from a <br>
different program, e.g. programs/ping/ping_main.c.<br>
<br>
> The dummy code is under programs/robocopy<br>
> <<a href="https://github.com/ofey404/wine/tree/robocopy/programs/robocopy" rel="noreferrer" target="_blank">https://github.com/ofey404/wine/tree/robocopy/programs/robocopy</a>><br>
> directory. And I want to add some unittest of `getopt_long()`, in<br>
> robocopy/tests/getopt.c<br>
> <<a href="https://github.com/ofey404/wine/blob/fe4a71850b023eefadab5ce357ce4671c1fffc72/programs/robocopy/tests/getopt.c#L21" rel="noreferrer" target="_blank">https://github.com/ofey404/wine/blob/fe4a71850b023eefadab5ce357ce4671c1fffc72/programs/robocopy/tests/getopt.c#L21</a>>.<br>
> I try to import my source code of `getopt.c` relatively into unit test<br>
> file, but I failed with error message like this:<br>
> <br>
> ../wine-git/programs/robocopy/tests/getopt.c:20: error: #include directive<br>
> with relative path not allowed<br>
> <br>
> How can I include my source file correctly into the test? Maybe I should<br>
> configure something in the `configure` script, but I don't know how to do<br>
> it.<br>
> <br>
> I've read some of the builtin programs, but they seldom have a separate<br>
> `test/` directory, and I don't find examples of unit tests.<br>
<br>
We don't really do unit tests of internal functions at all. Maybe <br>
there's an argument for it, but I suspect in this case at least it's not <br>
really necessary.<br>
<br>
</blockquote></div>