Skip to content

Commit f2bd38d

Browse files
committed
Merge branch 'development' of github.com:kgrgreer/foam3 into development
2 parents fd1bb9c + 08485cb commit f2bd38d

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

src/foam/core/test/TestBorder.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,15 @@ foam.CLASS({
160160
if ( t.failed ) {
161161
self.failed += t.failed;
162162
if ( testRun ) {
163-
// TODO: capture individual tests failures on the test,
164-
// so they can be added here.
165163
testRun.failures.push(t.id);
164+
if ( t.output ) {
165+
var lines = t.output.split('\n');
166+
for ( var i = 0 ; i < lines.length ; i++ ) {
167+
if ( lines[i].startsWith('FAILURE') ) {
168+
testRun.failures.push(lines[i]);
169+
}
170+
}
171+
}
166172
}
167173
}
168174
} catch (e) {

src/foam/core/test/TestRunnerScript.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ This will also keep the foam application running for inspection from the GUI.
213213
exitCode = 1;
214214
}
215215
if ( clientTestRun != null ) {
216+
reportClientTestDetails(x, clientTests);
216217
reportResults(x, clientTestRun, runTime);
217218
if (clientTestRun.getFailed() > 0 )
218219
exitCode = 1;
@@ -493,7 +494,31 @@ This will also keep the foam application running for inspection from the GUI.
493494
};
494495
agent.setHeadless( ! Boolean.getBoolean(SYSTEM_TEST_HEADED) );
495496
agent.execute(x);
496-
return (TestRun) dao.find(testRun.getId());
497+
TestRun result = (TestRun) dao.find(testRun.getId());
498+
if ( ! result.getCompleted() ) {
499+
result = (TestRun) result.fclone();
500+
result.setCompleted(true);
501+
result.setFailed(result.getFailed() + 1);
502+
result.setTests(result.getTests() + 1);
503+
List<String> failures = result.getFailures() != null ? new ArrayList<>((List<String>) result.getFailures()) : new ArrayList<>();
504+
failures.add("FAILURE: Client tests timed out after " + agent.getTimeout() + " seconds. Tests may still be running in the browser.");
505+
result.setFailures(failures);
506+
result = (TestRun) dao.put(result);
507+
}
508+
return result;
509+
`
510+
},
511+
{
512+
name: 'reportClientTestDetails',
513+
args: 'X x, List tests',
514+
javaCode: `
515+
DAO testDAO = (DAO) x.get("testDAO");
516+
for ( Test test : (List<Test>) tests ) {
517+
test = (Test) testDAO.find(test.getId());
518+
if ( test == null ) continue;
519+
printBold(test.getId());
520+
printOutput(test);
521+
}
497522
`
498523
},
499524
{

src/foam/u2/view/LazyScrollManager.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,14 @@ foam.CLASS({
285285
documentation: 'Tracks the first page where each group appears.',
286286
factory: function() { return {}; }
287287
},
288-
['suspendObserver', false]
288+
['suspendObserver', false],
289+
{
290+
name: 'refreshId',
291+
documentation: 'UID used to prevent old data from corrupting the refresh process',
292+
factory: function() {
293+
return foam.next$UID();
294+
}
295+
}
289296
],
290297

291298
methods: [
@@ -494,10 +501,13 @@ foam.CLASS({
494501
sortParams.push(this.invertGroupingOrder ? this.DESC(this.groupBy) : this.groupBy);
495502
if ( this.order ) sortParams.push(this.order);
496503
if ( sortParams.length ) proxy = proxy.orderBy(sortParams);
504+
let refreshId = this.refreshId;
497505

498506
this.loadingPages_$set(page);
499-
500507
return this.prepDAO(proxy, this.ctx).then((values) => {
508+
// This means a refresh was triggered while the call was in-flight
509+
// discard any calls since they might have old data
510+
if ( this.refreshId !== refreshId ) return;
501511
if ( page < this.currentTopPage_ || page > this.currentTopPage_ + this.NUM_PAGES_TO_RENDER) {
502512
// console.debug('Skipping load', page);
503513
this.loadingPages_$remove(page);
@@ -631,6 +641,8 @@ foam.CLASS({
631641
this.groupFirstPage_ = {};
632642
this.pageHeights_ = {};
633643
this.loadingPages_ = {};
644+
this.loadedPages_ = {};
645+
this.renderedPages_ = {};
634646
if ( ! this.isInit ) {
635647
this.currentTopPage_ = 0;
636648
this.topRow = 0;
@@ -645,6 +657,7 @@ foam.CLASS({
645657
// Re-attach sentinel observer after disconnect
646658
this.topSpacer_?.el().then(el => this.sentinelObserver_?.observe(el));
647659
this.bottomSpacer_?.el().then(el => this.sentinelObserver_?.observe(el));
660+
this.clearProperty('refreshId');
648661
this.updateRenderedPages();
649662
if ( this.topRow > 1 ) this.scrollToIndex = this.topRow;
650663
}

0 commit comments

Comments
 (0)