Skip to content

Commit c028153

Browse files
committed
added test results extra data options
1 parent c06c517 commit c028153

10 files changed

Lines changed: 1882 additions & 2 deletions

File tree

lib/helper.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,22 @@ function xmlToObj(xml) {
4646
val = o[a[0]];
4747
o[a[0]] = [val];
4848
}
49-
newObj = {};
50-
o[a[0]].push(newObj);
49+
if (len === 2) {
50+
return rec([o[a[0]].length, a[1]], o[a[0]]);
51+
} else {
52+
newObj = {};
53+
o[a[0]].push(newObj);
54+
}
5155
} else {
5256
o[a[0]] = {};
5357
}
5458
for (i = 1, len = a.length; i < len; i += 1) {
5559
rec(a[i], newObj || o[a[0]]);
5660
}
61+
} else if (len === undefined && typeof a === 'object') {
62+
Object.keys(a).forEach(function(key) {
63+
o[key] = a[key];
64+
});
5765
}
5866
};
5967

lib/mapping.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,34 @@ var options = {
413413
}
414414
},
415415
results: {
416+
'breakdown': {
417+
name: 'breakDown',
418+
key: 'b',
419+
api: 'breakdown',
420+
bool: true,
421+
info: 'include the breakdown of requests and bytes by mime type'
422+
},
423+
'domains': {
424+
name: 'domains',
425+
key: 'D',
426+
api: 'domains',
427+
bool: true,
428+
info: 'include the breakdown of requests and bytes by domain'
429+
},
430+
'pagespeed': {
431+
name: 'pageSpeed',
432+
key: 'p',
433+
api: 'pagespeed',
434+
bool: true,
435+
info: 'include the PageSpeed score in the response (may be slower)'
436+
},
437+
'requests': {
438+
name: 'requests',
439+
key: 'R',
440+
api: 'requests',
441+
bool: true,
442+
info: 'include the request data in the response (slower and results in much larger responses)'
443+
},
416444
'median': {
417445
name: 'medianMetric',
418446
key: 'm',

test/command-line-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ describe('WebPageTest Command Line', function() {
5454
});
5555
});
5656

57+
it('gets a test results with extra data input returns the API url', function(done) {
58+
exec(mock('results 130724_YD_8JX -bDpR'), function(err, data) {
59+
if (err) return done(err);
60+
data = JSON.parse(data);
61+
assert.equal(data.url, wptServer +
62+
'xmlResult.php?test=130724_YD_8JX&breakdown=1&domains=1&pagespeed=1&requests=1');
63+
done();
64+
});
65+
});
66+
5767
it('gets the locations list input returns the API url', function(done) {
5868
exec(mock('locations'), function(err, data) {
5969
if (err) return done(err);

test/dryrun-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ describe('Dry Run', function() {
6262
});
6363
});
6464

65+
it('gets a test results with extra data request', function(done) {
66+
wpt.getTestResults('130724_YD_8JX', {
67+
breakDown: true,
68+
domains: true,
69+
pageSpeed: true,
70+
requests: true,
71+
dryRun: true
72+
}, function (err, data) {
73+
if (err) return done(err);
74+
assert.equal(data.url, wptServer +
75+
'xmlResult.php?test=130724_YD_8JX&breakdown=1&domains=1&pagespeed=1&requests=1');
76+
done();
77+
});
78+
});
79+
6580
it('gets the locations list request', function(done) {
6681
wpt.getLocations({dryRun: true}, function (err, data) {
6782
if (err) return done(err);

test/fixtures/command-line/help-results.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
Options:
55

66
-h, --help output usage information
7+
-b, --breakdown include the breakdown of requests and bytes by mime type
8+
-D, --domains include the breakdown of requests and bytes by domain
9+
-p, --pagespeed include the PageSpeed score in the response (may be slower)
10+
-R, --requests include the request data in the response (slower and results in much larger responses)
711
-m, --median <metric> set the metric used to calculate median for multiple runs tests [loadTime]
812
-S, --specs <json_or_file> set the specs for performance test suite
913
-r, --reporter <name> set performance test suite reporter output: [dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity

test/fixtures/command-line/help-test.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
--wait [hostname:port] wait for test results informed by agent once complete listening on <hostname>:<port> [hostname:first port available above 8000]
5454
--timeout <seconds> timeout for polling and waiting results [no timeout]
5555
-e, --request <id> echo request ID, useful to track asynchronous requests
56+
--breakdown include the breakdown of requests and bytes by mime type
57+
--domains include the breakdown of requests and bytes by domain
58+
--pagespeed include the PageSpeed score in the response (may be slower)
59+
--requests include the request data in the response (slower and results in much larger responses)
5660
--median <metric> set the metric used to calculate median for multiple runs tests [loadTime]
5761
--specs <json_or_file> set the specs for performance test suite
5862
--reporter <name> set performance test suite reporter output: [dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity

0 commit comments

Comments
 (0)