ActiveSambaLdap 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.en +40 -0
- data/NEWS.ja +44 -0
- data/README.en +366 -0
- data/README.ja +361 -0
- data/Rakefile +168 -0
- data/bin/asl-groupadd +73 -0
- data/bin/asl-groupadd.help +1 -0
- data/bin/asl-groupdel +61 -0
- data/bin/asl-groupdel.help +1 -0
- data/bin/asl-groupmod +137 -0
- data/bin/asl-groupmod.help +1 -0
- data/bin/asl-groupshow +33 -0
- data/bin/asl-groupshow.help +1 -0
- data/bin/asl-passwd +90 -0
- data/bin/asl-passwd.help +1 -0
- data/bin/asl-populate +101 -0
- data/bin/asl-populate.help +1 -0
- data/bin/asl-purge +26 -0
- data/bin/asl-purge.help +1 -0
- data/bin/asl-samba-computeradd +96 -0
- data/bin/asl-samba-computeradd.help +1 -0
- data/bin/asl-samba-groupadd +57 -0
- data/bin/asl-samba-groupadd.help +1 -0
- data/bin/asl-samba-groupdel +55 -0
- data/bin/asl-samba-groupdel.help +1 -0
- data/bin/asl-samba-groupmod +99 -0
- data/bin/asl-samba-groupmod.help +1 -0
- data/bin/asl-samba-useradd +100 -0
- data/bin/asl-samba-useradd.help +1 -0
- data/bin/asl-samba-userdel +49 -0
- data/bin/asl-samba-userdel.help +1 -0
- data/bin/asl-samba-usermod +94 -0
- data/bin/asl-samba-usermod.help +1 -0
- data/bin/asl-useradd +264 -0
- data/bin/asl-useradd.help +1 -0
- data/bin/asl-userdel +84 -0
- data/bin/asl-userdel.help +1 -0
- data/bin/asl-usermod +335 -0
- data/bin/asl-usermod.help +1 -0
- data/bin/asl-usershow +33 -0
- data/bin/asl-usershow.help +1 -0
- data/lib/active_samba_ldap.rb +42 -0
- data/lib/active_samba_ldap/account_entry.rb +208 -0
- data/lib/active_samba_ldap/base.rb +137 -0
- data/lib/active_samba_ldap/command.rb +100 -0
- data/lib/active_samba_ldap/computer.rb +24 -0
- data/lib/active_samba_ldap/computer_account_entry.rb +34 -0
- data/lib/active_samba_ldap/configuration.rb +333 -0
- data/lib/active_samba_ldap/dc.rb +19 -0
- data/lib/active_samba_ldap/entry.rb +81 -0
- data/lib/active_samba_ldap/get_text_support.rb +12 -0
- data/lib/active_samba_ldap/group.rb +17 -0
- data/lib/active_samba_ldap/group_entry.rb +187 -0
- data/lib/active_samba_ldap/idmap.rb +19 -0
- data/lib/active_samba_ldap/ou.rb +20 -0
- data/lib/active_samba_ldap/populate.rb +257 -0
- data/lib/active_samba_ldap/reloadable.rb +15 -0
- data/lib/active_samba_ldap/samba_account_entry.rb +225 -0
- data/lib/active_samba_ldap/samba_entry.rb +26 -0
- data/lib/active_samba_ldap/samba_group_entry.rb +143 -0
- data/lib/active_samba_ldap/unix_id_pool.rb +43 -0
- data/lib/active_samba_ldap/user.rb +44 -0
- data/lib/active_samba_ldap/user_account_entry.rb +30 -0
- data/lib/active_samba_ldap/version.rb +3 -0
- data/lib/samba/encrypt.rb +86 -0
- data/misc/rd2html.rb +42 -0
- data/po/ja/active-samba-ldap.po +465 -0
- data/rails/README +30 -0
- data/rails/init.rb +33 -0
- data/rails_generators/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +27 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/computer.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/dc.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/group.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/idmap.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/ldap.yml +24 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/ou.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_controller.rb +12 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_helper.rb +2 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_index.rhtml +17 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_populate.rhtml +15 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_purge.rhtml +10 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/unix_id_pool.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/user.rb +3 -0
- data/setup.rb +1585 -0
- data/test-unit/History.txt +107 -0
- data/test-unit/README.txt +52 -0
- data/test-unit/Rakefile +40 -0
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/lib/test/unit.rb +342 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
- data/test-unit/lib/test/unit/assertions.rb +1149 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +329 -0
- data/test-unit/lib/test/unit/collector.rb +43 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +135 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/color-scheme.rb +86 -0
- data/test-unit/lib/test/unit/color.rb +96 -0
- data/test-unit/lib/test/unit/diff.rb +538 -0
- data/test-unit/lib/test/unit/error.rb +124 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +110 -0
- data/test-unit/lib/test/unit/fixture.rb +176 -0
- data/test-unit/lib/test/unit/notification.rb +125 -0
- data/test-unit/lib/test/unit/omission.rb +143 -0
- data/test-unit/lib/test/unit/pending.rb +146 -0
- data/test-unit/lib/test/unit/priority.rb +181 -0
- data/test-unit/lib/test/unit/runner/console.rb +52 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +425 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +223 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/tc_adder.rb +18 -0
- data/test-unit/sample/tc_subtracter.rb +18 -0
- data/test-unit/sample/test_user.rb +22 -0
- data/test-unit/sample/ts_examples.rb +7 -0
- data/test-unit/test/collector/test-descendant.rb +135 -0
- data/test-unit/test/collector/test-load.rb +333 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_objectspace.rb +98 -0
- data/test-unit/test/run-test.rb +13 -0
- data/test-unit/test/test-attribute.rb +86 -0
- data/test-unit/test/test-color-scheme.rb +56 -0
- data/test-unit/test/test-color.rb +47 -0
- data/test-unit/test/test-diff.rb +477 -0
- data/test-unit/test/test-emacs-runner.rb +60 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/test-notification.rb +33 -0
- data/test-unit/test/test-omission.rb +81 -0
- data/test-unit/test/test-pending.rb +70 -0
- data/test-unit/test/test-priority.rb +119 -0
- data/test-unit/test/test-testcase.rb +507 -0
- data/test-unit/test/test_assertions.rb +1082 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit-test-util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/test/asl-test-utils.rb +276 -0
- data/test/command.rb +67 -0
- data/test/config.yaml.sample +17 -0
- data/test/run-test.rb +20 -0
- data/test/test_asl_groupadd.rb +69 -0
- data/test/test_asl_groupdel.rb +88 -0
- data/test/test_asl_groupmod.rb +259 -0
- data/test/test_asl_groupshow.rb +21 -0
- data/test/test_asl_passwd.rb +126 -0
- data/test/test_asl_populate.rb +92 -0
- data/test/test_asl_purge.rb +21 -0
- data/test/test_asl_useradd.rb +712 -0
- data/test/test_asl_userdel.rb +75 -0
- data/test/test_asl_usermod.rb +549 -0
- data/test/test_asl_usershow.rb +27 -0
- data/test/test_entry.rb +21 -0
- data/test/test_group.rb +21 -0
- data/test/test_password.rb +51 -0
- data/test/test_samba_encrypt.rb +35 -0
- data/test/test_user_home_directory.rb +43 -0
- metadata +314 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Nathaniel Talbott.
|
3
|
+
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
4
|
+
# License:: Ruby license.
|
5
|
+
|
6
|
+
require 'test/unit/util/observable'
|
7
|
+
require 'test/unit/failure'
|
8
|
+
require 'test/unit/error'
|
9
|
+
require 'test/unit/omission'
|
10
|
+
require 'test/unit/pending'
|
11
|
+
require 'test/unit/notification'
|
12
|
+
|
13
|
+
module Test
|
14
|
+
module Unit
|
15
|
+
module NullResultContainerInitializer
|
16
|
+
private
|
17
|
+
def initialize_containers
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Collects Test::Unit::Failure and Test::Unit::Error so that
|
22
|
+
# they can be displayed to the user. To this end, observers
|
23
|
+
# can be added to it, allowing the dynamic updating of, say, a
|
24
|
+
# UI.
|
25
|
+
class TestResult
|
26
|
+
include Util::Observable
|
27
|
+
include NullResultContainerInitializer
|
28
|
+
include TestResultFailureSupport
|
29
|
+
include TestResultErrorSupport
|
30
|
+
include TestResultPendingSupport
|
31
|
+
include TestResultOmissionSupport
|
32
|
+
include TestResultNotificationSupport
|
33
|
+
|
34
|
+
CHANGED = "CHANGED"
|
35
|
+
FAULT = "FAULT"
|
36
|
+
|
37
|
+
attr_reader :run_count, :assertion_count, :faults
|
38
|
+
|
39
|
+
# Constructs a new, empty TestResult.
|
40
|
+
def initialize
|
41
|
+
@run_count, @assertion_count = 0, 0
|
42
|
+
@summary_generators = []
|
43
|
+
@problem_checkers = []
|
44
|
+
@faults = []
|
45
|
+
initialize_containers
|
46
|
+
end
|
47
|
+
|
48
|
+
# Records a test run.
|
49
|
+
def add_run
|
50
|
+
@run_count += 1
|
51
|
+
notify_changed
|
52
|
+
end
|
53
|
+
|
54
|
+
# Records an individual assertion.
|
55
|
+
def add_assertion
|
56
|
+
@assertion_count += 1
|
57
|
+
notify_changed
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns a string contain the recorded runs, assertions,
|
61
|
+
# failures and errors in this TestResult.
|
62
|
+
def summary
|
63
|
+
["#{run_count} tests",
|
64
|
+
"#{assertion_count} assertions",
|
65
|
+
*@summary_generators.collect {|generator| send(generator)}].join(", ")
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
summary
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns whether or not this TestResult represents
|
73
|
+
# successful completion.
|
74
|
+
def passed?
|
75
|
+
@problem_checkers.all? {|checker| not send(checker)}
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
def notify_changed
|
80
|
+
notify_listeners(CHANGED, self)
|
81
|
+
end
|
82
|
+
|
83
|
+
def notify_fault(fault)
|
84
|
+
@faults << fault
|
85
|
+
notify_listeners(FAULT, fault)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Nathaniel Talbott.
|
4
|
+
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
5
|
+
# License:: Ruby license.
|
6
|
+
|
7
|
+
require 'test/unit/error'
|
8
|
+
|
9
|
+
module Test
|
10
|
+
module Unit
|
11
|
+
|
12
|
+
# A collection of tests which can be #run.
|
13
|
+
#
|
14
|
+
# Note: It is easy to confuse a TestSuite instance with
|
15
|
+
# something that has a static suite method; I know because _I_
|
16
|
+
# have trouble keeping them straight. Think of something that
|
17
|
+
# has a suite method as simply providing a way to get a
|
18
|
+
# meaningful TestSuite instance.
|
19
|
+
class TestSuite
|
20
|
+
attr_reader :name, :tests
|
21
|
+
|
22
|
+
STARTED = name + "::STARTED"
|
23
|
+
FINISHED = name + "::FINISHED"
|
24
|
+
|
25
|
+
# Creates a new TestSuite with the given name.
|
26
|
+
def initialize(name="Unnamed TestSuite", test_case=nil)
|
27
|
+
@name = name
|
28
|
+
@tests = []
|
29
|
+
@test_case = test_case
|
30
|
+
end
|
31
|
+
|
32
|
+
# Runs the tests and/or suites contained in this
|
33
|
+
# TestSuite.
|
34
|
+
def run(result, &progress_block)
|
35
|
+
yield(STARTED, name)
|
36
|
+
run_startup(result)
|
37
|
+
@tests.each do |test|
|
38
|
+
test.run(result, &progress_block)
|
39
|
+
end
|
40
|
+
run_shutdown(result)
|
41
|
+
yield(FINISHED, name)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Adds the test to the suite.
|
45
|
+
def <<(test)
|
46
|
+
@tests << test
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete(test)
|
51
|
+
@tests.delete(test)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Retuns the rolled up number of tests in this suite;
|
55
|
+
# i.e. if the suite contains other suites, it counts the
|
56
|
+
# tests within those suites, not the suites themselves.
|
57
|
+
def size
|
58
|
+
total_size = 0
|
59
|
+
@tests.each { |test| total_size += test.size }
|
60
|
+
total_size
|
61
|
+
end
|
62
|
+
|
63
|
+
def empty?
|
64
|
+
tests.empty?
|
65
|
+
end
|
66
|
+
|
67
|
+
# Overridden to return the name given the suite at
|
68
|
+
# creation.
|
69
|
+
def to_s
|
70
|
+
@name
|
71
|
+
end
|
72
|
+
|
73
|
+
# It's handy to be able to compare TestSuite instances.
|
74
|
+
def ==(other)
|
75
|
+
return false unless(other.kind_of?(self.class))
|
76
|
+
return false unless(@name == other.name)
|
77
|
+
@tests == other.tests
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
def run_startup(result)
|
82
|
+
return if @test_case.nil? or !@test_case.respond_to?(:startup)
|
83
|
+
begin
|
84
|
+
@test_case.startup
|
85
|
+
rescue Exception
|
86
|
+
raise unless handle_exception($!, result)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def run_shutdown(result)
|
91
|
+
return if @test_case.nil? or !@test_case.respond_to?(:shutdown)
|
92
|
+
begin
|
93
|
+
@test_case.shutdown
|
94
|
+
rescue Exception
|
95
|
+
raise unless handle_exception($!, result)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def handle_exception(exception, result)
|
100
|
+
case exception
|
101
|
+
when *ErrorHandler::PASS_THROUGH_EXCEPTIONS
|
102
|
+
false
|
103
|
+
else
|
104
|
+
result.add_error(Error.new(@test_case.name, exception))
|
105
|
+
true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Nathaniel Talbott.
|
4
|
+
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
5
|
+
# License:: Ruby license.
|
6
|
+
|
7
|
+
require 'test/unit/color-scheme'
|
8
|
+
require 'test/unit/ui/testrunner'
|
9
|
+
require 'test/unit/ui/testrunnermediator'
|
10
|
+
require 'test/unit/ui/console/outputlevel'
|
11
|
+
|
12
|
+
module Test
|
13
|
+
module Unit
|
14
|
+
module UI
|
15
|
+
module Console
|
16
|
+
|
17
|
+
# Runs a Test::Unit::TestSuite on the console.
|
18
|
+
class TestRunner < UI::TestRunner
|
19
|
+
include OutputLevel
|
20
|
+
|
21
|
+
# Creates a new TestRunner for running the passed
|
22
|
+
# suite. If quiet_mode is true, the output while
|
23
|
+
# running is limited to progress dots, errors and
|
24
|
+
# failures, and the final result. io specifies
|
25
|
+
# where runner output should go to; defaults to
|
26
|
+
# STDOUT.
|
27
|
+
def initialize(suite, options={})
|
28
|
+
super
|
29
|
+
@output_level = @options[:output_level] || NORMAL
|
30
|
+
@output = @options[:output] || STDOUT
|
31
|
+
@use_color = @options[:use_color]
|
32
|
+
@use_color = guess_color_availability if @use_color.nil?
|
33
|
+
@color_scheme = @options[:color_scheme] || ColorScheme.default
|
34
|
+
@reset_color = Color.new("reset")
|
35
|
+
@progress_row = 0
|
36
|
+
@progress_row_max = @options[:progress_row_max]
|
37
|
+
@progress_row_max ||= guess_progress_row_max
|
38
|
+
@already_outputted = false
|
39
|
+
@faults = []
|
40
|
+
end
|
41
|
+
|
42
|
+
# Begins the test run.
|
43
|
+
def start
|
44
|
+
setup_mediator
|
45
|
+
attach_to_mediator
|
46
|
+
return start_mediator
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def setup_mediator
|
51
|
+
@mediator = create_mediator(@suite)
|
52
|
+
output_setup_end
|
53
|
+
end
|
54
|
+
|
55
|
+
def output_setup_end
|
56
|
+
suite_name = @suite.to_s
|
57
|
+
suite_name = @suite.name if @suite.kind_of?(Module)
|
58
|
+
output("Loaded suite #{suite_name}")
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_mediator(suite)
|
62
|
+
return TestRunnerMediator.new(suite)
|
63
|
+
end
|
64
|
+
|
65
|
+
def attach_to_mediator
|
66
|
+
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
|
67
|
+
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
|
68
|
+
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
|
69
|
+
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
|
70
|
+
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
|
71
|
+
end
|
72
|
+
|
73
|
+
def start_mediator
|
74
|
+
return @mediator.run_suite
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_fault(fault)
|
78
|
+
@faults << fault
|
79
|
+
output_progress(fault.single_character_display, fault_color(fault))
|
80
|
+
@already_outputted = true
|
81
|
+
end
|
82
|
+
|
83
|
+
def started(result)
|
84
|
+
@result = result
|
85
|
+
output_started
|
86
|
+
end
|
87
|
+
|
88
|
+
def output_started
|
89
|
+
output("Started")
|
90
|
+
end
|
91
|
+
|
92
|
+
def finished(elapsed_time)
|
93
|
+
nl if output?(NORMAL) and !output?(VERBOSE)
|
94
|
+
nl
|
95
|
+
output("Finished in #{elapsed_time} seconds.")
|
96
|
+
@faults.each_with_index do |fault, index|
|
97
|
+
nl
|
98
|
+
output_single("%3d) " % (index + 1))
|
99
|
+
label, detail = format_fault(fault).split(/\r?\n/, 2)
|
100
|
+
output(label, fault_color(fault))
|
101
|
+
output(detail)
|
102
|
+
end
|
103
|
+
nl
|
104
|
+
output(@result, result_color)
|
105
|
+
end
|
106
|
+
|
107
|
+
def format_fault(fault)
|
108
|
+
fault.long_display
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_started(name)
|
112
|
+
output_single(name + ": ", nil, VERBOSE)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_finished(name)
|
116
|
+
unless @already_outputted
|
117
|
+
output_progress(".", color("success"))
|
118
|
+
end
|
119
|
+
nl(VERBOSE)
|
120
|
+
@already_outputted = false
|
121
|
+
end
|
122
|
+
|
123
|
+
def nl(level=NORMAL)
|
124
|
+
output("", nil, level)
|
125
|
+
end
|
126
|
+
|
127
|
+
def output(something, color=nil, level=NORMAL)
|
128
|
+
return unless output?(level)
|
129
|
+
output_single(something, color, level)
|
130
|
+
@output.puts
|
131
|
+
end
|
132
|
+
|
133
|
+
def output_single(something, color=nil, level=NORMAL)
|
134
|
+
return false unless output?(level)
|
135
|
+
if @use_color and color
|
136
|
+
something = "%s%s%s" % [color.escape_sequence,
|
137
|
+
something,
|
138
|
+
@reset_color.escape_sequence]
|
139
|
+
end
|
140
|
+
@output.write(something)
|
141
|
+
@output.flush
|
142
|
+
true
|
143
|
+
end
|
144
|
+
|
145
|
+
def output_progress(mark, color=nil)
|
146
|
+
if output_single(mark, color, PROGRESS_ONLY)
|
147
|
+
return unless @progress_row_max > 0
|
148
|
+
@progress_row += mark.size
|
149
|
+
if @progress_row >= @progress_row_max
|
150
|
+
nl unless @output_level == VERBOSE
|
151
|
+
@progress_row = 0
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def output?(level)
|
157
|
+
level <= @output_level
|
158
|
+
end
|
159
|
+
|
160
|
+
def color(name)
|
161
|
+
@color_scheme[name] || ColorScheme.default[name]
|
162
|
+
end
|
163
|
+
|
164
|
+
def fault_color(fault)
|
165
|
+
color(fault.class.name.split(/::/).last.downcase)
|
166
|
+
end
|
167
|
+
|
168
|
+
def result_color
|
169
|
+
if @result.passed?
|
170
|
+
if @result.pending_count > 0
|
171
|
+
color("pending")
|
172
|
+
elsif @result.omission_count > 0
|
173
|
+
color("omission")
|
174
|
+
elsif @result.notification_count > 0
|
175
|
+
color("notification")
|
176
|
+
else
|
177
|
+
color("success")
|
178
|
+
end
|
179
|
+
elsif @result.error_count > 0
|
180
|
+
color("error")
|
181
|
+
elsif @result.failure_count > 0
|
182
|
+
color("failure")
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def guess_color_availability
|
187
|
+
return false unless @output.tty?
|
188
|
+
case ENV["TERM"]
|
189
|
+
when /term(?:-color)?\z/, "screen"
|
190
|
+
true
|
191
|
+
else
|
192
|
+
return true if ENV["EMACS"] == "t"
|
193
|
+
false
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def guess_progress_row_max
|
198
|
+
term_width = guess_term_width
|
199
|
+
if term_width.zero?
|
200
|
+
if ENV["EMACS"] == "t"
|
201
|
+
-1
|
202
|
+
else
|
203
|
+
79
|
204
|
+
end
|
205
|
+
else
|
206
|
+
term_width
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def guess_term_width
|
211
|
+
Integer(ENV["TERM_WIDTH"] || 0)
|
212
|
+
rescue ArgumentError
|
213
|
+
0
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
if __FILE__ == $0
|
222
|
+
Test::Unit::UI::Console::TestRunner.start_command_line_test
|
223
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit/ui/console/testrunner'
|
2
|
+
|
3
|
+
module Test
|
4
|
+
module Unit
|
5
|
+
module UI
|
6
|
+
module Emacs
|
7
|
+
class TestRunner < Console::TestRunner
|
8
|
+
private
|
9
|
+
def output_setup_end
|
10
|
+
end
|
11
|
+
|
12
|
+
def output_started
|
13
|
+
end
|
14
|
+
|
15
|
+
def format_fault(fault)
|
16
|
+
return super unless fault.respond_to?(:label)
|
17
|
+
format_method_name = "format_fault_#{fault.label.downcase}"
|
18
|
+
if respond_to?(format_method_name, true)
|
19
|
+
send(format_method_name, fault)
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def format_fault_failure(failure)
|
26
|
+
if failure.location.size == 1
|
27
|
+
location = failure.location[0]
|
28
|
+
location_display = location.sub(/\A(.+:\d+).*/, ' [\\1]')
|
29
|
+
else
|
30
|
+
location_display = "\n" + failure.location.join("\n")
|
31
|
+
end
|
32
|
+
result = "#{failure.label}:\n"
|
33
|
+
result << "#{failure.test_name}#{location_display}:\n"
|
34
|
+
result << failure.message
|
35
|
+
result
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_fault_error(error)
|
39
|
+
result = "#{error.label}:\n"
|
40
|
+
result << "#{error.test_name}:\n"
|
41
|
+
result << "#{error.message}\n"
|
42
|
+
result << error.backtrace.join("\n")
|
43
|
+
result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|