2016-10-23 10:27:30 -07:00
|
|
|
#!/usr/bin/env ruby
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
2019-10-15 10:30:08 -07:00
|
|
|
#
|
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
2016-11-23 11:12:51 -08:00
|
|
|
|
2017-11-30 06:49:11 -08:00
|
|
|
require 'watir'
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
require 'webdrivers'
|
2016-10-23 10:27:30 -07:00
|
|
|
require 'fileutils'
|
2016-11-23 11:12:51 -08:00
|
|
|
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
browser = Watir::Browser.new(:chrome, options: {
|
|
|
|
"goog:loggingPrefs" => {
|
2021-03-10 13:08:48 -08:00
|
|
|
"browser" => "ALL",
|
|
|
|
"performance" => "ALL"
|
|
|
|
},
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
args: ['--force-device-scale-factor=1', '--window-position=0,0']
|
|
|
|
})
|
2017-11-30 06:49:11 -08:00
|
|
|
|
2016-10-23 10:27:34 -07:00
|
|
|
Dir.chdir(File.dirname($0))
|
2016-11-23 11:12:51 -08:00
|
|
|
|
2016-10-23 10:27:30 -07:00
|
|
|
Dir['fixtures/*.html'].each do |file|
|
|
|
|
fixture = File.read(file)
|
|
|
|
name = File.basename(file, '.*')
|
|
|
|
puts "Generate #{name}"
|
|
|
|
|
|
|
|
ltr_fixture = fixture.gsub('start', 'left')
|
|
|
|
.gsub('end', 'right')
|
|
|
|
.gsub('flex-left', 'flex-start')
|
|
|
|
.gsub('flex-right', 'flex-end')
|
|
|
|
|
|
|
|
rtl_fixture = fixture.gsub('start', 'right')
|
|
|
|
.gsub('end', 'left')
|
|
|
|
.gsub('flex-right', 'flex-start')
|
|
|
|
.gsub('flex-left', 'flex-end')
|
|
|
|
|
|
|
|
template = File.open('test-template.html').read
|
|
|
|
f = File.open('test.html', 'w')
|
2016-11-23 11:12:51 -08:00
|
|
|
f.write sprintf(template, name, ltr_fixture, rtl_fixture, fixture)
|
2016-10-23 10:27:30 -07:00
|
|
|
f.close
|
|
|
|
FileUtils.copy('test.html', "#{name}.html") if $DEBUG
|
|
|
|
|
|
|
|
browser.goto('file://' + Dir.pwd + '/test.html')
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
logs = browser.driver.logs.get(:browser)
|
2016-10-23 10:27:30 -07:00
|
|
|
|
2022-12-28 01:21:52 -08:00
|
|
|
f = File.open("../tests/generated/#{name}.cpp", 'w')
|
2016-10-23 10:27:30 -07:00
|
|
|
f.write eval(logs[0].message.sub(/^[^"]*/, ''))
|
|
|
|
f.close
|
|
|
|
|
2016-12-07 05:12:11 -08:00
|
|
|
f = File.open("../java/tests/com/facebook/yoga/#{name}.java", 'w')
|
2016-12-03 04:40:21 -08:00
|
|
|
f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
2016-10-23 10:27:30 -07:00
|
|
|
f.close
|
|
|
|
|
Remove In-tree C# Bindings (#1302)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1302
These C# bindings were contributed as part of https://github.com/facebook/yoga/commit/ff8f17ac990a9d5b8c1b44dd3fd414b382855b0c. They have occasionally been refreshed, but has never really had validation it built continuously, or dedicated maintenance.
There has been a surge of work with https://github.com/facebook/yoga/pull/1207 to try to modernize the build for these, but checking with jkoritzinsky I'm not sure either of us have the time to commit to supporting these at the same level as other bindings.
Some well-known projects like Unity had already abandoned this set of bindings for their own. https://github.com/Unity-Technologies/UnityCsReference/commit/016297e35ce1bf35a2c411f87fe0d6362cad54c3#diff-c85198aaac9095a5446ed00b0fba8025072d235b2b69dea8aad85abc64a83e1e
So, as part of the work for an official OSS release, and really trying to define what is deprecated, and what we will try to support, I am removing the in-tree C# bindings from Yoga.
In the past, gaps in Yoga bindings we haven't supported have led to new bindings with dedicated maintainers e.g. [FlexLayout](https://github.com/layoutBox/FlexLayout), [yoga-rs](https://github.com/bschwind/yoga-rs), [yoga-wasm-web](https://github.com/shuding/yoga-wasm-web). My hope is that by removing the C# bindings that we are not supporting, we free up the opportunity for a new version to become the defacto.
Reviewed By: javache
Differential Revision: D46425886
fbshipit-source-id: df964c4d55adf93c4d1e82c104e74ca5ad181612
2023-06-05 10:48:10 -07:00
|
|
|
print logs[3]
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
f = File.open("../javascript/tests/generated/#{name}.test.ts", 'w')
|
Remove In-tree C# Bindings (#1302)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1302
These C# bindings were contributed as part of https://github.com/facebook/yoga/commit/ff8f17ac990a9d5b8c1b44dd3fd414b382855b0c. They have occasionally been refreshed, but has never really had validation it built continuously, or dedicated maintenance.
There has been a surge of work with https://github.com/facebook/yoga/pull/1207 to try to modernize the build for these, but checking with jkoritzinsky I'm not sure either of us have the time to commit to supporting these at the same level as other bindings.
Some well-known projects like Unity had already abandoned this set of bindings for their own. https://github.com/Unity-Technologies/UnityCsReference/commit/016297e35ce1bf35a2c411f87fe0d6362cad54c3#diff-c85198aaac9095a5446ed00b0fba8025072d235b2b69dea8aad85abc64a83e1e
So, as part of the work for an official OSS release, and really trying to define what is deprecated, and what we will try to support, I am removing the in-tree C# bindings from Yoga.
In the past, gaps in Yoga bindings we haven't supported have led to new bindings with dedicated maintainers e.g. [FlexLayout](https://github.com/layoutBox/FlexLayout), [yoga-rs](https://github.com/bschwind/yoga-rs), [yoga-wasm-web](https://github.com/shuding/yoga-wasm-web). My hope is that by removing the C# bindings that we are not supporting, we free up the opportunity for a new version to become the defacto.
Reviewed By: javache
Differential Revision: D46425886
fbshipit-source-id: df964c4d55adf93c4d1e82c104e74ca5ad181612
2023-06-05 10:48:10 -07:00
|
|
|
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
2017-01-02 02:22:45 -08:00
|
|
|
f.close
|
2016-10-23 10:27:30 -07:00
|
|
|
end
|
|
|
|
File.delete('test.html')
|
|
|
|
browser.close
|