Skip to content

Commit 6375f36

Browse files
committed
Add code to trace execusion of test TestPlugins.testProcess() which hangs on AppVeyor.
1 parent 319f594 commit 6375f36

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/tests/TestPlugins.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include "rapidassist/timing.h"
3737
#include "rapidassist/process.h"
3838

39+
#include "Environment.h"
40+
#include "rapidassist/environment_utf8.h"
41+
3942
namespace shellanything
4043
{
4144
namespace test
@@ -99,40 +102,70 @@ namespace shellanything
99102
//--------------------------------------------------------------------------------------------------
100103
TEST_F(TestPlugins, testProcess)
101104
{
105+
#define TRACE_LINE printf("%s, line %d\n", __FUNCTION__, __LINE__)
106+
107+
TRACE_LINE;
108+
109+
{
110+
// Force verbose mode
111+
static const std::string& VERBOSE_OPTION_NAME = Environment::SYSTEM_LOGGING_VERBOSE_ENVIRONMENT_VARIABLE_NAME;
112+
ra::environment::SetEnvironmentVariableUtf8(VERBOSE_OPTION_NAME.c_str(), "true");
113+
114+
115+
}
116+
117+
TRACE_LINE;
118+
102119
ConfigManager& cmgr = ConfigManager::GetInstance();
103120

121+
TRACE_LINE;
122+
104123
//Creating a temporary workspace for the test execution.
105124
Workspace workspace;
106125
ASSERT_FALSE(workspace.GetBaseDirectory().empty());
107126
ASSERT_TRUE(workspace.IsEmpty());
108127

128+
TRACE_LINE;
129+
109130
//Import the required files into the workspace
110131
static const std::string path_separator = ra::filesystem::GetPathSeparatorStr();
111132
std::string test_name = ra::testing::GetTestQualifiedName();
112133
std::string template_source_path = std::string("test_files") + path_separator + test_name + ".xml";
113134
ASSERT_TRUE(workspace.ImportFileUtf8(template_source_path.c_str()));
114135

136+
TRACE_LINE;
137+
115138
//Wait to make sure that the next file copy/modification will not have the same timestamp
116139
ra::timing::Millisleep(1500);
117140

141+
TRACE_LINE;
142+
118143
//Setup ConfigManager to read files from workspace
119144
cmgr.ClearSearchPath();
120145
cmgr.AddSearchPath(workspace.GetBaseDirectory());
121146
cmgr.Refresh();
122147

148+
TRACE_LINE;
149+
123150
//ASSERT the file is loaded
124151
ConfigFile::ConfigFilePtrList configs = cmgr.GetConfigFiles();
125152
ASSERT_EQ(1, configs.size());
126153

154+
TRACE_LINE;
155+
127156
ConfigFile* config0 = cmgr.GetConfigFiles()[0];
128157

158+
TRACE_LINE;
159+
129160
//ASSERT all plugins were loaded
130161
for (size_t i = 0; i < config0->GetPlugins().size(); i++)
131162
{
132163
const Plugin* plugin = config0->GetPlugins()[i];
133164
ASSERT_TRUE(plugin->IsLoaded()) << "The plugin '" << plugin->GetPath() << "' is not loaded.";
134165
}
135166

167+
TRACE_LINE;
168+
136169
//Get menus
137170
Menu::MenuPtrList menus = cmgr.GetConfigFiles()[0]->GetMenus();
138171
ASSERT_EQ(4, menus.size());
@@ -145,6 +178,8 @@ namespace shellanything
145178
ASSERT_TRUE(menu2 != NULL);
146179
ASSERT_TRUE(menu3 != NULL);
147180

181+
TRACE_LINE;
182+
148183
//ASSERT all expected content is parsed
149184
for (size_t i = 0; i < menus.size(); i++)
150185
{
@@ -159,21 +194,31 @@ namespace shellanything
159194
ASSERT_EQ(1, actions.size());
160195
}
161196

197+
TRACE_LINE;
198+
162199
PropertyManager& pmgr = PropertyManager::GetInstance();
163200

201+
TRACE_LINE;
202+
164203
//Disable process id property
165204
pmgr.SetProperty("sa_plugin_process.pid", "");
166205

206+
TRACE_LINE;
207+
167208
//Kill all instances of calc.exe
168209
KillCalculatorProcess();
169210

211+
TRACE_LINE;
212+
170213
//Set all menus visible
171214
for (size_t i = 0; i < menus.size(); i++)
172215
{
173216
Menu* menu = menus[i];
174217
menu->SetVisible(true);
175218
}
176219

220+
TRACE_LINE;
221+
177222
//Force an update to call the plugin
178223
SelectionContext c;
179224
#ifdef _WIN32
@@ -187,56 +232,78 @@ namespace shellanything
187232
#endif
188233
config0->Update(c);
189234

235+
TRACE_LINE;
236+
190237
//ASSERT all menus are now invisible
191238
for (size_t i = 0; i < menus.size(); i++)
192239
{
193240
Menu* menu = menus[i];
194241
ASSERT_FALSE(menu->IsVisible()) << "menu[" << i << "] named '" << menu->GetName() << "' should be invisible";
195242
}
196243

244+
TRACE_LINE;
245+
197246
//Start calc
198247
ra::process::processid_t pId = 0;
199248
ASSERT_TRUE( StartCalculatorProcess(pId) );
200249

250+
TRACE_LINE;
251+
201252
//Set all menus visible
202253
for (size_t i = 0; i < menus.size(); i++)
203254
{
204255
Menu* menu = menus[i];
205256
menu->SetVisible(true);
206257
}
207258

259+
TRACE_LINE;
260+
208261
//Update menus again
209262
config0->Update(c);
210263

264+
TRACE_LINE;
265+
211266
//ASSERT that half of menus are now invisible
212267
ASSERT_TRUE(menu0->IsVisible()) << "Menu named '" << menu0->GetName() << "' should be visible";
213268
ASSERT_FALSE(menu1->IsVisible()) << "Menu named '" << menu1->GetName() << "' should be invisible";
214269
ASSERT_TRUE(menu2->IsVisible()) << "Menu named '" << menu2->GetName() << "' should be visible";
215270
ASSERT_FALSE(menu3->IsVisible()) << "Menu named '" << menu3->GetName() << "' should be invisible";
216271

272+
TRACE_LINE;
273+
217274
//Set all menus invisible
218275
for (size_t i = 0; i < menus.size(); i++)
219276
{
220277
Menu* menu = menus[i];
221278
menu->SetVisible(false);
222279
}
223280

281+
TRACE_LINE;
282+
224283
// Change a property which is used by menus to filter visibility by pid
225284
pmgr.SetProperty("sa_plugin_process.pid", ra::strings::ToString(pId));
226285

286+
TRACE_LINE;
287+
227288
//Update menus again
228289
config0->Update(c);
229290

291+
TRACE_LINE;
292+
230293
//ASSERT all menus are now visible
231294
for (size_t i = 0; i < menus.size(); i++)
232295
{
233296
Menu* menu = menus[i];
234297
ASSERT_TRUE(menu->IsVisible()) << "menu[" << i << "] named '" << menu->GetName() << "' should be visible";
235298
}
236299

300+
TRACE_LINE;
301+
237302
//Cleanup
238303
KillCalculatorProcess();
239304
ASSERT_TRUE(workspace.Cleanup()) << "Failed deleting workspace directory '" << workspace.GetBaseDirectory() << "'.";
305+
306+
TRACE_LINE;
240307
}
241308
//--------------------------------------------------------------------------------------------------
242309
TEST_F(TestPlugins, testServices)

0 commit comments

Comments
 (0)