From f55eb8bb64c83f40dcae5a36edf798c3265f5540 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Sat, 17 Oct 2015 16:07:55 +0800 Subject: [PATCH] Update tests. --- .travis.yml | 8 ++++-- package.json | 3 ++ {tests => test}/Gemfile | 7 +++-- {tests => test}/README.md | 0 {tests => test}/Rakefile | 6 ++-- {tests => test}/config.rb | 0 {tests => test}/controls/font.css | 0 {tests => test}/controls/ie10.css | 0 {tests => test}/controls/ie11.css | 0 {tests => test}/controls/ie6.css | 0 {tests => test}/controls/ie7.css | 0 {tests => test}/controls/ie8.css | 0 {tests => test}/controls/ie9.css | 0 {tests => test}/controls/indent-amount.css | 0 {tests => test}/controls/safari6.css | 0 {tests => test}/controls/safari7.css | 0 .../controls/strict-normalize-false.css | 0 .../controls/strict-normalize-true.css | 0 {tests => test}/tests/font.scss | 0 {tests => test}/tests/ie10.scss | 0 {tests => test}/tests/ie11.scss | 0 {tests => test}/tests/ie6.scss | 0 {tests => test}/tests/ie7.scss | 0 {tests => test}/tests/ie8.scss | 0 {tests => test}/tests/ie9.scss | 0 {tests => test}/tests/indent-amount.scss | 0 {tests => test}/tests/safari6.scss | 0 {tests => test}/tests/safari7.scss | 0 .../tests/strict-normalize-false.scss | 0 .../tests/strict-normalize-true.scss | 0 {tests => test}/unit_tests.rb | 28 +++++++++---------- 31 files changed, 30 insertions(+), 22 deletions(-) rename {tests => test}/Gemfile (51%) rename {tests => test}/README.md (100%) rename {tests => test}/Rakefile (84%) rename {tests => test}/config.rb (100%) rename {tests => test}/controls/font.css (100%) rename {tests => test}/controls/ie10.css (100%) rename {tests => test}/controls/ie11.css (100%) rename {tests => test}/controls/ie6.css (100%) rename {tests => test}/controls/ie7.css (100%) rename {tests => test}/controls/ie8.css (100%) rename {tests => test}/controls/ie9.css (100%) rename {tests => test}/controls/indent-amount.css (100%) rename {tests => test}/controls/safari6.css (100%) rename {tests => test}/controls/safari7.css (100%) rename {tests => test}/controls/strict-normalize-false.css (100%) rename {tests => test}/controls/strict-normalize-true.css (100%) rename {tests => test}/tests/font.scss (100%) rename {tests => test}/tests/ie10.scss (100%) rename {tests => test}/tests/ie11.scss (100%) rename {tests => test}/tests/ie6.scss (100%) rename {tests => test}/tests/ie7.scss (100%) rename {tests => test}/tests/ie8.scss (100%) rename {tests => test}/tests/ie9.scss (100%) rename {tests => test}/tests/indent-amount.scss (100%) rename {tests => test}/tests/safari6.scss (100%) rename {tests => test}/tests/safari7.scss (100%) rename {tests => test}/tests/strict-normalize-false.scss (100%) rename {tests => test}/tests/strict-normalize-true.scss (100%) rename {tests => test}/unit_tests.rb (53%) diff --git a/.travis.yml b/.travis.yml index 9c4caca08..e33432493 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,16 @@ +# Configuration options are documented at: +# http://about.travis-ci.org/docs/user/languages/ruby/ language: ruby bundler_args: --without development rvm: - 1.9.3 - 2.0.0 + - 2.1.2 + - 2.2.1 gemfile: - - tests/Gemfile + - test/Gemfile branches: only: - master - 2.x -script: cd tests; bundle exec rake +script: cd test; bundle exec rake diff --git a/package.json b/package.json index ad3717c3f..5efbb130e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "Nicolas Gallagher", "John Albin Wilkins" ], + "scripts": { + "test": "cd test; bundle exec rake" + }, "license": [ "MIT", "GPLv2" diff --git a/tests/Gemfile b/test/Gemfile similarity index 51% rename from tests/Gemfile rename to test/Gemfile index 6942c4328..29d85c6d1 100644 --- a/tests/Gemfile +++ b/test/Gemfile @@ -1,11 +1,12 @@ # Pull gems from RubyGems source 'https://rubygems.org' -gem 'sass', ">= 3.3.0" -gem 'compass', ">= 1.0.0" +gem 'sass', "~> 3.3" +gem 'compass', "~> 1.0" group :test do gem 'rake' - gem "diffy", "~> 3.0.1" + gem "diffy", "~> 3.0.1" gem "colorize", "~> 0.6.0" + gem 'minitest', "~> 5.6" end diff --git a/tests/README.md b/test/README.md similarity index 100% rename from tests/README.md rename to test/README.md diff --git a/tests/Rakefile b/test/Rakefile similarity index 84% rename from tests/Rakefile rename to test/Rakefile index 4603d5d26..e1adcf045 100644 --- a/tests/Rakefile +++ b/test/Rakefile @@ -14,12 +14,12 @@ end desc 'Compile baseline CSS' task :compile do require 'compass' - require 'compass/sass_compiler' + require 'compass/exec' Compass.add_configuration 'config.rb' Compass.configuration.project_path = Dir.pwd # Compile into baseline directory instead of test output directory Compass.configuration.css_dir = 'controls' - Compass.sass_compiler.clean! - Compass.sass_compiler.compile! + Compass.compiler.clean! + Compass.compiler.run end diff --git a/tests/config.rb b/test/config.rb similarity index 100% rename from tests/config.rb rename to test/config.rb diff --git a/tests/controls/font.css b/test/controls/font.css similarity index 100% rename from tests/controls/font.css rename to test/controls/font.css diff --git a/tests/controls/ie10.css b/test/controls/ie10.css similarity index 100% rename from tests/controls/ie10.css rename to test/controls/ie10.css diff --git a/tests/controls/ie11.css b/test/controls/ie11.css similarity index 100% rename from tests/controls/ie11.css rename to test/controls/ie11.css diff --git a/tests/controls/ie6.css b/test/controls/ie6.css similarity index 100% rename from tests/controls/ie6.css rename to test/controls/ie6.css diff --git a/tests/controls/ie7.css b/test/controls/ie7.css similarity index 100% rename from tests/controls/ie7.css rename to test/controls/ie7.css diff --git a/tests/controls/ie8.css b/test/controls/ie8.css similarity index 100% rename from tests/controls/ie8.css rename to test/controls/ie8.css diff --git a/tests/controls/ie9.css b/test/controls/ie9.css similarity index 100% rename from tests/controls/ie9.css rename to test/controls/ie9.css diff --git a/tests/controls/indent-amount.css b/test/controls/indent-amount.css similarity index 100% rename from tests/controls/indent-amount.css rename to test/controls/indent-amount.css diff --git a/tests/controls/safari6.css b/test/controls/safari6.css similarity index 100% rename from tests/controls/safari6.css rename to test/controls/safari6.css diff --git a/tests/controls/safari7.css b/test/controls/safari7.css similarity index 100% rename from tests/controls/safari7.css rename to test/controls/safari7.css diff --git a/tests/controls/strict-normalize-false.css b/test/controls/strict-normalize-false.css similarity index 100% rename from tests/controls/strict-normalize-false.css rename to test/controls/strict-normalize-false.css diff --git a/tests/controls/strict-normalize-true.css b/test/controls/strict-normalize-true.css similarity index 100% rename from tests/controls/strict-normalize-true.css rename to test/controls/strict-normalize-true.css diff --git a/tests/tests/font.scss b/test/tests/font.scss similarity index 100% rename from tests/tests/font.scss rename to test/tests/font.scss diff --git a/tests/tests/ie10.scss b/test/tests/ie10.scss similarity index 100% rename from tests/tests/ie10.scss rename to test/tests/ie10.scss diff --git a/tests/tests/ie11.scss b/test/tests/ie11.scss similarity index 100% rename from tests/tests/ie11.scss rename to test/tests/ie11.scss diff --git a/tests/tests/ie6.scss b/test/tests/ie6.scss similarity index 100% rename from tests/tests/ie6.scss rename to test/tests/ie6.scss diff --git a/tests/tests/ie7.scss b/test/tests/ie7.scss similarity index 100% rename from tests/tests/ie7.scss rename to test/tests/ie7.scss diff --git a/tests/tests/ie8.scss b/test/tests/ie8.scss similarity index 100% rename from tests/tests/ie8.scss rename to test/tests/ie8.scss diff --git a/tests/tests/ie9.scss b/test/tests/ie9.scss similarity index 100% rename from tests/tests/ie9.scss rename to test/tests/ie9.scss diff --git a/tests/tests/indent-amount.scss b/test/tests/indent-amount.scss similarity index 100% rename from tests/tests/indent-amount.scss rename to test/tests/indent-amount.scss diff --git a/tests/tests/safari6.scss b/test/tests/safari6.scss similarity index 100% rename from tests/tests/safari6.scss rename to test/tests/safari6.scss diff --git a/tests/tests/safari7.scss b/test/tests/safari7.scss similarity index 100% rename from tests/tests/safari7.scss rename to test/tests/safari7.scss diff --git a/tests/tests/strict-normalize-false.scss b/test/tests/strict-normalize-false.scss similarity index 100% rename from tests/tests/strict-normalize-false.scss rename to test/tests/strict-normalize-false.scss diff --git a/tests/tests/strict-normalize-true.scss b/test/tests/strict-normalize-true.scss similarity index 100% rename from tests/tests/strict-normalize-true.scss rename to test/tests/strict-normalize-true.scss diff --git a/tests/unit_tests.rb b/test/unit_tests.rb similarity index 53% rename from tests/unit_tests.rb rename to test/unit_tests.rb index 81ee6465a..e2e13f0a5 100644 --- a/tests/unit_tests.rb +++ b/test/unit_tests.rb @@ -2,12 +2,12 @@ require 'compass' require 'compass/exec' -require 'test/unit' +require 'minitest/autorun' require 'diffy' require 'colorize' require 'pathname' -class TestCompassOutput < Test::Unit::TestCase +class TestCompassOutput < Minitest::Test Compass.add_configuration 'config.rb' Compass.configuration.project_path = Dir.pwd @@ -20,35 +20,35 @@ class TestCompassOutput < Test::Unit::TestCase define_method "test_#{test_name}_compile " do # Compiled CSS file path - test_file_pwd = Compass.compiler.corresponding_css_file(sass_file) + css_file = Compass.compiler.corresponding_css_file(sass_file) # Relative path of compiled CSS file from Tests directory - relative_pwd = Pathname.new(test_file_pwd).relative_path_from(Pathname.new("#{Dir.pwd}/output")).to_s + css_file_relative = Pathname.new(css_file).relative_path_from(Pathname.new("#{Dir.pwd}/output")).to_s # Control files path - control_file_pwd = "#{Dir.pwd}/controls/" + relative_pwd + control_file = "#{Dir.pwd}/controls/" + css_file_relative # The base path of the sub folders, making the folders if needed - base_pwd = relative_pwd.sub(File.basename(relative_pwd), '') - FileUtils.mkdir_p "#{Dir.pwd}/output/#{base_pwd}" + base_dir = File.dirname(css_file_relative) + FileUtils.mkdir_p "#{Dir.pwd}/output/#{base_dir}" # Compiles Sass file - Compass.compiler.compile sass_file, test_file_pwd # Raises exception upon error + Compass.compiler.compile sass_file, css_file # Raises exception upon error begin # Assert that our test output matches our control output - passed = assert FileUtils.compare_file(test_file_pwd, control_file_pwd), "Compiled output for #{File.basename(sass_file)} does not match control output!".red + passed = assert FileUtils.compare_file(css_file, control_file), "Compiled output for #{File.basename(sass_file)} does not match control output!".red ensure # If there is a failure, generate a diff of the files and put it with the compiled file if !passed - test_file = File.open(test_file_pwd).read; - control_file = File.open(control_file_pwd).read; - diff_pwd = "#{Dir.pwd}/output/#{relative_pwd}.diff" + test_file = File.open(css_file).read; + control_file = File.open(control_file).read; + diff_file = "#{css_file}.diff" diff_content = Diffy::Diff.new(control_file, test_file, :include_diff_info => true) - File.open(diff_pwd, 'w') { |f| f.write(diff_content.to_s(:text)) } + File.open(diff_file, 'w') { |f| f.write(diff_content.to_s(:text)) } - puts "Control->Compiled diff output to ".yellow + "tests/output/#{relative_pwd}.diff".blue + puts "Control->Compiled diff output to ".yellow + "output/#{css_file_relative}.diff".blue end end end