-
Notifications
You must be signed in to change notification settings - Fork 35
Stateful comments, and clock
, freeze
commands
#324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: hkmc2
Are you sure you want to change the base?
Conversation
val timingId = runtimeClock.get.flatMap(s => if s == "" then N else S(s)) | ||
val startTime = timingId.map(_ => System.nanoTime()) | ||
|
||
mkQuery(preStr, jsStr): stdout => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right thing to time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just do the timing in node.js? Add a module with a time
function that prints the elabsed time:
time of () =>
foo(123)
> 456ms
= 42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would probably make more sense, and this could be frozen. at the moment, I'm not sure if stateful comments are particularly useful for anything other than freeze
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would suggest only using freeze
instead.
Thanks for the proposal! As discussed in the meeting, the ideal feature would freeze the rest of the file atfer the let config = 123
//│ config = 123
:freeze
====================================================================================================
print(config)
//│ > 123 Furthermore, the non-printed output would still be checked, and the difftest would fail if there is a change there. This does mean that in the example above, changing |
By the way, this
is not quite true. Difftests are run only once (by the corresponding test command). But if you run individual tests through the watcher, it's just that the watcher keeps detecting a change and re-running the file. The emergent fixed point behavior is an artifact of the watcher :^) |
Ah good point, have clarified. |
Difftests run with the watcher, are run until the file reach a fixpoint, which is expected to happen after 2 runs (the first run updates the file, which triggers a re-run which doesn't change the file). However, if a program has non-deterministic output, a fixpoint is almost never reached and difftests are continuously run as the watcher continuously triggers a run.
To avoid this, output that is expected to be non-determistic can be written with a stateful comment (starting with
//+
), which is passed as input to subsequent runs. This allows commands to force idempotence subject to conditions, based on the previous run's output. For example, with a command like:clock test
or:freeze test
, stateful comments starting withruntime clock time (test)
orfreeze (test)
are re-output without change.Some issues:
freeze
freezes output, the term is still executed, since subsequent blocks in the difftest may depend on it. This could lead to confusing behaviour in which the frozen output doesn't change, but the behaviour of subsequent code does.clock
is very annoying, since all the identifiers need to be changed. Might be helped by introducing dependencies in which a block is re-run if one of it's dependencies is changed.