Iterate on test setup

This commit is contained in:
Nick Gerleman
2022-12-24 00:25:02 -08:00
parent 0a82167c30
commit 0f67a0a458
38 changed files with 36 additions and 61 deletions

View File

@@ -56,7 +56,7 @@ Dir['fixtures/*.html'].each do |file|
print logs[4] print logs[4]
f = File.open("../javascript/tests/Facebook.Yoga/#{name}.js", 'w') f = File.open("../javascript/tests/generated/#{name}.test.js", 'w')
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name) f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close f.close
end end

View File

@@ -37,7 +37,12 @@ import { loadYoga } from "yoga-layout/entrypoint/wasm-async";
## Contributing ## Contributing
`yoga-layout` may be locally built by running the following set of commands. The build requires that some dependencies be installed first. ### Requirements
1. CMake >= 3.13
1. (Optional) ninja, for faster builds
### Building
```bash ```bash
git clone https://github.com/facebook/yoga.git git clone https://github.com/facebook/yoga.git
@@ -46,7 +51,12 @@ yarn install
yarn build yarn build
``` ```
### Requirements ### Testing
1. CMake >= 3.13 ```bash
1. (Optional) ninja, for faster builds # Build and test all entrypoints
yarn test
# Build and test a specific entrypoint
yarn test:asmjs-sync
```

View File

@@ -9,6 +9,6 @@
module.exports = { module.exports = {
setupFiles: ["./jest.setup.js", "./tests/tools.js"], setupFiles: ["./jest.setup.js", "./tests/tools.js"],
testRegex: '/tests/Facebook.Yoga/.*\\.js$', testRegex: '/tests/.*\\.test\\.js$',
watchman: false, watchman: false,
} }

View File

@@ -26,17 +26,17 @@
"src_js/**" "src_js/**"
], ],
"scripts": { "scripts": {
"benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')", "benchmark": "yarn build && node tests/run-bench $(find tests/benchmarks -name '*.js')",
"build": "yarn build:native && yarn build:js", "build": "yarn build:js && yarn build:native",
"build:configure": "which ninja && emcmake cmake -S . -B build -G Ninja || emcmake cmake -S . -B build", "build:configure": "which ninja && emcmake cmake -S . -B build -G Ninja || emcmake cmake -S . -B build",
"build:copy-dts": "cd src_js && find . -name '*.d.ts' | cpio -pdm ../dist", "build:copy-dts": "cd src_js && find . -name '*.d.ts' | cpio -pdm ../dist",
"build:js": "babel src_js --source-maps --out-dir dist && yarn build:copy-dts", "build:js": "babel src_js --source-maps --out-dir dist && yarn build:copy-dts",
"build:native": "yarn build:configure && cmake --build build", "build:native": "yarn build:configure && cmake --build build",
"test": "yarn test:asmjs && yarn test:asmjs-sync && yarn test:wasm && yarn test:wasm-sync", "test": "yarn test:asmjs-async && yarn test:asmjs-sync && yarn test:wasm-async && yarn test:wasm-sync",
"test:asmjs": "WASM=0 SYNC=0 jest", "test:asmjs-async": "yarn build --target asmjs-async && WASM=0 SYNC=0 jest",
"test:asmjs-sync": "WASM=0 SYNC=1 jest", "test:asmjs-sync": "yarn build --target asmjs-sync && WASM=0 SYNC=1 jest",
"test:wasm": "WASM=1 SYNC=0 jest", "test:wasm-async": "yarn build --target wasm-async && WASM=1 SYNC=0 jest",
"test:wasm-sync": "WASM=1 SYNC=1 jest" "test:wasm-sync": "yarn build --target wasm-sync && WASM=1 SYNC=1 jest"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.20.7", "@babel/cli": "^7.20.7",

View File

@@ -7,9 +7,9 @@
* @format * @format
*/ */
const wrapAsm = require('./wrapAsm'); const wrapAsm = require('../wrapAsm');
module.exports = (loadAsm) => ({ module.exports = (loadAsm) => ({
loadYoga: () => loadAsm().then(wrapAsm), loadYoga: () => loadAsm().then(wrapAsm),
...require('./generated/YGEnums'), ...require('../generated/YGEnums'),
}); });

View File

@@ -7,5 +7,5 @@
* @format * @format
*/ */
const wrapAsm = require('./wrapAsm'); const wrapAsm = require('../wrapAsm');
module.exports = (asm) => wrapAsm(asm()); module.exports = (asm) => wrapAsm(asm());

View File

@@ -8,4 +8,4 @@
*/ */
const asm = require('../build/asmjs-async'); const asm = require('../build/asmjs-async');
module.exports = require("./entryAsync")(asm); module.exports = require("./_entryAsync")(asm);

View File

@@ -8,4 +8,4 @@
*/ */
const asm = require('../build/asmjs-sync'); const asm = require('../build/asmjs-sync');
module.exports = require("./entrySync")(asm); module.exports = require("./_entrySync")(asm);

View File

@@ -8,4 +8,4 @@
*/ */
const asm = require('../build/wasm-async'); const asm = require('../build/wasm-async');
module.exports = require("./entryAsync")(asm); module.exports = require("./_entryAsync")(asm);

View File

@@ -8,4 +8,4 @@
*/ */
const asm = require('../build/wasm-sync'); const asm = require('../build/wasm-sync');
module.exports = require("./entrySync")(asm); module.exports = require("./_entrySync")(asm);

View File

@@ -5,9 +5,8 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
var Yoga = Yoga || require("../../dist/entry-" + process.env.TEST_ENTRY); const ITERATIONS = 2000;
const YGBENCHMARK = global.YGBENCHMARK ?? global.test;
var ITERATIONS = 2000;
YGBENCHMARK("Stack with flex", function() { YGBENCHMARK("Stack with flex", function() {
var root = Yoga.Node.create(); var root = Yoga.Node.create();

View File

@@ -1361,7 +1361,7 @@ it("align_baseline_multiline_column", function () {
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(70 === root_child1.getComputedLeft(), "70 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(30 === root_child1.getComputedWidth(), "30 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); console.assert(30 === root_child1.getComputedWidth(), "30 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
@@ -1371,7 +1371,7 @@ it("align_baseline_multiline_column", function () {
console.assert(20 === root_child1_child0.getComputedWidth(), "20 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")"); console.assert(20 === root_child1_child0.getComputedWidth(), "20 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
console.assert(20 === root_child1_child0.getComputedHeight(), "20 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")"); console.assert(20 === root_child1_child0.getComputedHeight(), "20 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
console.assert(10 === root_child2.getComputedLeft(), "10 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
console.assert(40 === root_child2.getComputedWidth(), "40 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); console.assert(40 === root_child2.getComputedWidth(), "40 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
console.assert(70 === root_child2.getComputedHeight(), "70 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); console.assert(70 === root_child2.getComputedHeight(), "70 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
@@ -1481,7 +1481,7 @@ it("align_baseline_multiline_column2", function () {
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(70 === root_child1.getComputedLeft(), "70 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(30 === root_child1.getComputedWidth(), "30 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); console.assert(30 === root_child1.getComputedWidth(), "30 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
@@ -1491,7 +1491,7 @@ it("align_baseline_multiline_column2", function () {
console.assert(20 === root_child1_child0.getComputedWidth(), "20 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")"); console.assert(20 === root_child1_child0.getComputedWidth(), "20 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
console.assert(20 === root_child1_child0.getComputedHeight(), "20 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")"); console.assert(20 === root_child1_child0.getComputedHeight(), "20 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
console.assert(10 === root_child2.getComputedLeft(), "10 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
console.assert(40 === root_child2.getComputedWidth(), "40 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); console.assert(40 === root_child2.getComputedWidth(), "40 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
console.assert(70 === root_child2.getComputedHeight(), "70 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); console.assert(70 === root_child2.getComputedHeight(), "70 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");

View File

@@ -1,34 +0,0 @@
<html>
<script>
function it(name, func) {
console.log(name);
func();
}
function YGBENCHMARK(name, func) {
console.log(name);
func();
}
</script>
<script src="../dist/Yoga.bundle.js"></script>
<script src="./tools.js"></script>
<script src="./Facebook.Yoga/YGAbsolutePositionTest.js"></script>
<script src="./Facebook.Yoga/YGAlignContentTest.js"></script>
<script src="./Facebook.Yoga/YGAlignItemsTest.js"></script>
<script src="./Facebook.Yoga/YGAlignSelfTest.js"></script>
<script src="./Facebook.Yoga/YGBorderTest.js"></script>
<script src="./Facebook.Yoga/YGFlexDirectionTest.js"></script>
<script src="./Facebook.Yoga/YGFlexTest.js"></script>
<script src="./Facebook.Yoga/YGFlexWrapTest.js"></script>
<script src="./Facebook.Yoga/YGJustifyContentTest.js"></script>
<script src="./Facebook.Yoga/YGMarginTest.js"></script>
<script src="./Facebook.Yoga/YGMinMaxDimensionTest.js"></script>
<script src="./Facebook.Yoga/YGPaddingTest.js"></script>
<script src="./Facebook.Yoga/YGRoundingTest.js"></script>
<script src="./Benchmarks/YGBenchmark.js"></script>
</html>