Skip to content

Commit 4dd5c40

Browse files
committed
Add Logging and disp message for CppServerFixture to debug Issue 205
1 parent 2a690f0 commit 4dd5c40

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

test/texamples.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,12 @@ function testWebread(testCase)
267267
server = fullfile(serverfolder, "webread_example_server");
268268

269269
% start the C++ server
270-
testCase.applyFixture(CppServerFixture(server, testCase));
270+
fixture = testCase.applyFixture(CppServerFixture(server, testCase));
271+
testCase.verifyEqual(fixture.Status,0,"webread_example_server failed to launch with the following output:" + fixture.CmdOut);
271272
pause(3); % wait for server to start up
272273

274+
% using disp to diagnose Issue #205
275+
disp(readlines(fixture.OutFile))
273276
% run the example
274277
webread_example();
275278

test/utils/CppServerFixture.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
properties(SetAccess=private)
88
ServerFile (1,1) string
9+
Status (1,1) double
10+
CmdOut (1,:) char
11+
FolderFixture
12+
OutFile
13+
914
end
1015

1116
properties(Access = private)
@@ -20,10 +25,13 @@
2025
function fixture = CppServerFixture(serverfile, testCase)
2126
fixture.ServerFile = string(serverfile);
2227
fixture.TestCase = testCase;
28+
fixture.FolderFixture = testCase.applyFixture(...
29+
matlab.unittest.fixtures.TemporaryFolderFixture);
2330
end
2431

2532
function setup(fixture)
26-
system(fixture.ServerFile + '&');
33+
fixture.OutFile = fullfile(fixture.FolderFixture.Folder,"webreadfail.txt");
34+
[fixture.Status,fixture.CmdOut] = system(fixture.ServerFile + "> " + fixture.OutFile + " 2>&1" +'&');
2735
end
2836

2937
function teardown(fixture)

0 commit comments

Comments
 (0)