forked from tensorflow/tfjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.ts
78 lines (65 loc) · 2.59 KB
/
run_tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
// We import index.ts so that the Node backend gets registered.
import './index';
import * as tf from '@tensorflow/tfjs-core';
import * as jasmine_util from '@tensorflow/tfjs-core/dist/jasmine_util';
Error.stackTraceLimit = Infinity;
// tslint:disable-next-line:no-require-imports
const jasmineCtor = require('jasmine');
process.on('unhandledRejection', e => {
throw e;
});
jasmine_util.setTestEnvs(
[{name: 'test-tensorflow', backendName: 'headless-nodegl', flags: {}}]);
const IGNORE_LIST: string[] = [
// https://github.com/tensorflow/tfjs/issues/1711
'time cpu test-tensorflow {} simple upload',
// TODO(kreeger): File issue: bad uniform in input.uniformValues.
'sparseToDense test-tensorflow {} should work with 0-sized tensors',
// TODO(kreeger): File issue: fromPixels doesn't have data field.
// tslint:disable:max-line-length
'fromPixels, mock canvas test-tensorflow {} accepts a canvas-like element, numChannels=4',
'fromPixels, mock canvas test-tensorflow {} accepts a canvas-like element'
];
const runner = new jasmineCtor();
runner.loadConfig({
spec_files: [
'src/**/*_test.ts', 'node_modules/@tensorflow/tfjs-core/dist/**/*_test.js'
],
random: false
});
if (process.env.JASMINE_SEED) {
runner.seed(process.env.JASMINE_SEED);
}
const env = jasmine.getEnv();
// Filter method that returns boolean, if a given test should return.
env.specFilter = spec => {
// Return false (skip the test) if the test is in the ignore list.
for (let i = 0; i < IGNORE_LIST.length; ++i) {
if (spec.getFullName().indexOf(IGNORE_LIST[i]) > -1) {
return false;
}
}
// Otherwise run the test.
return true;
};
console.log(`Running tests with the following GL info`);
const gl = (tf.backend() as tf.webgl.MathBackendWebGL).getGPGPUContext().gl;
console.log(` GL_VERSION: ${gl.getParameter(gl.VERSION)}`);
console.log(` GL_RENDERER: ${gl.getParameter(gl.RENDERER)}`);
runner.execute();