Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Postconditions

Ian Wehrman edited this page Jun 12, 2015 · 1 revision

You'll now see new logging messages in the console that describe the automatic postcondition verification. For example:

Enqueuing action documents.selectNextDocument; 0/0
Executing action documents.selectNextDocument after waiting 0ms; 1/0
Verifying 1 postcondition for sub-action documents.selectDocument of action documents.selectNextDocument
Verified 2 postcondition for sub-action documents.selectDocument of action documents.selectNextDocument in 60ms
Finished action documents.selectNextDocument in 373ms with RTT 373ms; 1/0

Philosophical note: We could imagine defining a very heavy verification condition which builds a fresh model from PS state after every action and checks it against the current document model. I think that would be going way too far. Instead, I advocate declaring verification conditions just for actions that change PS state, and for defining narrow, simple, re-usable verification conditions.

Practical note: Postconditions are verified after executing actions and after sub-actions (via transfer), so it makes sense to declare these verification conditions as close to the Photoshop-state-changing action as possible. For example, in the PR below I've added the condition _verifyActiveDocument to the action documents.selectDocument but not to document.selectNextDocument, since the latter just transfers to the former, and hence will already be verified. In the case of Photoshop events, the verification conditions should be declared for the actions that the event handler calls, as in the case of layers.addLayer.

Early positive results: After implementing this, I quickly found two bugs as a result of postcondition verification failure: #1437 and #1443. The former results in output like the following:

Enqueuing action layers.ungroupSelected; 0/0
Executing action layers.ungroupSelected after waiting 0ms; 1/0
Verifying 2 postconditions for action layers.ungroupSelected
Verification of postcondition 1 failed for action layers.ungroupSelected
Action layers.ungroupSelected failed: Error: Incorrect selected layer count: 0 instead of 2
    at _verifyLayerSelection (file:///Users/ian/Desktop/photoshop-Release_x86_64/Plug-Ins/Spaces/www/src/js/actions/layers.js:244:27)
From previous event:
    at _verifyLayerSelection (file:///Users/ian/Desktop/photoshop-Release_x86_64/Plug-Ins/Spaces/www/src/js/actions/layers.js:238:14)
    at null.<anonymous> (file:///Users/ian/Desktop/photoshop-Release_x86_64/Plug-Ins/Spaces/www/src/js/fluxcontroller.js:291:41)
    at Array.map (native)
    at null.<anonymous> (file:///Users/ian/Desktop/photoshop-Release_x86_64/Plug-Ins/Spaces/www/src/js/fluxcontroller.js:290:45)

Future note: Other good opportunities for verification conditions might be layer bounds, window transforms, history states, tools, modal states, and keyboard policies.

Clone this wiki locally