sanity: initial rewrite of sanity testing
parent
56d8cff626
commit
61afecd95d
4
Rakefile
4
Rakefile
|
|
@ -40,8 +40,8 @@ end
|
||||||
|
|
||||||
desc 'Run sanity tests without a full rebuild'
|
desc 'Run sanity tests without a full rebuild'
|
||||||
task :sanity_only do
|
task :sanity_only do
|
||||||
require_relative 'spec/samples/sanity.rb'
|
require_relative 'spec/sanity/sanity_test.rb'
|
||||||
Sanity.new.run
|
SanityTest.new.run
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Run full rebuild with sanity tests'
|
desc 'Run full rebuild with sanity tests'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
sanity.html
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<title>Diff with CSS Example</title>
|
||||||
|
<style>
|
||||||
|
body{
|
||||||
|
/*background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAHElEQVQYlWO4ePFiAzGY4eLFiw0MxIBRhVRRCADsljgKUbBKPgAAAABJRU5ErkJggg==) repeat;*/
|
||||||
|
}
|
||||||
|
img{
|
||||||
|
height: 6in;
|
||||||
|
}
|
||||||
|
.diff {
|
||||||
|
width: 4in;
|
||||||
|
height: 6in;
|
||||||
|
background-repeat: none, none;
|
||||||
|
background-size: contain, contain;
|
||||||
|
background-blend-mode: difference;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<% images.each_with_index do |(expected, actual), i| %>
|
||||||
|
|
||||||
|
<img src="<%= expected %>"/>
|
||||||
|
<img src="<%= actual %>"/>
|
||||||
|
<style>
|
||||||
|
.mine<%= i %> {
|
||||||
|
background-image: url(<%= expected %>), url(<%= actual %>);"
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="diff mine<%= i %>"/>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
require 'launchy'
|
||||||
|
require 'erb'
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
# An pixel-by-pixel comparison of sample images for visual regression testing
|
||||||
|
class SanityTest
|
||||||
|
|
||||||
|
@@ERB = "#{File.expand_path(File.dirname(__FILE__))}/sanity.html.erb"
|
||||||
|
@@HTML = "#{File.expand_path(File.dirname(__FILE__))}/sanity.html"
|
||||||
|
@@COMPARES = "#{File.expand_path(File.dirname(__FILE__))}/tests.yml"
|
||||||
|
@@SAMPLES = "file:///#{File.expand_path("samples/")}"
|
||||||
|
|
||||||
|
def images
|
||||||
|
require 'pp'
|
||||||
|
comps = YAML.load_file(@@COMPARES)
|
||||||
|
pp comps
|
||||||
|
comps.each do | test, data |
|
||||||
|
pp data
|
||||||
|
end
|
||||||
|
[
|
||||||
|
["#{@@SAMPLES}/images/_images_00_expected.png", "#{@@SAMPLES}/images/_images_00.png"]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
puts @@SAMPLES
|
||||||
|
puts 'Building sanity test...'
|
||||||
|
process_erb(File.read(@@ERB))
|
||||||
|
Launchy.open('file:///' + @@HTML)
|
||||||
|
puts 'Done.'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def process_erb(sanity_template)
|
||||||
|
renderer = ERB.new(sanity_template)
|
||||||
|
File.open(@@HTML, 'w+') do |html|
|
||||||
|
html.write(renderer.result(binding))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
images:
|
||||||
|
dir: images
|
||||||
|
expected: _images_00_expected.png
|
||||||
|
actual: _images_00.png
|
||||||
|
text:
|
||||||
|
dir: text
|
||||||
|
expected: _text_00_expected.png
|
||||||
|
actual: _text_00.png
|
||||||
|
autoscale_font:
|
||||||
|
dir: autoscale_font
|
||||||
|
expected: card_00_expected.png
|
||||||
|
actual: card_00.png
|
||||||
Loading…
Reference in New Issue