Skip to content

Commit 4ed2572

Browse files
author
jan
committed
Better logging to find out why the regression test fails on github
1 parent d47a4d8 commit 4ed2572

10 files changed

+380
-417
lines changed

io.sloeber.tests/src/io/sloeber/core/CompileAndUpload.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sloeber.core;
22

33

4+
import static org.junit.Assert.assertNull;
45
import static org.junit.Assert.fail;
56

67
import java.io.File;
@@ -171,7 +172,7 @@ public void Build_Verify_upload(MCUBoard myBoard,CodeDescription codeDescriptor,
171172
}
172173
try {
173174
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
174-
if (Shared.hasBuildErrors(theTestProject)) {
175+
if (Shared.hasBuildErrors(theTestProject)!=null) {
175176
// try again because the libraries may not yet been added
176177
Shared.waitForAllJobsToFinish(); // for the indexer
177178
try {
@@ -182,11 +183,8 @@ public void Build_Verify_upload(MCUBoard myBoard,CodeDescription codeDescriptor,
182183
}
183184
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD,
184185
monitor);
185-
if (Shared.hasBuildErrors(theTestProject)) {
186-
// give up
187-
fail("Failed to compile the project:" + projectName
188-
+ " build errors");
189-
}
186+
// give up
187+
assertNull (Shared.hasBuildErrors(theTestProject)) ;
190188
}
191189

192190
} catch (CoreException e) {

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ public void testExample(String projectName, CodeDescription codeDescriptor,
9595
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", Shared.buildCounter++ >= mySkipAtStart);
9696
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
9797

98-
if (!Shared.buildAndVerify(projectName, board.getBoardDescriptor(), codeDescriptor,
99-
new CompileDescription())) {
100-
myTotalFails++;
101-
fail(Shared.getLastFailMessage());
102-
}
98+
myTotalFails++;
99+
assertNull (Shared.buildAndVerify(projectName, board.getBoardDescriptor(), codeDescriptor,
100+
new CompileDescription())) ;
101+
myTotalFails++;
103102
}
104103

105104
}

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnTeensyTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ public void testArduinoIDEExamplesOnTeensy(String testName, CodeDescription code
9393
BoardDescription board) throws Exception {
9494
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
9595
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
96-
if (!Shared.buildAndVerify(testName, board, codeDescriptor, new CompileDescription())) {
97-
myTotalFails++;
98-
fail(Shared.getLastFailMessage());
99-
}
96+
myTotalFails++;
97+
assertNull (Shared.buildAndVerify(testName, board, codeDescriptor, new CompileDescription()));
98+
myTotalFails--;
10099
}
101100

102101
}

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesonJantjesBoardsTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ public void testExample( CodeDescription codeDescriptor,
9393
BoardDescription board) throws Exception {
9494
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
9595
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
96-
97-
if (!Shared.buildAndVerify(board, codeDescriptor)) {
98-
myTotalFails++;
99-
fail(Shared.getLastFailMessage());
100-
}
96+
myTotalFails++;
97+
assertNull (Shared.buildAndVerify(board, codeDescriptor));
98+
myTotalFails--;
10199
}
102100

103101
}

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileDefaultInoOnAllBoardsTest.java

Lines changed: 313 additions & 315 deletions
Large diffs are not rendered by default.

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileExamplesTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sloeber.core;
22

3+
import static org.junit.Assert.assertNull;
34
import static org.junit.Assert.fail;
45

56
import java.util.Arrays;
@@ -114,10 +115,9 @@ public void testExamples(String name, BoardDescription boardDescriptor, CodeDesc
114115
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
115116

116117
Shared.buildCounter++;
117-
if (!Shared.buildAndVerify(name, boardDescriptor, codeDescriptor, new CompileDescription())) {
118-
myTotalFails++;
119-
fail(Shared.getLastFailMessage() );
120-
}
118+
myTotalFails++;
119+
assertNull(Shared.buildAndVerify(name, boardDescriptor, codeDescriptor, new CompileDescription()));
120+
myTotalFails--;
121121

122122
}
123123

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileLibraryExamplesTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ public void testExamples(String name, MCUBoard boardID, Example example) throws
112112
Map<String, String> boardOptions = boardID.getBoardOptions(example);
113113
BoardDescription boardDescriptor = boardID.getBoardDescriptor();
114114
boardDescriptor.setOptions(boardOptions);
115-
if (!Shared.buildAndVerify(boardDescriptor, codeDescriptor)) {
115+
String error=Shared.buildAndVerify(boardDescriptor, codeDescriptor);
116+
if (error!=null) {
116117
myTotalFails++;
117-
fail(Shared.getLastFailMessage());
118+
fail(error);
118119
}
119120

120121
}

io.sloeber.tests/src/io/sloeber/core/RegressionTest.java

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ public void issue555() throws CoreException {
111111
}
112112
try {
113113
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
114-
if (Shared.hasBuildErrors(theTestProject)) {
115-
fail("Failed to compile the project:" + projectName + " as uno build errors");
116-
}
114+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
117115
} catch (CoreException e) {
118116
e.printStackTrace();
119117
fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as uno exception");
@@ -133,12 +131,10 @@ public void issue555() throws CoreException {
133131

134132
try {
135133
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
136-
if (Shared.hasBuildErrors(theTestProject)) {
134+
if (Shared.hasBuildErrors(theTestProject)!=null) {
137135
Shared.waitForAllJobsToFinish();
138136
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
139-
if (Shared.hasBuildErrors(theTestProject)) {
140-
fail("Failed to compile the project:" + projectName + " as teensy");
141-
}
137+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
142138
}
143139
} catch (CoreException e) {
144140
e.printStackTrace();
@@ -164,9 +160,7 @@ public void issue687() throws Exception {
164160
new CompileDescription(), new NullProgressMonitor());
165161
Shared.waitForAllJobsToFinish(); // for the indexer
166162
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
167-
if (Shared.hasBuildErrors(theTestProject)) {
168-
fail("Failed to compile the project:" + projectName + " issue687 is not fixed");
169-
}
163+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
170164
} catch (Exception e) {
171165
e.printStackTrace();
172166
fail("Failed to create the project:" + projectName);
@@ -188,9 +182,7 @@ public void create_CPP_based_Sloeber_Project() throws Exception {
188182
new CompileDescription(), new NullProgressMonitor());
189183
Shared.waitForAllJobsToFinish(); // for the indexer
190184
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
191-
if (Shared.hasBuildErrors(theTestProject)) {
192-
fail("Failed to compile the project:" + projectName + " CPP project no longer work");
193-
}
185+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
194186
} catch (Exception e) {
195187
e.printStackTrace();
196188
fail("Failed to create the project:" + projectName);
@@ -212,9 +204,7 @@ public void createDefaultInoProject() throws Exception {
212204
new CompileDescription(), new NullProgressMonitor());
213205
Shared.waitForAllJobsToFinish(); // for the indexer
214206
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
215-
if (Shared.hasBuildErrors(theTestProject)) {
216-
fail("Failed to compile the project:" + projectName + " INO project no longer work");
217-
}
207+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
218208
} catch (Exception e) {
219209
e.printStackTrace();
220210
fail("Failed to create the project:" + projectName);
@@ -240,9 +230,7 @@ public void issue1047_Board_Names_Can_Be_used_as_Strings() throws Exception {
240230
unoBoard.getBoardDescriptor(), codeDescriptor, new CompileDescription(), new NullProgressMonitor());
241231
Shared.waitForAllJobsToFinish(); // for the indexer
242232
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
243-
if (Shared.hasBuildErrors(theTestProject)) {
244-
fail("Failed to compile the project:" + projectName + " issue1047 is not fixed");
245-
}
233+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
246234
} catch (Exception e) {
247235
e.printStackTrace();
248236
fail("Failed to create the project:" + projectName);
@@ -278,10 +266,7 @@ public void are_jantjes_options_taken_into_account() throws Exception {
278266

279267
Shared.waitForAllJobsToFinish(); // for the indexer
280268
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
281-
if (Shared.hasBuildErrors(theTestProject)) {
282-
fail("Failed to compile the project:" + projectName
283-
+ " The defines have not been taken into account properly");
284-
}
269+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
285270
} catch (Exception e) {
286271
e.printStackTrace();
287272
fail("Failed to create the project:" + projectName);
@@ -311,10 +296,7 @@ public void is_extern_C_taken_into_account() throws Exception {
311296

312297
Shared.waitForAllJobsToFinish(); // for the indexer
313298
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
314-
if (Shared.hasBuildErrors(theTestProject)) {
315-
fail("Failed to compile the project:" + projectName
316-
+ " extern \"C\" has not been taken into account properly.");
317-
}
299+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
318300
} catch (Exception e) {
319301
e.printStackTrace();
320302
fail("Failed to create the project:" + projectName);
@@ -343,10 +325,7 @@ public void are_defines_before_includes_taken_into_account() throws Exception {
343325

344326
Shared.waitForAllJobsToFinish(); // for the indexer
345327
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
346-
if (Shared.hasBuildErrors(theTestProject)) {
347-
fail("Failed to compile the project:" + projectName
348-
+ " defines have not been taken into account properly.");
349-
}
328+
Assert.assertNull(Shared.hasBuildErrors(theTestProject));
350329

351330
}
352331

@@ -370,9 +349,7 @@ public void rename_Configuration() throws Exception {
370349

371350
Shared.waitForAllJobsToFinish(); // for the indexer
372351
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
373-
if (Shared.hasBuildErrors(theTestProject)) {
374-
fail("Failed to compile the project before config rename");
375-
}
352+
Assert.assertNull("Failed to compile the project before config rename",Shared.hasBuildErrors(theTestProject));
376353

377354
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
378355
ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(theTestProject);
@@ -382,9 +359,7 @@ public void rename_Configuration() throws Exception {
382359

383360
Shared.waitForAllJobsToFinish(); // for the indexer
384361
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
385-
if (Shared.hasBuildErrors(theTestProject)) {
386-
fail("Failed to compile the project after config rename");
387-
}
362+
Assert.assertNull("Failed to compile the project after config rename",Shared.hasBuildErrors(theTestProject));
388363
}
389364

390365
// /**
@@ -450,9 +425,7 @@ public void openAndClosePreservesSettings(String projectName , CodeDescription c
450425
// also do a build
451426
Shared.waitForAllJobsToFinish(); // for the indexer
452427
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
453-
if (Shared.hasBuildErrors(theTestProject)) {
454-
fail("Failed to compile the project before close:" + projectName);
455-
}
428+
Assert.assertNull("Failed to compile the project before close: "+ projectName,Shared.hasBuildErrors(theTestProject));
456429

457430
// also do a clean
458431
Shared.waitForAllJobsToFinish(); // for the indexer
@@ -497,9 +470,7 @@ public void openAndClosePreservesSettings(String projectName , CodeDescription c
497470
// also do a build
498471
Shared.waitForAllJobsToFinish(); // for the indexer
499472
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
500-
if (Shared.hasBuildErrors(theTestProject)) {
501-
fail("Failed to compile the project after open:" + projectName);
502-
}
473+
Assert.assertNull("Failed to compile the project after open: "+ projectName,Shared.hasBuildErrors(theTestProject));
503474

504475
}
505476

@@ -608,7 +579,7 @@ public void createProjectWithURI() throws Exception {
608579
otherDesc, new NullProgressMonitor());
609580

610581
proj.build(IncrementalProjectBuilder.FULL_BUILD, null);
611-
Assert.assertFalse("Failed to compile the project: " + proj1Name, Shared.hasBuildErrors(proj));
582+
Assert.assertNull("Failed to compile the project: " + Shared.hasBuildErrors(proj), Shared.hasBuildErrors(proj));
612583
String fileLocation = projectFolder.append("src").append(proj1Name + ".cpp").toString();
613584

614585
IFile cppFile = proj.getFolder("src").getFile(proj1Name + ".cpp");
@@ -694,7 +665,7 @@ public void testDifferentSourceFolders(String projectName, CodeDescription codeD
694665
Shared.waitForAllJobsToFinish(); // for the indexer
695666

696667
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
697-
assertFalse("Failed to compile "+projectName,Shared.hasBuildErrors(project));
668+
assertNull("Failed to compile "+projectName,Shared.hasBuildErrors(project));
698669

699670
String srcFolder=codeDescriptor.getCodeFolder();
700671
IFile cppFile=null;
@@ -725,10 +696,8 @@ public void redirectedJson() throws Exception {
725696
fail("redirect Json ");
726697
return;
727698
}
728-
if (!Shared.buildAndVerify("redirect_json", boardid, CodeDescription.createDefaultIno(),
729-
new CompileDescription())) {
730-
fail(Shared.getLastFailMessage() );
731-
}
699+
Assert.assertNull(Shared.buildAndVerify("redirect_json", boardid, CodeDescription.createDefaultIno(),
700+
new CompileDescription()));
732701
}
733702

734703

@@ -785,9 +754,7 @@ public void NightlyBoardPatron( String name, MCUBoard boardID, Example example,C
785754

786755
BoardDescription boardDescriptor = boardID.getBoardDescriptor();
787756
boardDescriptor.setOptions(boardID.getBoardOptions(example));
788-
if(!Shared.buildAndVerifyAllBuilders(name,boardID.getBoardDescriptor(), codeDescriptor, compileOptions)) {
789-
fail(Shared.getLastFailMessage() );
790-
}
757+
Assert.assertNull(Shared.buildAndVerifyAllBuilders(name,boardID.getBoardDescriptor(), codeDescriptor, compileOptions));
791758

792759
}
793760

0 commit comments

Comments
 (0)