Skip to content

Commit e21de82

Browse files
andyclaude
andcommitted
Test hook: ECCE_TEST_DIALOG_ANSWER picks the button; launcher test covers Launch anyway
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BTQ7mniRtDdhU7VF9tEVBD
1 parent 3acaddb commit e21de82

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎src/wxgui/wxdialogs/ewxMessageDialog.C‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <cstring>
12
#include "wx/wxprec.h"
23

34
#ifndef WX_PRECOMP
@@ -122,6 +123,7 @@ void ewxMessageDialog::OnButtonClick( wxCommandEvent& event )
122123

123124
// ECCE_TEST_DIALOG_CLOSE=<seconds>: log the dialog to stderr, then dismiss it
124125
// after that long, so a headless run can see it and still end cleanly.
126+
// ECCE_TEST_DIALOG_ANSWER=yes|ok|cancel picks the button pressed (default ok).
125127
int ewxMessageDialog::ShowModal()
126128
{
127129
const char * secs = getenv("ECCE_TEST_DIALOG_CLOSE");
@@ -132,7 +134,11 @@ int ewxMessageDialog::ShowModal()
132134
(const char *)p_label->GetLabel().mb_str());
133135
fflush(stderr);
134136
wxTimer timer(this);
135-
Bind(wxEVT_TIMER, [this](wxTimerEvent&) { EndModal(wxID_OK); });
137+
const char * ans = getenv("ECCE_TEST_DIALOG_ANSWER");
138+
int id = wxID_OK;
139+
if (ans && !strcmp(ans, "yes")) id = wxID_YES;
140+
else if (ans && !strcmp(ans, "cancel")) id = wxID_CANCEL;
141+
Bind(wxEVT_TIMER, [this, id](wxTimerEvent&) { EndModal(id); });
136142
timer.StartOnce(atoi(secs) * 1000);
137143
return ewxDialog::ShowModal();
138144
}

‎tests/machregister/launcher_test.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ def mpi_check(disp, build, tmp):
7474
g.write(os.path.join(fake, "mpirun"), "#!/bin/sh\n")
7575
os.chmod(os.path.join(fake, "mpirun"), 0o755)
7676

77-
def run(path, script):
77+
def run(path, script, answer=None):
7878
g.write(os.path.join(e.root, "lscript"), script)
7979
env = e.env(disp)
8080
env.pop("ECCE_MACHREG_SCRIPT", None)
81+
if answer:
82+
env["ECCE_TEST_DIALOG_ANSWER"] = answer
8183
env.update({"ECCE_REALUSER": "eccetest", "PATH": path,
8284
"ECCE_TEST_DIALOG_CLOSE": "1",
8385
"ECCE_LAUNCHER_SCRIPT": os.path.join(e.root, "lscript")})
@@ -107,6 +109,16 @@ def run(path, script):
107109
"a missing mpirun for ORCA on 4 cores is named")
108110
g.check("mpicheck NWChem: go" in out,
109111
"after Run on 1 core nothing more is asked")
112+
p = run(farm, """
113+
machine localhost
114+
procs 4
115+
mpicheck ORCA
116+
expect wsprocs 4
117+
quit
118+
""", answer="yes")
119+
clean(p, "the MPI check answered Launch anyway")
120+
g.check("ECCE_TEST_DIALOG:" in p.stdout and "mpicheck ORCA: go" in p.stdout,
121+
"Launch anyway goes on with the cores as set (4)")
110122
p = run(fake + os.pathsep + farm, """
111123
machine localhost
112124
procs 4

0 commit comments

Comments
 (0)