File: test_runner_test.rb

package info (click to toggle)
gem2deb 2.2.6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,228 kB
  • sloc: ruby: 5,562; sh: 140; perl: 46; ansic: 33; makefile: 31
file content (52 lines) | stat: -rw-r--r-- 1,653 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require_relative '../test_helper'
require 'gem2deb/test_runner'

class TestRunnerTest < Gem2DebTestCase

  def self.should_detect_test_runner(dir)
    should "detect a test runner for #{dir}" do
      Dir.chdir(dir) do
        assert Gem2Deb::TestRunner.detect
      end
    end
  end

  def self.test_should_return(exitstatus, dir, autopkgtest: false)
    should_detect_test_runner(dir)
    should "exit #{exitstatus} when testing #{dir}" do
      begin
        Dir.chdir(dir) do
          self.class.silently do
            runner = Gem2Deb::TestRunner.detect
            runner.autopkgtest = autopkgtest
            def runner.exec(*cmd)
              system(*cmd)
              exit($?.exitstatus)
            end
            rubylib = ENV['RUBYLIB']
            ENV['RUBYLIB'] = GEM2DEB_ROOT_SOURCE_DIR + '/lib'
            begin
              runner.run_tests
            ensure
              ENV['RUBYLIB'] = rubylib
            end
          end
        end
      rescue SystemExit => e
        assert_equal exitstatus, e.status
      end
    end
  end

  test_should_return 0, 'test/sample/test_runner/yaml/pass'
  test_should_return 1, 'test/sample/test_runner/yaml/fail'
  test_should_return 0, 'test/sample/test_runner/rake/with_rakelib'
  test_should_return 0, 'test/sample/test_runner/rake/pass'
  test_should_return 1, 'test/sample/test_runner/rake/fail'
  test_should_return 0, 'test/sample/test_runner/rb/pass'
  test_should_return 1, 'test/sample/test_runner/rb/fail'

  test_should_return 77, 'test/sample/test_runner/no_tests', autopkgtest: true
  test_should_return 0, 'test/sample/ruby-autopkgtest-example', autopkgtest: true

end