laurent.orseau
2022-5-18 15:42:08

@robby There are some failing quickscript-test tests, probably due to race conditions: http://drdr.racket-lang.org/60618/cs/racket/share/pkgs/quickscript-test/drracket.rkt I need these steps to be done in a serial way: (queue-callback/res (λ () (send drr create-new-tab))) (wait-for-drracket-frame) (run-script "show-counter") (queue-callback/res (λ () (check string-suffix? (send (get-text) get-text) "\n0"))) (wait-for-drracket-frame) (run-script "increase-counter") (run-script "increase-counter") (run-script "increase-counter") (queue-callback/res (λ () (check string-suffix? (send (get-text) get-text) "\n3"))) (wait-for-drracket-frame) Is that the wrong way to do it?



robby
2022-5-18 15:45:59

Nothing jumps out at me as obviously the issue, I’m sorry to say.


robby
2022-5-18 15:46:22

Oh, I see one thing.


laurent.orseau
2022-5-18 15:46:40

Note: The quickscript script is persistent, which means it retains its state from call to call (and updates the state)


robby
2022-5-18 15:47:03

The first line creates a new tab (in the queue’d callback) but the second line is waiting for a drracket frame, not waiting for a new tab.


robby
2022-5-18 15:47:40

The wait-for-drracket-frame window just waits for the front most frame to be a drracket window.


robby
2022-5-18 15:47:50

You might need to wait for something else in those places?


laurent.orseau
2022-5-18 15:48:35

aha, that could explain the issue indeed. Is there a way to wait for the tab to be in keyboard focus?


robby
2022-5-18 15:48:53

you can write whatever predicate you need


robby
2022-5-18 15:49:04

Take a look at the implementation of wait-for-drracket-frame


laurent.orseau
2022-5-18 15:49:40

Ok great, thanks, I’ll take a look this weekend hopefully


robby
2022-5-18 15:50:19

The essence of it is the call to poll-until


laurent.orseau
2022-5-18 15:50:31

Right, I think I get the idea


robby
2022-5-18 15:50:35

There is some extra stuff in that function to print a message that you can ignore


robby
2022-5-18 15:51:18

The waiting for pending events might matter but might not depending on what’s going on but probalby you don’t want to rely on that.


robby
2022-5-18 15:51:43

If the work you’re starting is itself not going to finish on a single event (but queue’s other events) then you want to put that into your polling function


robby
2022-5-18 15:51:52

hth


laurent.orseau
2022-5-18 15:53:18

Does this (test:menu-select "Scripts" "Tests" name) pushes something to the event queue, or is it synchronized?


laurent.orseau
2022-5-18 15:58:01

From the code, it seems to be synchronized as I can see some semaphore waits, but I’m not 100% sure


robby
2022-5-18 17:12:50

The call to test:menu-select creates an event that selects the menu and puts that into the event queue.


robby
2022-5-18 17:13:15

That will trigger a call to that menu’s callback, which might just finish all its work or it might put more events into the queue, depending on what the menu item is/does.