lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Running unit tests in less time


From: Vadim Zeitlin
Subject: Re: [lmi] Running unit tests in less time
Date: Wed, 3 May 2017 03:20:04 +0200

On Tue, 2 May 2017 22:23:16 +0000 Greg Chicares <address@hidden> wrote:

[...snip already fixed -- thanks! -- issue discussion...]

GC> >  The cleanest/ideal fix would probably be to avoid creating temporary 
files
GC> > in the current directory and do it in (a subdirectory of) the system
GC> > temporary directory. Please let me know if you'd like me to implement this
GC> > instead of/in addition to the fix above.
GC> 
GC> Let's see...mktemp() has come to be considered unsafe since the last time I
GC> used it, which was probably in the 1980s. Now mkstemp() and mkdtemp() are
GC> recommended instead, but they're not standard C(++).

 I'm afraid they're still the best functions to use. It's a pity that they
have to be wrapped in some portable wrapper which would also handle MSW via
::GetTempFileName(), but it's not difficult to do (even though the code of
wxFileName::CreateTempFileName() doing this is not that nice, now that I
look at it...).

GC> However, tmpnam() is open to race conditions, so we'd probably be better off
GC> hardcoding unique names for each unit test's temporary files (instead of
GC> hardcoding non-unique names as at present). I think that's what I'll do.

 It's probably justified on the basis of not worrying about a problem which
is rather unlikely to arise, but I do feel uncomfortably about using hard
coded file names, even for (or maybe especially for) the temporary files.
If the small amount of extra work on wrapping mkstemp() can be justified,
I'd prefer to do it just because then there would be nothing to worry
about.

GC> Would it really be better to use TMPDIR? If we write temporary files in the
GC> current directory, then we can run i686 and x86_64 tests simultaneously (in
GC> different directories), without any possibility of collision between
GC> architectures.

 If the file names are hardcoded anyhow, using TMPDIR seems rather
pointless. But if they're not, then the problem of collision would never
arise and using TMPDIR would happen automatically anyhow.

 Regards,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]