Skip to content

Commit 029cfa6

Browse files
authored
Merge pull request #47 from mamaar/gentest
Automatically generated tests
2 parents d918578 + 21b0139 commit 029cfa6

Some content is hidden

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

52 files changed

+13806
-18843
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "src/yoga"]
2+
path = src/yoga
3+
url = https://github.com/facebook/yoga.git
4+
checkout = 1.10.0

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,29 @@ fn main() {
6060
}
6161
```
6262

63-
Yoga Version
64-
------------
63+
Testing
64+
-------
65+
The unit tests are automatically generated based on upstream fixtures and should not be edited manually.
66+
67+
```
68+
$ cargo test
69+
```
70+
71+
To generate the test cases:
72+
Download the [ChromeDriver](http://chromedriver.chromium.org) binary and put it somewhere in your `$PATH`. Linux/MacOS example:
73+
74+
```
75+
$ cp chromedriver /usr/local/bin
76+
```
6577

66-
[c5f826de8306e5fbe5963f944c75add827e096c3](https://github.com/facebook/yoga/tree/c5f826de8306e5fbe5963f944c75add827e096c3/yoga)
78+
Install the required Ruby gem.
79+
80+
```
81+
$ sudo gem install watir
82+
```
83+
84+
Generate the tests.
85+
86+
```
87+
$ ruby gentest/gentest.rb
88+
```

build.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@ use bindgen::RustTarget;
55
use cc::Build;
66
use std::env;
77
use std::path::PathBuf;
8+
use std::process::Command;
89

910
fn main() {
11+
Command::new("git")
12+
.args(&["submodule", "init"])
13+
.status()
14+
.expect("Unable to initialize git submodules");
15+
Command::new("git")
16+
.args(&["submodule", "update"])
17+
.status()
18+
.expect("Unable to update the submodule repositories");
19+
1020
Build::new()
1121
.cpp(true)
1222
// https://github.com/facebook/yoga/blob/c5f826de8306e5fbe5963f944c75add827e096c3/BUCK#L13
@@ -20,15 +30,15 @@ fn main() {
2030
// https://github.com/facebook/yoga/blob/c5f826de8306e5fbe5963f944c75add827e096c3/yoga_defs.bzl#L58-L60
2131
.flag("-fPIC")
2232
// C++ Files
23-
.file("src/c/Utils.cpp")
24-
.file("src/c/YGConfig.cpp")
25-
.file("src/c/YGEnums.cpp")
26-
.file("src/c/YGFloatOptional.cpp")
27-
.file("src/c/YGLayout.cpp")
28-
.file("src/c/YGNode.cpp")
29-
.file("src/c/YGNodePrint.cpp")
30-
.file("src/c/YGStyle.cpp")
31-
.file("src/c/Yoga.cpp")
33+
.file("src/yoga/yoga/Utils.cpp")
34+
.file("src/yoga/yoga/YGConfig.cpp")
35+
.file("src/yoga/yoga/YGEnums.cpp")
36+
.file("src/yoga/yoga/YGFloatOptional.cpp")
37+
.file("src/yoga/yoga/YGLayout.cpp")
38+
.file("src/yoga/yoga/YGNode.cpp")
39+
.file("src/yoga/yoga/YGNodePrint.cpp")
40+
.file("src/yoga/yoga/YGStyle.cpp")
41+
.file("src/yoga/yoga/Yoga.cpp")
3242
.compile("libyoga.a");
3343

3444
let bindings = bindgen::Builder::default()
@@ -41,7 +51,7 @@ fn main() {
4151
.layout_tests(false)
4252
.rustfmt_bindings(false)
4353
.rustified_enum("YG.*")
44-
.header("src/c/wrapper.h")
54+
.header("src/yoga/yoga/Yoga.h")
4555
.generate()
4656
.expect("Unable to generate bindings");
4757

src/c/LICENSE renamed to gentest/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2014-present, Facebook, Inc.
3+
Copyright (c) Facebook, Inc. and its affiliates.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)