Skip to content

Commit 5ec3184

Browse files
authored
Mocha integration test suite (facebookincubator#150)
This moves ./npm to ./npm/fbx2gltf, and introduces a Mocha / TypeScript based testing harness. We're also adding a GIT LFS dependency, but only for people who want to run tests. We're using LFS to store the many FBX models we want to convert to GLB as part of the integration test suite.
1 parent ffd6af3 commit 5ec3184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+895
-76
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.glb filter=lfs diff=lfs merge=lfs -text
2+
*.fbx filter=lfs diff=lfs merge=lfs -text
3+
*.tga filter=lfs diff=lfs merge=lfs -text
4+
*.png filter=lfs diff=lfs merge=lfs -text
5+
*.jpg filter=lfs diff=lfs merge=lfs -text

.gitignore

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
npm/bin/Darwin/FBX2glTF
2-
npm/bin/Linux/FBX2glTF
3-
npm/bin/Windows_NT/FBX2glTF.exe
4-
npm/node_modules/
5-
sdk/
1+
npm/fbx2gltf/bin/Darwin/FBX2glTF
2+
npm/fbx2gltf/bin/Linux/FBX2glTF
3+
npm/fbx2gltf/bin/Windows_NT/FBX2glTF.exe
4+
npm/fbx2gltf/node_modules/
5+
npm/tests/node_modules/
6+
npm/tests/test/*.js
7+
npm/tests/test/*.js.map

npm/LICENSE npm/fbx2gltf/LICENSE

File renamed without changes.

npm/PATENTS npm/fbx2gltf/PATENTS

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

npm/index.js npm/fbx2gltf/index.js

File renamed without changes.

npm/package.json npm/fbx2gltf/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fbx2gltf",
3-
"version": "0.9.5",
3+
"version": "0.9.6",
44
"description": "Node wrapper around FBX2glTF tools.",
55
"main": "index.js",
66
"repository": {

npm/fbx2gltf/yarn.lock

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
balanced-match@^1.0.0:
6+
version "1.0.0"
7+
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
8+
9+
brace-expansion@^1.1.7:
10+
version "1.1.11"
11+
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
12+
dependencies:
13+
balanced-match "^1.0.0"
14+
concat-map "0.0.1"
15+
16+
17+
version "0.0.1"
18+
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
19+
20+
fs.realpath@^1.0.0:
21+
version "1.0.0"
22+
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
23+
24+
glob@^7.0.5:
25+
version "7.1.3"
26+
resolved "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
27+
dependencies:
28+
fs.realpath "^1.0.0"
29+
inflight "^1.0.4"
30+
inherits "2"
31+
minimatch "^3.0.4"
32+
once "^1.3.0"
33+
path-is-absolute "^1.0.0"
34+
35+
inflight@^1.0.4:
36+
version "1.0.6"
37+
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
38+
dependencies:
39+
once "^1.3.0"
40+
wrappy "1"
41+
42+
inherits@2:
43+
version "2.0.3"
44+
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
45+
46+
minimatch@^3.0.4:
47+
version "3.0.4"
48+
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
49+
dependencies:
50+
brace-expansion "^1.1.7"
51+
52+
once@^1.3.0:
53+
version "1.4.0"
54+
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
55+
dependencies:
56+
wrappy "1"
57+
58+
path-is-absolute@^1.0.0:
59+
version "1.0.1"
60+
resolved "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
61+
62+
rimraf@^2.6.2:
63+
version "2.6.2"
64+
resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
65+
dependencies:
66+
glob "^7.0.5"
67+
68+
wrappy@1:
69+
version "1.0.2"
70+
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

npm/tests/.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.ts
2+
!*.d.ts

npm/tests/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:4c2a5e85e167c1b9d91dbfe29a44cad80afab7f95a97f42c69a40dbd573265df
3+
size 68128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:84732464cd4c52e813a6ec7c0b5bff50290a2e8e05b6ecc38c2b98e474eaafcf
3+
size 14302496
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:afcc80ed8ce4a5cd62e5b14fa91c1ae69188211d973dd9a8c0300e21e91d1f8f
3+
size 219872
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:52cb225bad9cc9c74bc80c2c9f15a44cddf738d08e2194df4bd1259b830b17c7
3+
size 1072432
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:a56249c6d7a953f4dac9fd823324ac948c348ae5b306fa020667ee5b8e9c4f2f
3+
size 2295056
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:a5ae59378d0e90957bce9f766e4e5b41212af8ca2835902391b3d31c0181a056
3+
size 564048

npm/tests/models/fromFbxSDK/Box.fbx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:862247f82d91dab7a998c6110775eaed0bd7196368e40f3bf6115f9221bf1875
3+
size 12128
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:b4c6de8e9b23c05bd0bd2c227e9d817deb30efea5779db5afe03752a2869e2cd
3+
size 23180
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:6ce40cb9b86d0bcdfb66a3382a80349b70037d65197906be34eab0db6eb9418c
3+
size 8983744
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:6a783718dd72e3d1acd76b6e41c950ca1f9f04743a4c7f3dd4e571169ff464d4
3+
size 704532
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:03ed8da4f2b5b6a5309fa52b2b700e49215f8ba680789b5f210688615232625b
3+
size 17424
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:36f5082165900ce7c0e53d8638c12aa55ef79d80983b65c024a468d210b4c1ff
3+
size 159532

npm/tests/package.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "fbx2gltf-tests",
3+
"version": "0.9.6",
4+
"description": "Test suite for FBX2glTF",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/facebookincubator/FBX2glTF.git"
9+
},
10+
"contributors": [
11+
"Pär Winzell <[email protected]>",
12+
"Michael Bayne",
13+
"J.M.P. van Waveren",
14+
"Amanda Watson"
15+
],
16+
"license": "BSD-3-Clause",
17+
"bugs": {
18+
"url": "https://github.com/facebookincubator/FBX2glTF/issues"
19+
},
20+
"homepage": "https://github.com/facebookincubator/FBX2glTF",
21+
"scripts": {
22+
"pretest": "tsc",
23+
"test": "mocha",
24+
"watch": "mocha-typescript-watch",
25+
"prepare": "tsc"
26+
},
27+
"dependencies": {
28+
"fbx2gltf": "file:../fbx2gltf",
29+
"gltf-validator": "^2.0.0-dev.2.6",
30+
"tmp": "^0.0.33"
31+
},
32+
"devDependencies": {
33+
"@types/chai": "^4.1.7",
34+
"@types/mocha": "^5.2.5",
35+
"@types/node": "^10.12.12",
36+
"chai": "^4.2.0",
37+
"mocha": "^5.2.0",
38+
"mocha-typescript": "^1.1.17",
39+
"source-map-support": "^0.5.9",
40+
"typescript": "^3.2.2"
41+
}
42+
}

npm/tests/test/fbx2gltf.ts

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { readFileSync } from 'fs';
2+
import * as tmp from 'tmp';
3+
import * as path from 'path';
4+
import * as fbx2gltf from 'fbx2gltf';
5+
import { assert, expect } from 'chai';
6+
import { validateBytes } from 'gltf-validator';
7+
8+
interface Model {
9+
path: string;
10+
ignoredIssues?: Array<string>;
11+
args?: Array<string>;
12+
}
13+
14+
const MODELS :Array<Model> = [
15+
{ path: 'fromFacebook/Jon/jon_morph' },
16+
{
17+
path: 'fromFacebook/Jon/troll-final',
18+
ignoredIssues: [ 'ACCESSOR_NON_UNIT' ],
19+
},
20+
{ path: 'fromFacebook/Natalie/GlitchRobot' },
21+
{ path: 'fromFacebook/Ocean/blackvan/blackvan_with_windows' },
22+
{ path: 'fromFacebook/Ocean/zell_van_vertex_color' },
23+
{ path: 'fromFacebook/RAZ/RAZ_ape' },
24+
{ path: 'fromFbxSDK/Box' },
25+
{
26+
path: 'fromFbxSDK/Humanoid',
27+
ignoredIssues: [ 'UNSUPPORTED_EXTENSION' ],
28+
},
29+
{
30+
path: 'fromFbxSDK/Camera',
31+
ignoredIssues: [ 'UNSUPPORTED_EXTENSION' ],
32+
},
33+
{ path: 'fromFbxSDK/Normals' },
34+
{ path: 'fromGltfSamples/BoxVertexColors/BoxVertexColors' },
35+
{ path: 'fromGltfSamples/WaterBottle/NewWaterBottle' },
36+
];
37+
38+
const CONVERSION_TIMEOUT_MS = 50000;
39+
40+
describe('FBX2glTF', () => {
41+
const tmpobj = tmp.dirSync();
42+
for(let model of MODELS) {
43+
const modelName = path.basename(model.path);
44+
describe('Model: ' + modelName, () => {
45+
const fbxPath = path.join('models', model.path + '.fbx');
46+
let glbBytes;
47+
it('should convert fbx to glb', async () => {
48+
const glbPath = path.join(tmpobj.name, modelName + '.glb');
49+
50+
try {
51+
const destPath = await fbx2gltf(fbxPath, glbPath, model.args || []);
52+
assert.isNotNull(destPath);
53+
glbBytes = readFileSync(destPath);
54+
} catch (err) {
55+
throw new Error('Conversion failed: ' + err);
56+
}
57+
}).timeout(CONVERSION_TIMEOUT_MS);
58+
59+
it('resulting glb should be valid', async() => {
60+
try {
61+
let options = <any>{};
62+
if (model.ignoredIssues) {
63+
options.ignoredIssues = model.ignoredIssues;
64+
}
65+
const report = await validateBytes(glbBytes, options);
66+
expect(report.issues.numErrors).to.equal(0);
67+
expect(report.issues.numWarnings).to.equal(0);
68+
69+
} catch (err) {
70+
throw new Error('Validation failed: ' + err);
71+
}
72+
});
73+
});
74+
}
75+
console.log('GLB files may be inspected in: ' + tmpobj.name);
76+
});

npm/tests/test/mocha.opts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--ui mocha-typescript
2+
--require source-map-support/register
3+
--recursive test

npm/tests/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"module": "commonjs",
5+
"sourceMap": true,
6+
"experimentalDecorators": true,
7+
"lib": [ "es6" ]
8+
}
9+
}

0 commit comments

Comments
 (0)