-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing higher-performance CT interface, see #88
- Loading branch information
1 parent
08c5610
commit 9285a2c
Showing
4 changed files
with
239 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<!-- | ||
Displays a self-updating report of continuous test results based on the continuous-server.js prototype. | ||
See local-report.js | ||
--> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | ||
|
||
<title>Continuous Testing</title> | ||
</head> | ||
|
||
<body> | ||
<script src="../../assert/js/assert.js"></script> | ||
<script src="../../tandem/js/PhetioIDUtils.js"></script> | ||
<script src="../../sherpa/lib/jquery-2.1.0.js"></script> | ||
<script src="../../sherpa/lib/lodash-4.17.4.min.js"></script> | ||
<script src="../../sherpa/lib/himalaya-0.2.7.js"></script> | ||
<script src="../../sherpa/lib/he-1.1.1.js"></script> | ||
<script src="../../query-string-machine/js/QueryStringMachine.js"></script> | ||
<script src="../../scenery/build/scenery.min.js"></script> | ||
<script src="../js/local-report.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// Copyright 2020, University of Colorado Boulder | ||
|
||
/** | ||
* Displays a self-updating report of continuous test results | ||
* | ||
* @author Jonathan Olson <[email protected]> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
window.assertions.enableAssert(); | ||
|
||
const options = QueryStringMachine.getAll( { | ||
server: { | ||
type: 'string', | ||
|
||
// Origin for our server (ignoring current port), so that we don't require localhost | ||
defaultValue: window.location.protocol + '//' + window.location.hostname | ||
} | ||
} ); | ||
|
||
const passColor = new scenery.Color( 60, 255, 60 ); | ||
const failColor = new scenery.Color( 255, 90, 90 ); | ||
const mixedColor = new scenery.Color( 255,210,80 ); | ||
const unincludedColor = new scenery.Color( 128, 128, 128 ); | ||
const untestedColor = new scenery.Color( 240, 240, 240 ); | ||
|
||
// Property.<string> | ||
const snapshotStatusProperty = new axon.Property( 'unknown status' ); | ||
|
||
snapshotStatusProperty.lazyLink( status => console.log( `Status: ${status}` ) ); | ||
|
||
(function snapshotStatusLoop() { | ||
const req = new XMLHttpRequest(); | ||
req.onload = function() { | ||
setTimeout( snapshotStatusLoop, 1000 ); | ||
snapshotStatusProperty.value = JSON.parse( req.responseText ).status; | ||
}; | ||
req.onerror = function() { | ||
setTimeout( snapshotStatusLoop, 1000 ); | ||
snapshotStatusProperty.value = 'Could not contact server'; | ||
}; | ||
req.open( 'get', options.server + '/aquaserver/snapshot-status', true ); | ||
req.send(); | ||
})(); | ||
|
||
// Property.<Object|null> | ||
const reportProperty = new axon.Property( { | ||
snapshots: [], | ||
testNames: [] | ||
} ); | ||
|
||
(function reportLoop() { | ||
const req = new XMLHttpRequest(); | ||
req.onload = function() { | ||
setTimeout( reportLoop, 20000 ); | ||
reportProperty.value = JSON.parse( req.responseText ); | ||
}; | ||
req.onerror = function() { | ||
setTimeout( reportLoop, 20000 ); | ||
reportProperty.reset(); | ||
}; | ||
req.open( 'get', options.server + '/aquaserver/report', true ); | ||
req.send(); | ||
})(); | ||
|
||
const rootNode = new scenery.Node(); | ||
const display = new scenery.Display( rootNode ); | ||
|
||
document.body.appendChild( display.domElement ); | ||
|
||
display.initializeEvents(); | ||
display.updateOnRequestAnimationFrame( dt => { | ||
|
||
} ); | ||
|
||
const statusNode = new scenery.Text( '', { fontSize: 14 } ); | ||
snapshotStatusProperty.link( status => { | ||
statusNode.text = status; | ||
} ); | ||
|
||
const reportNode = new scenery.Node(); | ||
reportProperty.link( report => { | ||
const testLabels = report.testNames.map( names => new scenery.Text( names.join( ' : ' ), { fontSize: 12 } ) ); | ||
|
||
const snapshotLabels = report.snapshots.map( snapshot => new scenery.VBox( { | ||
spacing: 2, | ||
children: [ | ||
...new Date( 1586988043041 ).toLocaleString().replace( ',', '' ).replace( ' AM', 'am' ).replace( ' PM', 'pm' ).split( ' ' ).map( str => new scenery.Text( str, { fontSize: 10 } ) ) | ||
] | ||
} ) ); | ||
|
||
const maxTestLabelWidth = _.max( testLabels.map( node => node.width ) ); | ||
const maxTestLabelHeight = _.max( testLabels.map( node => node.height ) ); | ||
const maxSnapshotLabelWidth = _.max( snapshotLabels.map( node => node.width ) ); | ||
const maxSnapshotLabelHeight = _.max( snapshotLabels.map( node => node.height ) ); | ||
|
||
const snapshotsTestNodes = _.flatten( report.snapshots.map( ( snapshot, i ) => { | ||
return report.testNames.map( ( names, j ) => { | ||
const test = _.find( snapshot.tests, test => _.isEqual( names, test.names ) ); | ||
|
||
const background = new scenery.Rectangle( 0, 0, maxSnapshotLabelWidth, maxTestLabelHeight, { | ||
x: maxTestLabelWidth + i * maxSnapshotLabelWidth, | ||
y: maxSnapshotLabelHeight + j * maxTestLabelHeight | ||
} ); | ||
|
||
if ( test ) { | ||
if ( test.passCount > 0 && test.failCount === 0 ) { | ||
background.fill = passColor; | ||
} | ||
else if ( test.passCount === 0 && test.failCount > 0 ) { | ||
background.fill = failColor; | ||
} | ||
else if ( test.passCount === 0 && test.failCount === 0 ) { | ||
background.fill = untestedColor; | ||
} | ||
else { | ||
background.fill = mixedColor; | ||
} | ||
} | ||
else { | ||
background.fill = unincludedColor; | ||
} | ||
|
||
return background; | ||
} ); | ||
} ) ); | ||
|
||
testLabels.forEach( ( label, i ) => { | ||
label.left = 0; | ||
label.top = i * maxTestLabelHeight + maxSnapshotLabelHeight; | ||
} ); | ||
snapshotLabels.forEach( ( label, i ) => { | ||
label.top = 0; | ||
label.left = maxTestLabelWidth + i * maxSnapshotLabelWidth; | ||
} ); | ||
|
||
reportNode.children = [ | ||
...testLabels, | ||
...snapshotLabels, | ||
...snapshotsTestNodes | ||
]; | ||
display.width = Math.ceil( rootNode.width ); | ||
display.height = Math.ceil( rootNode.height ); | ||
} ); | ||
|
||
|
||
|
||
|
||
rootNode.addChild( new scenery.VBox( { | ||
spacing: 10, | ||
align: 'left', | ||
children: [ statusNode, reportNode ] | ||
} ) ); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters