in reply to Unit testing OS rich code
`touch $to_base.FLG`;Are you really running the external touch command via backticks without checking for errors? Eeww. IMHO, Perl internal functions should generally be preferred to running external commands; they tend to be faster, more portable, more secure, and more robust with better error diagnostics. To mimic the touch command in Perl is not difficult. If the file already exists, you could simply use:
Or you might employ the CPAN File::Touch module.my $now = time(); utime($now, $now, $file);
As for testing this sort of stuff, I don't usually mock at all, just have the test setup create a new empty scratch directory, populate it with known content, test against that, and have the test teardown remove the scratch directory. Oh, and do it all in Perl, not running external commands. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unit testing OS rich code
by Voronich (Hermit) on Oct 13, 2011 at 13:18 UTC | |
by BrowserUk (Patriarch) on Oct 13, 2011 at 13:34 UTC | |
by Voronich (Hermit) on Oct 13, 2011 at 14:00 UTC | |
by eyepopslikeamosquito (Archbishop) on Oct 17, 2011 at 01:59 UTC | |
by chromatic (Archbishop) on Oct 17, 2011 at 04:26 UTC | |
by Voronich (Hermit) on Oct 17, 2011 at 03:06 UTC |