Add a model for parsing buildbot JSON with unit tests
[WebKit.git] / Websites / perf.webkit.org / unit-tests / resources / v3-models.js
1 'use strict';
2
3 function importFromV3(file, name) {
4     const modelsDirectory = '../../public/v3/';
5
6     global[name] = require(modelsDirectory + file)[name];
7 }
8
9 importFromV3('models/data-model.js', 'DataModelObject');
10 importFromV3('models/data-model.js', 'LabeledObject');
11
12 importFromV3('models/analysis-task.js', 'AnalysisTask');
13 importFromV3('models/build-request.js', 'BuildRequest');
14 importFromV3('models/builder.js', 'Build');
15 importFromV3('models/builder.js', 'Builder');
16 importFromV3('models/commit-log.js', 'CommitLog');
17 importFromV3('models/measurement-adaptor.js', 'MeasurementAdaptor');
18 importFromV3('models/measurement-cluster.js', 'MeasurementCluster');
19 importFromV3('models/measurement-set.js', 'MeasurementSet');
20 importFromV3('models/metric.js', 'Metric');
21 importFromV3('models/platform.js', 'Platform');
22 importFromV3('models/repository.js', 'Repository');
23 importFromV3('models/root-set.js', 'MeasurementRootSet');
24 importFromV3('models/root-set.js', 'RootSet');
25 importFromV3('models/test.js', 'Test');
26 importFromV3('models/test-group.js', 'TestGroup');
27
28 importFromV3('instrumentation.js', 'Instrumentation');
29
30 global.Statistics = require('../../public/shared/statistics.js');
31
32 beforeEach(function () {
33     AnalysisTask._fetchAllPromise = null;
34     AnalysisTask.clearStaticMap();
35     CommitLog.clearStaticMap();
36     RootSet.clearStaticMap();
37     TestGroup.clearStaticMap();
38     BuildRequest.clearStaticMap();
39
40     global.osx = Repository.ensureSingleton(9, {name: 'OS X'});
41     global.webkit = Repository.ensureSingleton(11, {name: 'WebKit', url: 'http://trac.webkit.org/changeset/$1'});
42     global.builder = new Builder(176, {name: 'WebKit Perf Builder', buildUrl: 'http://build.webkit.org/builders/$builderName/$buildNumber'});
43
44     global.someTest = Test.ensureSingleton(1928, {name: 'Some test'});
45     global.someMetric = Metric.ensureSingleton(2884, {name: 'Some metric', test: someTest});
46     global.somePlatform = Platform.ensureSingleton(65, {name: 'Some platform', metrics: [someMetric]});
47 });