Skip to content

Commit 6de726c

Browse files
committed
put image viewer in functional state
1 parent e7691c2 commit 6de726c

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

devtools/image_viewer/server.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var path = require('path');
44
var exec = require('child_process').exec;
55

66
var browserify = require('browserify');
7+
var brfs = require('brfs');
78
var ecstatic = require('ecstatic');
89
var _open = require('open');
910

@@ -15,23 +16,31 @@ var PORT = '9090';
1516

1617
console.log('Listening on :' + PORT + '\n');
1718

18-
var listName = 'list-of-incorrect-images.txt';
19+
var listPath = constants.pathToTestImagesDiffList;
20+
var listCMD = [
21+
'ls',
22+
constants.pathToTestImagesDiff,
23+
'>',
24+
listPath
25+
].join(' ');
1926

2027
// build image viewer bundle
2128
fs.unlink(constants.pathToImageViewerBundle, function() {
22-
exec('ls ../test-images-diffs/ > ' + listName, function() {
23-
var b = browserify(path.join(__dirname, './viewer.js'), { debug: true });
29+
exec(listCMD, function() {
30+
var b = browserify(path.join(__dirname, './viewer.js'), {
31+
debug: true,
32+
transform: [brfs]
33+
});
2434

25-
b.transform('brfs');
2635
b.bundle(function(err) {
2736
if(err) throw err;
2837

2938
_open('http://localhost:' + PORT + '/devtools/image_viewer');
3039
})
3140
.pipe(fs.createWriteStream(constants.pathToImageViewerBundle));
3241

33-
fs.readFile(listName, 'utf8', function(err, data) {
34-
console.log('In ' + listName + ':\n' + data);
42+
fs.readFile(listPath, 'utf8', function(err, data) {
43+
console.log('In ' + listPath + ':\n' + data);
3544
});
3645
});
3746
});

devtools/image_viewer/viewer.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
var fs = require('fs');
2+
23
var d3 = require('d3');
34

5+
var constants = require('../../tasks/util/constants');
6+
7+
48
var $plotlist = document.getElementById('plot-list'),
59
$images = document.getElementById('plot-images'),
610
$mock = document.getElementById('plot-mock');
711

8-
var dirBaseline = '../test-images-baseline/',
9-
dirTest = '../test-images/',
10-
dirDiff = '../test-images-diffs/',
11-
dirMocks = '../mocks/';
12+
var dirBaseline = constants.pathToTestImageBaselines,
13+
dirTest = constants.pathToTestImages,
14+
dirDiff = constants.pathToTestImagesDiff,
15+
dirMocks = constants.pathToTestImageMocks;
1216

17+
// N.B. brfs only understand hard-coded paths
1318
var imageNames = fs.readFileSync(
14-
__dirname + '/list-of-incorrect-images.txt', 'utf8'
19+
__dirname + '/../../build/list_of_incorrect_images.txt',
20+
'utf8'
1521
)
1622
.split('\n')
1723
.filter(function(x) { return x; })

tasks/util/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
pathToTestImageBaselines: path.join(pathToImageTest, 'baselines/'),
3333
pathToTestImages: path.join(pathToBuild, 'test_images/'),
3434
pathToTestImagesDiff: path.join(pathToBuild, 'test_images_diff/'),
35+
pathToTestImagesDiffList: path.join(pathToBuild, 'list_of_incorrect_images.txt'),
3536

3637
uglifyOptions: {
3738
fromString: true,

0 commit comments

Comments
 (0)