in reply to Re: Artificial System Clock
in thread Artificial System Clock

Thanks for your reply. I took a look at these two modules:

Time:Mock

I read both:

http://search.cpan.org/dist/Time-Mock/lib/Time/Mock.pm

and:

http://search.cpan.org/~ewilhelm/Time-Mock-v0.0.1/lib/Time/Mock.pm#Class_Methods

about this, and although I certainly don't understand most of what is described there, it sounds like it does something different. Namely that it allows you to speed-up or slow-down the system clock, and there appears to be something about alarms in there. It looks like there are issues with child processes and forking too, although they may have corrected that by now (?)

Time::MockTime

I was unable to find anything about this with a quick Google search. Can you please point me to something that gives an overview of it? (Sorry for my new-ness!)

* * *

An Artificial System Clock does something different: it provides you the ability to trick your system into thinking it is a different date-time. Once implemented, you can instantly move the application forward or backward to a date, run some tests to verify that the system does what it's supposed to in that date-time context, and then instantly move the application to a different date-time, verify more application behavior, etc.

The value the TimeChannels service provides is that it keeps the date-time setting in one, shared ("published") location, where multiple parties can subscribe to it. Especially in building a system that interfaces other systems, if all the interfacing systems have implemented the ASC, and are all subscribing to the same ASC channel, then the testers can coordinate date-time jumps by simply changing the ASC value in one location (i.e., TimeChannels.com), and all the interfacing systems suddenly reflect the new date-time.

* * *

I am very interested in your first statement, though, about replacing the globals. Can you please elaborate on that? Do you mean to replace the contents of existing perl library functions like time, localtime, etc.?

Thanks,

John

Replies are listed 'Best First'.
Re^3: Artificial System Clock
by JavaFan (Canon) on Nov 11, 2008 at 14:41 UTC
    Have you read http://search.cpan.org/~ddick/Test-MockTime-0.09/lib/Test/MockTime.pod?

    From its description:

    This module was created to enable test suites to test code at specific points in time. Specifically it overrides localtime, gmtime and time at compile time and then relies on the user supplying a mock time via set_relative_time, set_absolute_time or set_fixed_time to alter future calls to gmtime,time or localtime.
    You also asked:
    I am very interested in your first statement, though, about replacing the globals. Can you please elaborate on that? Do you mean to replace the contents of existing perl library functions like time, localtime, etc.?
    Yes, except time, localtime, etc aren't library functions, but core functions. The source to Time::MockTime gives an example of how to do it:
    BEGIN { *CORE::GLOBAL::time = \&Test::MockTime::time; *CORE::GLOBAL::localtime = \&Test::MockTime::localtime; *CORE::GLOBAL::gmtime = \&Test::MockTime::gmtime; }