diff options
author | 2015-06-24 19:07:00 +0100 | |
---|---|---|
committer | 2015-06-24 19:07:00 +0100 | |
commit | 95d97fa4b708db8186a7f13cc96c7929ce5277f6 (patch) | |
tree | 177441eb04590628d3bba14637080d1bf04d0233 | |
parent | Run tests using travis (diff) | |
download | ruby-tinderbox-95d97fa4b708db8186a7f13cc96c7929ce5277f6.tar.gz ruby-tinderbox-95d97fa4b708db8186a7f13cc96c7929ce5277f6.tar.bz2 ruby-tinderbox-95d97fa4b708db8186a7f13cc96c7929ce5277f6.zip |
Add seed data for running tests in dev environment
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | web/Rakefile | 21 | ||||
-rw-r--r-- | web/lib/ci.rb | 10 | ||||
-rw-r--r-- | web/test/minitest_helper.rb | 21 | ||||
-rw-r--r-- | web/test/test-logs/.gitignore | 2 | ||||
-rw-r--r-- | web/test/test_build_status.rb | 11 | ||||
-rw-r--r-- | web/test/test_outdated_gems.rb | 10 | ||||
-rw-r--r-- | web/test/test_repoman_checks.rb | 2 | ||||
-rw-r--r-- | web/test/test_ruby_targets.rb | 12 | ||||
-rw-r--r-- | web/test/test_visualizations.rb | 2 |
10 files changed, 77 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml index 7bfa2db..13f6d87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ install: - sudo pip install pylint script: - bundle exec rake db:migrate - - bundle exec rake test + - bundle exec rake diff --git a/web/Rakefile b/web/Rakefile index e6ab09c..3c9225a 100644 --- a/web/Rakefile +++ b/web/Rakefile @@ -1,17 +1,26 @@ require_relative 'app' -task default: 'test' +task default: 'lint_and_test' -desc 'Run the test suite' +desc 'Run tests' task :test do + puts "\nMINITEST:" + Dir.glob('./test/test_*.rb') { |f| require f } +end + +desc 'Run linters' +task :lint do puts "RUBOCOP:\n" sh 'bundle exec rubocop' puts "\nSHELLCHECK:\n" sh "shellcheck --exclude=SC2016 #{Dir.glob('../**/*.sh').join(' ')}" puts "\nPYLINT:\n" sh "pylint --rcfile=.pylintrc #{Dir.glob('../**/*.py').join(' ')}" - puts "\nMINITEST:" - Dir.glob('./test/test_*.rb') { |f| require f } +end + +task :lint_and_test do + Rake::Task['lint'].invoke + Rake::Task['test'].invoke end namespace :db do @@ -27,7 +36,7 @@ namespace :db do desc 'Update the build database with logfiles from ci-logs/' task :update_build do - update_build + update_build('ci-logs/*/*/builds/*') end desc 'Clear the build database' @@ -37,7 +46,7 @@ namespace :db do desc 'Update the repoman database with logfiles from repo-logs/' task :update_repoman do - update_repoman + update_repoman('ci-logs/*/*/repomans/*') end desc 'Clear the repoman database' diff --git a/web/lib/ci.rb b/web/lib/ci.rb index c3839c9..2388160 100644 --- a/web/lib/ci.rb +++ b/web/lib/ci.rb @@ -93,10 +93,11 @@ def generate_package_list(ci_type, num_of_packages) packages_with_targets end -def update_build - Dir.glob('ci-logs/*/*/builds/*') do |build| +def update_build(log_path) + Dir.glob(log_path) do |build| begin build_array = build.split('/') + build_array.shift(1) if build_array[1] == 'test-logs' sha1 = build_array[1] timestamp = build_array[4] target = build_array[2].sub('_target', '') @@ -128,10 +129,11 @@ def update_build end end -def update_repoman - Dir.glob('ci-logs/*/*/repomans/*') do |repoman| +def update_repoman(log_path) + Dir.glob(log_path) do |repoman| begin repoman_array = repoman.split('/') + repoman_array.shift(1) if repoman_array[1] == 'test-logs' sha1 = repoman_array[1] timestamp = repoman_array[4] target = repoman_array[2].sub('_target', '') diff --git a/web/test/minitest_helper.rb b/web/test/minitest_helper.rb index 4e4caaf..d9065b3 100644 --- a/web/test/minitest_helper.rb +++ b/web/test/minitest_helper.rb @@ -2,3 +2,24 @@ gem 'minitest' require 'minitest/autorun' require 'rack/test' require_relative '../app' + +clear_packages +package = File.read('test/test-logs/1/package').lines.each(&:strip!) +Package.create( + sha1: package[0], + category: package[1], + name: package[2], + version: package[3], + revision: package[4], + slot: package[5], + identifier: package[6], + amd64_keyword: package[7], + r19_target: package[8], + r20_target: package[9], + r21_target: package[10], + r22_target: package[11], + gem_version: package[12] +) +update_build('test/test-logs/*/*/builds/*') + +MiniTest.after_run { clear_packages } diff --git a/web/test/test-logs/.gitignore b/web/test/test-logs/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/web/test/test-logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/web/test/test_build_status.rb b/web/test/test_build_status.rb index 336e3d1..381389f 100644 --- a/web/test/test_build_status.rb +++ b/web/test/test_build_status.rb @@ -7,9 +7,18 @@ class TestWeb < Minitest::Test RubyTinderbox end - def test_headings + def test_heading get '/build_status' assert last_response.ok? assert last_response.body.include? '<h1>Build Status (CI)</h1>' end + + def test_table + get '/build_status' + assert last_response.ok? + assert last_response.body.include? 'lorem-ipsum/dolor-1.2.3' + assert last_response.body.include? '2012-12-12' + assert last_response.body.include? 'Succeeded' + assert last_response.body.include? '1 Build(s)' + end end diff --git a/web/test/test_outdated_gems.rb b/web/test/test_outdated_gems.rb index ac1b8ff..afbdae5 100644 --- a/web/test/test_outdated_gems.rb +++ b/web/test/test_outdated_gems.rb @@ -7,9 +7,17 @@ class TestWeb < Minitest::Test RubyTinderbox end - def test_headings + def test_heading get '/outdated_gems' assert last_response.ok? assert last_response.body.include? '<h1>Outdated Gems</h1>' end + + def test_table + get '/outdated_gems' + assert last_response.ok? + assert last_response.body.include? 'lorem-ipsum/dolor-1.2.3' + assert last_response.body.include? '1.2.3' + assert last_response.body.include? '1.2.4' + end end diff --git a/web/test/test_repoman_checks.rb b/web/test/test_repoman_checks.rb index ef6c7b6..e583fa4 100644 --- a/web/test/test_repoman_checks.rb +++ b/web/test/test_repoman_checks.rb @@ -7,7 +7,7 @@ class TestWeb < Minitest::Test RubyTinderbox end - def test_headings + def test_heading get '/repoman_checks' assert last_response.ok? assert last_response.body.include? '<h1>Build Status (CI)</h1>' diff --git a/web/test/test_ruby_targets.rb b/web/test/test_ruby_targets.rb index 7aa2f69..9cd76b2 100644 --- a/web/test/test_ruby_targets.rb +++ b/web/test/test_ruby_targets.rb @@ -14,9 +14,19 @@ class TestWeb < Minitest::Test assert last_response.body.include? '<h1>Ruby Targets</h1>' end - def test_headings + def test_heading get '/ruby_targets' assert last_response.ok? assert last_response.body.include? '<h1>Ruby Targets</h1>' end + + def test_table + get '/ruby_targets' + assert last_response.ok? + assert last_response.body.include? 'lorem-ipsum/dolor-1.2.3' + assert last_response.body.include? 'ruby19' + assert last_response.body.include? 'ruby20' + assert last_response.body.include? 'ruby21' + assert last_response.body.include? 'ruby22' + end end diff --git a/web/test/test_visualizations.rb b/web/test/test_visualizations.rb index 45b08d4..ef1fe0a 100644 --- a/web/test/test_visualizations.rb +++ b/web/test/test_visualizations.rb @@ -7,7 +7,7 @@ class TestWeb < Minitest::Test RubyTinderbox end - def test_headings + def test_heading get '/visualizations' assert last_response.ok? assert last_response.body.include? '<h1>Visualizations</h1>' |