gentest for Java and C#
Summary: - Revise scripts to generate Java and C# unittests using the same HTML fixtures as well as C for code coverage. - Add wrap_column test workaround in gentest.js. - Add checkDefaultValues for sanity check of the CSSLayout default values by test-template.html - Add `align-content: flex-start;` in default div to align with CSSLayout default $ cd csharp/gentest $ ruby gentest.rb - macOS example for C# $ cd csharp/tests/Facebook.CSSLayout $ clang -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -g -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp $ mcs -debug -t:library -r:nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs $ mono64 --debug nunit-console.exe CSSLayoutTest.dll Reviewed By: emilsjolander Differential Revision: D4053777 fbshipit-source-id: 84450208015e65baf604987bd56c6a268598b545
This commit is contained in:
committed by
Facebook Github Bot
parent
1488f822c3
commit
dc5e613285
44
gentest/gentest.rb
Normal file
44
gentest/gentest.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'watir-webdriver'
|
||||
require 'fileutils'
|
||||
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
"loggingPrefs"=>{"browser"=>"ALL", "performance"=>"ALL"})
|
||||
browser = Watir::Browser.new(:chrome, :desired_capabilities => caps)
|
||||
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')
|
||||
f.write sprintf(template, ltr_fixture, rtl_fixture, fixture)
|
||||
f.close
|
||||
FileUtils.copy('test.html', "#{name}.html") if $DEBUG
|
||||
|
||||
browser.goto('file://' + Dir.pwd + '/test.html')
|
||||
logs = browser.driver.manage.logs.get(:browser)
|
||||
|
||||
f = File.open("../tests/#{name}.cpp", 'w')
|
||||
f.write eval(logs[0].message.sub(/^[^"]*/, ''))
|
||||
f.close
|
||||
|
||||
f = File.open("../java/tests/com/facebook/csslayout/#{name}.java", 'w')
|
||||
f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('CSSNodeLayoutTest', name)
|
||||
f.close
|
||||
|
||||
f = File.open("../csharp/tests/Facebook.CSSLayout/#{name}.cs", 'w')
|
||||
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('CSSNodeLayoutTest', name)
|
||||
f.close
|
||||
end
|
||||
File.delete('test.html')
|
||||
browser.close
|
Reference in New Issue
Block a user