elliottcable-echoe 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -1
- data/Manifest +1 -93
- data/Rakefile +1 -2
- data/echoe.gemspec +7 -7
- data/lib/echoe.rb +50 -22
- data/lib/echoe/net.rb +7 -0
- data/lib/echoe/platform.rb +27 -25
- data/vendor/rake/lib/rake/contrib/sshpublisher.rb +0 -4
- metadata +7 -96
- data/vendor/rake/CHANGES +0 -400
- data/vendor/rake/README +0 -285
- data/vendor/rake/Rakefile +0 -418
- data/vendor/rake/TODO +0 -20
- data/vendor/rake/bin/rake +0 -31
- data/vendor/rake/doc/example/Rakefile1 +0 -38
- data/vendor/rake/doc/example/Rakefile2 +0 -35
- data/vendor/rake/doc/example/a.c +0 -6
- data/vendor/rake/doc/example/b.c +0 -6
- data/vendor/rake/doc/example/main.c +0 -11
- data/vendor/rake/doc/glossary.rdoc +0 -51
- data/vendor/rake/doc/jamis.rb +0 -591
- data/vendor/rake/doc/proto_rake.rdoc +0 -127
- data/vendor/rake/doc/rake.1.gz +0 -0
- data/vendor/rake/doc/rakefile.rdoc +0 -534
- data/vendor/rake/doc/rational.rdoc +0 -151
- data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/vendor/rake/install.rb +0 -88
- data/vendor/rake/lib/rake.rb +0 -2468
- data/vendor/rake/lib/rake/classic_namespace.rb +0 -8
- data/vendor/rake/lib/rake/clean.rb +0 -33
- data/vendor/rake/lib/rake/gempackagetask.rb +0 -103
- data/vendor/rake/lib/rake/loaders/makefile.rb +0 -35
- data/vendor/rake/lib/rake/packagetask.rb +0 -185
- data/vendor/rake/lib/rake/rake_test_loader.rb +0 -5
- data/vendor/rake/lib/rake/rdoctask.rb +0 -147
- data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +0 -23
- data/vendor/rake/lib/rake/runtest.rb +0 -23
- data/vendor/rake/lib/rake/tasklib.rb +0 -23
- data/vendor/rake/lib/rake/testtask.rb +0 -161
- data/vendor/rake/lib/rake/win32.rb +0 -54
- data/vendor/rake/test/capture_stdout.rb +0 -26
- data/vendor/rake/test/check_expansion.rb +0 -5
- data/vendor/rake/test/contrib/test_sys.rb +0 -47
- data/vendor/rake/test/data/chains/Rakefile +0 -15
- data/vendor/rake/test/data/default/Rakefile +0 -19
- data/vendor/rake/test/data/dryrun/Rakefile +0 -22
- data/vendor/rake/test/data/file_creation_task/Rakefile +0 -33
- data/vendor/rake/test/data/imports/Rakefile +0 -19
- data/vendor/rake/test/data/imports/deps.mf +0 -1
- data/vendor/rake/test/data/multidesc/Rakefile +0 -17
- data/vendor/rake/test/data/namespace/Rakefile +0 -57
- data/vendor/rake/test/data/rakelib/test1.rb +0 -3
- data/vendor/rake/test/data/rbext/rakefile.rb +0 -3
- data/vendor/rake/test/data/sample.mf +0 -12
- data/vendor/rake/test/data/statusreturn/Rakefile +0 -8
- data/vendor/rake/test/data/unittest/Rakefile +0 -1
- data/vendor/rake/test/filecreation.rb +0 -32
- data/vendor/rake/test/functional.rb +0 -15
- data/vendor/rake/test/in_environment.rb +0 -30
- data/vendor/rake/test/rake_test_setup.rb +0 -10
- data/vendor/rake/test/reqfile.rb +0 -3
- data/vendor/rake/test/reqfile2.rb +0 -3
- data/vendor/rake/test/session_functional.rb +0 -337
- data/vendor/rake/test/shellcommand.rb +0 -3
- data/vendor/rake/test/test_application.rb +0 -694
- data/vendor/rake/test/test_clean.rb +0 -14
- data/vendor/rake/test/test_definitions.rb +0 -82
- data/vendor/rake/test/test_earlytime.rb +0 -35
- data/vendor/rake/test/test_extension.rb +0 -63
- data/vendor/rake/test/test_file_creation_task.rb +0 -62
- data/vendor/rake/test/test_file_task.rb +0 -139
- data/vendor/rake/test/test_filelist.rb +0 -618
- data/vendor/rake/test/test_fileutils.rb +0 -250
- data/vendor/rake/test/test_ftp.rb +0 -59
- data/vendor/rake/test/test_invocation_chain.rb +0 -75
- data/vendor/rake/test/test_makefile_loader.rb +0 -25
- data/vendor/rake/test/test_multitask.rb +0 -45
- data/vendor/rake/test/test_namespace.rb +0 -36
- data/vendor/rake/test/test_package_task.rb +0 -116
- data/vendor/rake/test/test_pathmap.rb +0 -209
- data/vendor/rake/test/test_rake.rb +0 -41
- data/vendor/rake/test/test_require.rb +0 -33
- data/vendor/rake/test/test_rules.rb +0 -347
- data/vendor/rake/test/test_task_arguments.rb +0 -89
- data/vendor/rake/test/test_task_manager.rb +0 -170
- data/vendor/rake/test/test_tasklib.rb +0 -12
- data/vendor/rake/test/test_tasks.rb +0 -371
- data/vendor/rake/test/test_test_task.rb +0 -75
- data/vendor/rake/test/test_top_level_functions.rb +0 -84
- data/vendor/rake/test/test_win32.rb +0 -57
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rake/clean'
|
5
|
-
|
6
|
-
class TestClean < Test::Unit::TestCase
|
7
|
-
include Rake
|
8
|
-
def test_clean
|
9
|
-
assert Task['clean'], "Should define clean"
|
10
|
-
assert Task['clobber'], "Should define clobber"
|
11
|
-
assert Task['clobber'].prerequisites.include?("clean"),
|
12
|
-
"Clobber should require clean"
|
13
|
-
end
|
14
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'rake'
|
6
|
-
require 'test/filecreation'
|
7
|
-
|
8
|
-
######################################################################
|
9
|
-
class TestDefinitions < Test::Unit::TestCase
|
10
|
-
include Rake
|
11
|
-
EXISTINGFILE = "testdata/existing"
|
12
|
-
|
13
|
-
def setup
|
14
|
-
Task.clear
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_task
|
18
|
-
done = false
|
19
|
-
task :one => [:two] do done = true end
|
20
|
-
task :two
|
21
|
-
task :three => [:one, :two]
|
22
|
-
check_tasks(:one, :two, :three)
|
23
|
-
assert done, "Should be done"
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_file_task
|
27
|
-
done = false
|
28
|
-
file "testdata/one" => "testdata/two" do done = true end
|
29
|
-
file "testdata/two"
|
30
|
-
file "testdata/three" => ["testdata/one", "testdata/two"]
|
31
|
-
check_tasks("testdata/one", "testdata/two", "testdata/three")
|
32
|
-
assert done, "Should be done"
|
33
|
-
end
|
34
|
-
|
35
|
-
def check_tasks(n1, n2, n3)
|
36
|
-
t = Task[n1]
|
37
|
-
assert Task === t, "Should be a Task"
|
38
|
-
assert_equal n1.to_s, t.name
|
39
|
-
assert_equal [n2.to_s], t.prerequisites.collect{|n| n.to_s}
|
40
|
-
t.invoke
|
41
|
-
t2 = Task[n2]
|
42
|
-
assert_equal FileList[], t2.prerequisites
|
43
|
-
t3 = Task[n3]
|
44
|
-
assert_equal [n1.to_s, n2.to_s], t3.prerequisites.collect{|n|n.to_s}
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_incremental_definitions
|
48
|
-
runs = []
|
49
|
-
task :t1 => [:t2] do runs << "A"; 4321 end
|
50
|
-
task :t1 => [:t3] do runs << "B"; 1234 end
|
51
|
-
task :t1 => [:t3]
|
52
|
-
task :t2
|
53
|
-
task :t3
|
54
|
-
Task[:t1].invoke
|
55
|
-
assert_equal ["A", "B"], runs
|
56
|
-
assert_equal ["t2", "t3"], Task[:t1].prerequisites
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_missing_dependencies
|
60
|
-
task :x => ["testdata/missing"]
|
61
|
-
assert_raises(RuntimeError) { Task[:x].invoke }
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_implicit_file_dependencies
|
65
|
-
runs = []
|
66
|
-
create_existing_file
|
67
|
-
task :y => [EXISTINGFILE] do |t| runs << t.name end
|
68
|
-
Task[:y].invoke
|
69
|
-
assert_equal runs, ['y']
|
70
|
-
end
|
71
|
-
|
72
|
-
private # ----------------------------------------------------------
|
73
|
-
|
74
|
-
def create_existing_file
|
75
|
-
Dir.mkdir File.dirname(EXISTINGFILE) unless
|
76
|
-
File.exist?(File.dirname(EXISTINGFILE))
|
77
|
-
open(EXISTINGFILE, "w") do |f| f.puts "HI" end unless
|
78
|
-
File.exist?(EXISTINGFILE)
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rake'
|
5
|
-
|
6
|
-
class TestEarlyTime < Test::Unit::TestCase
|
7
|
-
def test_create
|
8
|
-
early = Rake::EarlyTime.instance
|
9
|
-
time = Time.mktime(1970, 1, 1, 0, 0, 0)
|
10
|
-
assert early <= Time.now
|
11
|
-
assert early < Time.now
|
12
|
-
assert early != Time.now
|
13
|
-
assert Time.now > early
|
14
|
-
assert Time.now >= early
|
15
|
-
assert Time.now != early
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_equality
|
19
|
-
early = Rake::EarlyTime.instance
|
20
|
-
assert_equal early, early, "two early times should be equal"
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_original_time_compare_is_not_messed_up
|
24
|
-
t1 = Time.mktime(1970, 1, 1, 0, 0, 0)
|
25
|
-
t2 = Time.now
|
26
|
-
assert t1 < t2
|
27
|
-
assert t2 > t1
|
28
|
-
assert t1 == t1
|
29
|
-
assert t2 == t2
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_to_s
|
33
|
-
assert_equal "<EARLY TIME>", Rake::EARLY.to_s
|
34
|
-
end
|
35
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rake'
|
5
|
-
require 'stringio'
|
6
|
-
|
7
|
-
######################################################################
|
8
|
-
class TestExtension < Test::Unit::TestCase
|
9
|
-
|
10
|
-
module Redirect
|
11
|
-
def error_redirect
|
12
|
-
old_err = $stderr
|
13
|
-
result = StringIO.new
|
14
|
-
$stderr = result
|
15
|
-
yield
|
16
|
-
result
|
17
|
-
ensure
|
18
|
-
$stderr = old_err
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Sample
|
23
|
-
extend Redirect
|
24
|
-
|
25
|
-
def duplicate_method
|
26
|
-
:original
|
27
|
-
end
|
28
|
-
|
29
|
-
OK_ERRS = error_redirect do
|
30
|
-
rake_extension("a") do
|
31
|
-
def ok_method
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
DUP_ERRS = error_redirect do
|
38
|
-
rake_extension("duplicate_method") do
|
39
|
-
def duplicate_method
|
40
|
-
:override
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_methods_actually_exist
|
47
|
-
sample = Sample.new
|
48
|
-
sample.ok_method
|
49
|
-
sample.duplicate_method
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_no_warning_when_defining_ok_method
|
53
|
-
assert_equal "", Sample::OK_ERRS.string
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_extension_complains_when_a_method_that_is_present
|
57
|
-
assert_match(/warning:/i, Sample::DUP_ERRS.string)
|
58
|
-
assert_match(/already exists/i, Sample::DUP_ERRS.string)
|
59
|
-
assert_match(/duplicate_method/i, Sample::DUP_ERRS.string)
|
60
|
-
assert_equal :original, Sample.new.duplicate_method
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'rake'
|
6
|
-
require 'test/filecreation'
|
7
|
-
|
8
|
-
######################################################################
|
9
|
-
class TestFileCreationTask < Test::Unit::TestCase
|
10
|
-
include Rake
|
11
|
-
include FileCreation
|
12
|
-
|
13
|
-
DUMMY_DIR = 'testdata/dummy_dir'
|
14
|
-
|
15
|
-
def setup
|
16
|
-
Task.clear
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
FileUtils.rm_rf DUMMY_DIR
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_file_needed
|
24
|
-
create_dir DUMMY_DIR
|
25
|
-
fc_task = Task[DUMMY_DIR]
|
26
|
-
assert_equal DUMMY_DIR, fc_task.name
|
27
|
-
FileUtils.rm_rf fc_task.name
|
28
|
-
assert fc_task.needed?, "file should be needed"
|
29
|
-
FileUtils.mkdir fc_task.name
|
30
|
-
assert_equal nil, fc_task.prerequisites.collect{|n| Task[n].timestamp}.max
|
31
|
-
assert ! fc_task.needed?, "file should not be needed"
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_directory
|
35
|
-
directory DUMMY_DIR
|
36
|
-
fc_task = Task[DUMMY_DIR]
|
37
|
-
assert_equal DUMMY_DIR, fc_task.name
|
38
|
-
assert FileCreationTask === fc_task
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_no_retriggers_on_filecreate_task
|
42
|
-
create_timed_files(OLDFILE, NEWFILE)
|
43
|
-
t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
|
44
|
-
t2 = Rake.application.intern(FileCreationTask, NEWFILE)
|
45
|
-
assert ! t2.needed?, "Should not need to build new file"
|
46
|
-
assert ! t1.needed?, "Should not need to rebuild old file because of new"
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_no_retriggers_on_file_task
|
50
|
-
create_timed_files(OLDFILE, NEWFILE)
|
51
|
-
t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
|
52
|
-
t2 = Rake.application.intern(FileCreationTask, NEWFILE)
|
53
|
-
assert ! t2.needed?, "Should not need to build new file"
|
54
|
-
assert ! t1.needed?, "Should not need to rebuild old file because of new"
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_very_early_timestamp
|
58
|
-
t1 = Rake.application.intern(FileCreationTask, OLDFILE)
|
59
|
-
assert t1.timestamp < Time.now
|
60
|
-
assert t1.timestamp < Time.now - 1000000
|
61
|
-
end
|
62
|
-
end
|
@@ -1,139 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'rake'
|
6
|
-
require 'test/filecreation'
|
7
|
-
|
8
|
-
######################################################################
|
9
|
-
class TestFileTask < Test::Unit::TestCase
|
10
|
-
include Rake
|
11
|
-
include FileCreation
|
12
|
-
|
13
|
-
def setup
|
14
|
-
Task.clear
|
15
|
-
@runs = Array.new
|
16
|
-
FileUtils.rm_f NEWFILE
|
17
|
-
FileUtils.rm_f OLDFILE
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_file_need
|
21
|
-
name = "testdata/dummy"
|
22
|
-
file name
|
23
|
-
ftask = Task[name]
|
24
|
-
assert_equal name.to_s, ftask.name
|
25
|
-
File.delete(ftask.name) rescue nil
|
26
|
-
assert ftask.needed?, "file should be needed"
|
27
|
-
open(ftask.name, "w") { |f| f.puts "HI" }
|
28
|
-
assert_equal nil, ftask.prerequisites.collect{|n| Task[n].timestamp}.max
|
29
|
-
assert ! ftask.needed?, "file should not be needed"
|
30
|
-
File.delete(ftask.name) rescue nil
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_file_times_new_depends_on_old
|
34
|
-
create_timed_files(OLDFILE, NEWFILE)
|
35
|
-
|
36
|
-
t1 = Rake.application.intern(FileTask, NEWFILE).enhance([OLDFILE])
|
37
|
-
t2 = Rake.application.intern(FileTask, OLDFILE)
|
38
|
-
assert ! t2.needed?, "Should not need to build old file"
|
39
|
-
assert ! t1.needed?, "Should not need to rebuild new file because of old"
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_file_times_old_depends_on_new
|
43
|
-
create_timed_files(OLDFILE, NEWFILE)
|
44
|
-
|
45
|
-
t1 = Rake.application.intern(FileTask,OLDFILE).enhance([NEWFILE])
|
46
|
-
t2 = Rake.application.intern(FileTask, NEWFILE)
|
47
|
-
assert ! t2.needed?, "Should not need to build new file"
|
48
|
-
preq_stamp = t1.prerequisites.collect{|t| Task[t].timestamp}.max
|
49
|
-
assert_equal t2.timestamp, preq_stamp
|
50
|
-
assert t1.timestamp < preq_stamp, "T1 should be older"
|
51
|
-
assert t1.needed?, "Should need to rebuild old file because of new"
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_file_depends_on_task_depend_on_file
|
55
|
-
create_timed_files(OLDFILE, NEWFILE)
|
56
|
-
|
57
|
-
file NEWFILE => [:obj] do |t| @runs << t.name end
|
58
|
-
task :obj => [OLDFILE] do |t| @runs << t.name end
|
59
|
-
file OLDFILE do |t| @runs << t.name end
|
60
|
-
|
61
|
-
Task[:obj].invoke
|
62
|
-
Task[NEWFILE].invoke
|
63
|
-
assert ! @runs.include?(NEWFILE)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_existing_file_depends_on_non_existing_file
|
67
|
-
create_file(OLDFILE)
|
68
|
-
delete_file(NEWFILE)
|
69
|
-
file NEWFILE
|
70
|
-
file OLDFILE => NEWFILE
|
71
|
-
assert_nothing_raised do Task[OLDFILE].invoke end
|
72
|
-
end
|
73
|
-
|
74
|
-
# I have currently disabled this test. I'm not convinced that
|
75
|
-
# deleting the file target on failure is always the proper thing to
|
76
|
-
# do. I'm willing to hear input on this topic.
|
77
|
-
def ztest_file_deletes_on_failure
|
78
|
-
task :obj
|
79
|
-
file NEWFILE => [:obj] do |t|
|
80
|
-
FileUtils.touch NEWFILE
|
81
|
-
fail "Ooops"
|
82
|
-
end
|
83
|
-
assert Task[NEWFILE]
|
84
|
-
begin
|
85
|
-
Task[NEWFILE].invoke
|
86
|
-
rescue Exception
|
87
|
-
end
|
88
|
-
assert( ! File.exist?(NEWFILE), "NEWFILE should be deleted")
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
######################################################################
|
94
|
-
class TestDirectoryTask < Test::Unit::TestCase
|
95
|
-
include Rake
|
96
|
-
|
97
|
-
def setup
|
98
|
-
rm_rf "testdata", :verbose=>false
|
99
|
-
end
|
100
|
-
|
101
|
-
def teardown
|
102
|
-
rm_rf "testdata", :verbose=>false
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_directory
|
106
|
-
desc "DESC"
|
107
|
-
directory "testdata/a/b/c"
|
108
|
-
assert_equal FileCreationTask, Task["testdata"].class
|
109
|
-
assert_equal FileCreationTask, Task["testdata/a"].class
|
110
|
-
assert_equal FileCreationTask, Task["testdata/a/b/c"].class
|
111
|
-
assert_nil Task["testdata"].comment
|
112
|
-
assert_equal "DESC", Task["testdata/a/b/c"].comment
|
113
|
-
assert_nil Task["testdata/a/b"].comment
|
114
|
-
verbose(false) {
|
115
|
-
Task['testdata/a/b'].invoke
|
116
|
-
}
|
117
|
-
assert File.exist?("testdata/a/b")
|
118
|
-
assert ! File.exist?("testdata/a/b/c")
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_directory_win32
|
122
|
-
desc "WIN32 DESC"
|
123
|
-
FileUtils.mkdir_p("testdata")
|
124
|
-
Dir.chdir("testdata") do
|
125
|
-
directory 'c:/testdata/a/b/c'
|
126
|
-
assert_equal FileCreationTask, Task['c:/testdata'].class
|
127
|
-
assert_equal FileCreationTask, Task['c:/testdata/a'].class
|
128
|
-
assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
|
129
|
-
assert_nil Task['c:/testdata'].comment
|
130
|
-
assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
|
131
|
-
assert_nil Task['c:/testdata/a/b'].comment
|
132
|
-
verbose(false) {
|
133
|
-
Task['c:/testdata/a/b'].invoke
|
134
|
-
}
|
135
|
-
assert File.exist?('c:/testdata/a/b')
|
136
|
-
assert ! File.exist?('c:/testdata/a/b/c')
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
@@ -1,618 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rake'
|
5
|
-
|
6
|
-
require 'test/capture_stdout'
|
7
|
-
|
8
|
-
class TestFileList < Test::Unit::TestCase
|
9
|
-
FileList = Rake::FileList
|
10
|
-
include CaptureStdout
|
11
|
-
|
12
|
-
def setup
|
13
|
-
create_test_data
|
14
|
-
end
|
15
|
-
|
16
|
-
def teardown
|
17
|
-
# FileList.select_default_ignore_patterns
|
18
|
-
FileUtils.rm_rf("testdata")
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_delgating_methods_do_not_include_to_a_or_to_ary
|
22
|
-
assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
|
23
|
-
assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
|
24
|
-
assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
|
25
|
-
assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_create
|
29
|
-
fl = FileList.new
|
30
|
-
assert_equal 0, fl.size
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_create_with_args
|
34
|
-
fl = FileList.new("testdata/*.c", "x")
|
35
|
-
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
36
|
-
fl.sort
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_create_with_block
|
40
|
-
fl = FileList.new { |f| f.include("x") }
|
41
|
-
assert_equal ["x"], fl.resolve
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create_with_brackets
|
45
|
-
fl = FileList["testdata/*.c", "x"]
|
46
|
-
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
47
|
-
fl.sort
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_create_with_brackets_and_filelist
|
51
|
-
fl = FileList[FileList["testdata/*.c", "x"]]
|
52
|
-
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
53
|
-
fl.sort
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_include_with_another_array
|
57
|
-
fl = FileList.new.include(["x", "y", "z"])
|
58
|
-
assert_equal ["x", "y", "z"].sort, fl.sort
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_include_with_another_filelist
|
62
|
-
fl = FileList.new.include(FileList["testdata/*.c", "x"])
|
63
|
-
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
64
|
-
fl.sort
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_append
|
68
|
-
fl = FileList.new
|
69
|
-
fl << "a.rb" << "b.rb"
|
70
|
-
assert_equal ['a.rb', 'b.rb'], fl
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_add_many
|
74
|
-
fl = FileList.new
|
75
|
-
fl.include %w(a d c)
|
76
|
-
fl.include('x', 'y')
|
77
|
-
assert_equal ['a', 'd', 'c', 'x', 'y'], fl
|
78
|
-
assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_add_return
|
82
|
-
f = FileList.new
|
83
|
-
g = f << "x"
|
84
|
-
assert_equal f.object_id, g.object_id
|
85
|
-
h = f.include("y")
|
86
|
-
assert_equal f.object_id, h.object_id
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_match
|
90
|
-
fl = FileList.new
|
91
|
-
fl.include('test/test*.rb')
|
92
|
-
assert fl.include?("test/test_filelist.rb")
|
93
|
-
assert fl.size > 3
|
94
|
-
fl.each { |fn| assert_match(/\.rb$/, fn) }
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_add_matching
|
98
|
-
fl = FileList.new
|
99
|
-
fl << "a.java"
|
100
|
-
fl.include("test/*.rb")
|
101
|
-
assert_equal "a.java", fl[0]
|
102
|
-
assert fl.size > 2
|
103
|
-
assert fl.include?("test/test_filelist.rb")
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_multiple_patterns
|
107
|
-
create_test_data
|
108
|
-
fl = FileList.new
|
109
|
-
fl.include('*.c', '*xist*')
|
110
|
-
assert_equal [], fl
|
111
|
-
fl.include('testdata/*.c', 'testdata/*xist*')
|
112
|
-
assert_equal [
|
113
|
-
'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
|
114
|
-
].sort, fl.sort
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_square_bracket_pattern
|
118
|
-
fl = FileList.new
|
119
|
-
fl.include("testdata/abc.[ch]")
|
120
|
-
assert fl.size == 2
|
121
|
-
assert fl.include?("testdata/abc.c")
|
122
|
-
assert fl.include?("testdata/abc.h")
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_curly_bracket_pattern
|
126
|
-
fl = FileList.new
|
127
|
-
fl.include("testdata/abc.{c,h}")
|
128
|
-
assert fl.size == 2
|
129
|
-
assert fl.include?("testdata/abc.c")
|
130
|
-
assert fl.include?("testdata/abc.h")
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_reject
|
134
|
-
fl = FileList.new
|
135
|
-
fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
|
136
|
-
fl.reject! { |fn| fn =~ %r{/x} }
|
137
|
-
assert_equal [
|
138
|
-
'testdata/abc.c', 'testdata/existing'
|
139
|
-
], fl
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_exclude
|
143
|
-
fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
|
144
|
-
fl.each { |fn| touch fn, :verbose => false }
|
145
|
-
x = fl.exclude(%r{/x.+\.})
|
146
|
-
assert_equal FileList, x.class
|
147
|
-
assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
|
148
|
-
assert_equal fl.object_id, x.object_id
|
149
|
-
fl.exclude('testdata/*.c')
|
150
|
-
assert_equal ['testdata/existing'], fl
|
151
|
-
fl.exclude('testdata/existing')
|
152
|
-
assert_equal [], fl
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_excluding_via_block
|
156
|
-
fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
|
157
|
-
fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
|
158
|
-
assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
|
159
|
-
assert_equal ['testdata/a.c', 'testdata/b.c'], fl
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_exclude_return_on_create
|
163
|
-
fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
|
164
|
-
assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
|
165
|
-
assert_equal FileList, fl.class
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_exclude_with_string_return_on_create
|
169
|
-
fl = FileList['testdata/*'].exclude('testdata/abc.c')
|
170
|
-
assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
|
171
|
-
assert_equal FileList, fl.class
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_default_exclude
|
175
|
-
fl = FileList.new
|
176
|
-
fl.clear_exclude
|
177
|
-
fl.include("**/*~", "**/*.bak", "**/core")
|
178
|
-
assert fl.member?("testdata/core"), "Should include core"
|
179
|
-
assert fl.member?("testdata/x.bak"), "Should include .bak files"
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_unique
|
183
|
-
fl = FileList.new
|
184
|
-
fl << "x.c" << "a.c" << "b.rb" << "a.c"
|
185
|
-
assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl
|
186
|
-
fl.uniq!
|
187
|
-
assert_equal ['x.c', 'a.c', 'b.rb'], fl
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_to_string
|
191
|
-
fl = FileList.new
|
192
|
-
fl << "a.java" << "b.java"
|
193
|
-
assert_equal "a.java b.java", fl.to_s
|
194
|
-
assert_equal "a.java b.java", "#{fl}"
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_to_array
|
198
|
-
fl = FileList['a.java', 'b.java']
|
199
|
-
assert_equal ['a.java', 'b.java'], fl.to_a
|
200
|
-
assert_equal Array, fl.to_a.class
|
201
|
-
assert_equal ['a.java', 'b.java'], fl.to_ary
|
202
|
-
assert_equal Array, fl.to_ary.class
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_to_s_pending
|
206
|
-
fl = FileList['testdata/abc.*']
|
207
|
-
result = fl.to_s
|
208
|
-
assert_match(%r{testdata/abc\.c}, result)
|
209
|
-
assert_match(%r{testdata/abc\.h}, result)
|
210
|
-
assert_match(%r{testdata/abc\.x}, result)
|
211
|
-
assert_match(%r{(testdata/abc\..\b ?){2}}, result)
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_inspect_pending
|
215
|
-
fl = FileList['testdata/abc.*']
|
216
|
-
result = fl.inspect
|
217
|
-
assert_match(%r{"testdata/abc\.c"}, result)
|
218
|
-
assert_match(%r{"testdata/abc\.h"}, result)
|
219
|
-
assert_match(%r{"testdata/abc\.x"}, result)
|
220
|
-
assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_sub
|
224
|
-
fl = FileList["testdata/*.c"]
|
225
|
-
f2 = fl.sub(/\.c$/, ".o")
|
226
|
-
assert_equal FileList, f2.class
|
227
|
-
assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
|
228
|
-
f2.sort
|
229
|
-
f3 = fl.gsub(/\.c$/, ".o")
|
230
|
-
assert_equal FileList, f3.class
|
231
|
-
assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
|
232
|
-
f3.sort
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_claim_to_be_a_kind_of_array
|
236
|
-
fl = FileList['testdata/*.c']
|
237
|
-
assert fl.is_a?(Array)
|
238
|
-
assert fl.kind_of?(Array)
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_claim_to_be_a_kind_of_filelist
|
242
|
-
fl = FileList['testdata/*.c']
|
243
|
-
assert fl.is_a?(FileList)
|
244
|
-
assert fl.kind_of?(FileList)
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_claim_to_be_a_filelist_instance
|
248
|
-
fl = FileList['testdata/*.c']
|
249
|
-
assert fl.instance_of?(FileList)
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_dont_claim_to_be_an_array_instance
|
253
|
-
fl = FileList['testdata/*.c']
|
254
|
-
assert ! fl.instance_of?(Array)
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_sub!
|
258
|
-
f = "x/a.c"
|
259
|
-
fl = FileList[f, "x/b.c"]
|
260
|
-
res = fl.sub!(/\.c$/, ".o")
|
261
|
-
assert_equal ["x/a.o", "x/b.o"].sort, fl.sort
|
262
|
-
assert_equal "x/a.c", f
|
263
|
-
assert_equal fl.object_id, res.object_id
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_sub_with_block
|
267
|
-
fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"]
|
268
|
-
# The block version doesn't work the way I want it to ...
|
269
|
-
# f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" }
|
270
|
-
f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class")
|
271
|
-
assert_equal [
|
272
|
-
"classes/org/onestepback/a.class",
|
273
|
-
"classes/org/onestepback/b.class"
|
274
|
-
].sort,
|
275
|
-
f2.sort
|
276
|
-
end
|
277
|
-
|
278
|
-
def test_string_ext
|
279
|
-
assert_equal "one.net", "one.two".ext("net")
|
280
|
-
assert_equal "one.net", "one.two".ext(".net")
|
281
|
-
assert_equal "one.net", "one".ext("net")
|
282
|
-
assert_equal "one.net", "one".ext(".net")
|
283
|
-
assert_equal "one.two.net", "one.two.c".ext(".net")
|
284
|
-
assert_equal "one/two.net", "one/two.c".ext(".net")
|
285
|
-
assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
|
286
|
-
assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
|
287
|
-
assert_equal "one.x/two.net", "one.x/two".ext(".net")
|
288
|
-
assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
|
289
|
-
assert_equal ".onerc.net", ".onerc.dot".ext("net")
|
290
|
-
assert_equal ".onerc.net", ".onerc".ext("net")
|
291
|
-
assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
|
292
|
-
assert_equal "one", "one.two".ext('')
|
293
|
-
assert_equal "one", "one.two".ext
|
294
|
-
assert_equal ".one", ".one.two".ext
|
295
|
-
assert_equal ".one", ".one".ext
|
296
|
-
assert_equal ".", ".".ext("c")
|
297
|
-
assert_equal "..", "..".ext("c")
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_filelist_ext
|
301
|
-
assert_equal FileList['one.c', '.one.c'],
|
302
|
-
FileList['one.net', '.one'].ext('c')
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_gsub
|
306
|
-
create_test_data
|
307
|
-
fl = FileList["testdata/*.c"]
|
308
|
-
f2 = fl.gsub(/a/, "A")
|
309
|
-
assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
|
310
|
-
f2.sort
|
311
|
-
end
|
312
|
-
|
313
|
-
def test_gsub!
|
314
|
-
create_test_data
|
315
|
-
f = FileList["testdata/*.c"]
|
316
|
-
f.gsub!(/a/, "A")
|
317
|
-
assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
|
318
|
-
f.sort
|
319
|
-
end
|
320
|
-
|
321
|
-
def test_egrep_with_output
|
322
|
-
files = FileList['test/test*.rb']
|
323
|
-
the_line_number = __LINE__ + 1
|
324
|
-
out = capture_stdout do files.egrep(/PUGH/) end
|
325
|
-
assert_match(/:#{the_line_number}:/, out)
|
326
|
-
end
|
327
|
-
|
328
|
-
def test_egrep_with_block
|
329
|
-
files = FileList['test/test*.rb']
|
330
|
-
found = false
|
331
|
-
the_line_number = __LINE__ + 1
|
332
|
-
files.egrep(/XYZZY/) do |fn, ln, line |
|
333
|
-
assert_equal 'test/test_filelist.rb', fn
|
334
|
-
assert_equal the_line_number, ln
|
335
|
-
assert_match(/files\.egrep/, line)
|
336
|
-
found = true
|
337
|
-
end
|
338
|
-
assert found, "should have found a matching line"
|
339
|
-
end
|
340
|
-
|
341
|
-
def test_existing
|
342
|
-
fl = FileList['testdata/abc.c', 'testdata/notthere.c']
|
343
|
-
assert_equal ["testdata/abc.c"], fl.existing
|
344
|
-
assert fl.existing.is_a?(FileList)
|
345
|
-
end
|
346
|
-
|
347
|
-
def test_existing!
|
348
|
-
fl = FileList['testdata/abc.c', 'testdata/notthere.c']
|
349
|
-
result = fl.existing!
|
350
|
-
assert_equal ["testdata/abc.c"], fl
|
351
|
-
assert_equal fl.object_id, result.object_id
|
352
|
-
end
|
353
|
-
|
354
|
-
def test_ignore_special
|
355
|
-
f = FileList['testdata/*']
|
356
|
-
assert ! f.include?("testdata/CVS"), "Should not contain CVS"
|
357
|
-
assert ! f.include?("testdata/.svn"), "Should not contain .svn"
|
358
|
-
assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
|
359
|
-
assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
|
360
|
-
assert ! f.include?("testdata/x~"), "Should not contain ~ files"
|
361
|
-
assert ! f.include?("testdata/core"), "Should not contain core files"
|
362
|
-
end
|
363
|
-
|
364
|
-
def test_clear_ignore_patterns
|
365
|
-
f = FileList['testdata/*', 'testdata/.svn']
|
366
|
-
f.clear_exclude
|
367
|
-
assert f.include?("testdata/abc.c")
|
368
|
-
assert f.include?("testdata/xyz.c")
|
369
|
-
assert f.include?("testdata/CVS")
|
370
|
-
assert f.include?("testdata/.svn")
|
371
|
-
assert f.include?("testdata/x.bak")
|
372
|
-
assert f.include?("testdata/x~")
|
373
|
-
end
|
374
|
-
|
375
|
-
def test_exclude_with_alternate_file_seps
|
376
|
-
fl = FileList.new
|
377
|
-
assert fl.exclude?("x/CVS/y")
|
378
|
-
assert fl.exclude?("x\\CVS\\y")
|
379
|
-
assert fl.exclude?("x/.svn/y")
|
380
|
-
assert fl.exclude?("x\\.svn\\y")
|
381
|
-
assert fl.exclude?("x/core")
|
382
|
-
assert fl.exclude?("x\\core")
|
383
|
-
end
|
384
|
-
|
385
|
-
def test_add_default_exclude_list
|
386
|
-
fl = FileList.new
|
387
|
-
fl.exclude(/~\d+$/)
|
388
|
-
assert fl.exclude?("x/CVS/y")
|
389
|
-
assert fl.exclude?("x\\CVS\\y")
|
390
|
-
assert fl.exclude?("x/.svn/y")
|
391
|
-
assert fl.exclude?("x\\.svn\\y")
|
392
|
-
assert fl.exclude?("x/core")
|
393
|
-
assert fl.exclude?("x\\core")
|
394
|
-
assert fl.exclude?("x/abc~1")
|
395
|
-
end
|
396
|
-
|
397
|
-
def test_basic_array_functions
|
398
|
-
f = FileList['b', 'c', 'a']
|
399
|
-
assert_equal 'b', f.first
|
400
|
-
assert_equal 'b', f[0]
|
401
|
-
assert_equal 'a', f.last
|
402
|
-
assert_equal 'a', f[2]
|
403
|
-
assert_equal 'a', f[-1]
|
404
|
-
assert_equal ['a', 'b', 'c'], f.sort
|
405
|
-
f.sort!
|
406
|
-
assert_equal ['a', 'b', 'c'], f
|
407
|
-
end
|
408
|
-
|
409
|
-
def test_flatten
|
410
|
-
assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
|
411
|
-
['a', FileList['testdata/*.c']].flatten.sort
|
412
|
-
end
|
413
|
-
|
414
|
-
def test_clone_and_dup
|
415
|
-
a = FileList['a', 'b', 'c']
|
416
|
-
c = a.clone
|
417
|
-
d = a.dup
|
418
|
-
a << 'd'
|
419
|
-
assert_equal ['a', 'b', 'c', 'd'], a
|
420
|
-
assert_equal ['a', 'b', 'c'], c
|
421
|
-
assert_equal ['a', 'b', 'c'], d
|
422
|
-
end
|
423
|
-
|
424
|
-
def test_dup_and_clone_replicate_taint
|
425
|
-
a = FileList['a', 'b', 'c']
|
426
|
-
a.taint
|
427
|
-
c = a.clone
|
428
|
-
d = a.dup
|
429
|
-
assert c.tainted?, "Clone should be tainted"
|
430
|
-
assert d.tainted?, "Dup should be tainted"
|
431
|
-
end
|
432
|
-
|
433
|
-
def test_duped_items_will_thaw
|
434
|
-
a = FileList['a', 'b', 'c']
|
435
|
-
a.freeze
|
436
|
-
d = a.dup
|
437
|
-
d << 'more'
|
438
|
-
assert_equal ['a', 'b', 'c', 'more'], d
|
439
|
-
end
|
440
|
-
|
441
|
-
def test_cloned_items_stay_frozen
|
442
|
-
a = FileList['a', 'b', 'c']
|
443
|
-
a.freeze
|
444
|
-
c = a.clone
|
445
|
-
assert_raise(TypeError, RuntimeError) do
|
446
|
-
c << 'more'
|
447
|
-
end
|
448
|
-
end
|
449
|
-
|
450
|
-
def test_array_comparisons
|
451
|
-
fl = FileList['b', 'b']
|
452
|
-
a = ['b', 'a']
|
453
|
-
b = ['b', 'b']
|
454
|
-
c = ['b', 'c']
|
455
|
-
assert_equal( 1, fl <=> a )
|
456
|
-
assert_equal( 0, fl <=> b )
|
457
|
-
assert_equal( -1, fl <=> c )
|
458
|
-
assert_equal( -1, a <=> fl )
|
459
|
-
assert_equal( 0, b <=> fl )
|
460
|
-
assert_equal( 1, c <=> fl )
|
461
|
-
end
|
462
|
-
|
463
|
-
def test_array_equality
|
464
|
-
a = FileList['a', 'b']
|
465
|
-
b = ['a', 'b']
|
466
|
-
assert a == b
|
467
|
-
assert b == a
|
468
|
-
# assert a.eql?(b)
|
469
|
-
# assert b.eql?(a)
|
470
|
-
assert ! a.equal?(b)
|
471
|
-
assert ! b.equal?(a)
|
472
|
-
end
|
473
|
-
|
474
|
-
def test_enumeration_methods
|
475
|
-
a = FileList['a', 'b']
|
476
|
-
b = a.collect { |it| it.upcase }
|
477
|
-
assert_equal ['A', 'B'], b
|
478
|
-
assert_equal FileList, b.class
|
479
|
-
|
480
|
-
b = a.map { |it| it.upcase }
|
481
|
-
assert_equal ['A', 'B'], b
|
482
|
-
assert_equal FileList, b.class
|
483
|
-
|
484
|
-
b = a.sort
|
485
|
-
assert_equal ['a', 'b'], b
|
486
|
-
assert_equal FileList, b.class
|
487
|
-
|
488
|
-
b = a.sort_by { |it| it }
|
489
|
-
assert_equal ['a', 'b'], b
|
490
|
-
assert_equal FileList, b.class
|
491
|
-
|
492
|
-
b = a.find_all { |it| it == 'b'}
|
493
|
-
assert_equal ['b'], b
|
494
|
-
assert_equal FileList, b.class
|
495
|
-
|
496
|
-
b = a.select { |it| it.size == 1 }
|
497
|
-
assert_equal ['a', 'b'], b
|
498
|
-
assert_equal FileList, b.class
|
499
|
-
|
500
|
-
b = a.reject { |it| it == 'b' }
|
501
|
-
assert_equal ['a'], b
|
502
|
-
assert_equal FileList, b.class
|
503
|
-
|
504
|
-
b = a.grep(/./)
|
505
|
-
assert_equal ['a', 'b'], b
|
506
|
-
assert_equal FileList, b.class
|
507
|
-
|
508
|
-
b = a.partition { |it| it == 'b' }
|
509
|
-
assert_equal [['b'], ['a']], b
|
510
|
-
assert_equal Array, b.class
|
511
|
-
assert_equal FileList, b[0].class
|
512
|
-
assert_equal FileList, b[1].class
|
513
|
-
|
514
|
-
b = a.zip(['x', 'y']).to_a
|
515
|
-
assert_equal [['a', 'x'], ['b', 'y']], b
|
516
|
-
assert_equal Array, b.class
|
517
|
-
assert_equal Array, b[0].class
|
518
|
-
assert_equal Array, b[1].class
|
519
|
-
end
|
520
|
-
|
521
|
-
def test_array_operators
|
522
|
-
a = ['a', 'b']
|
523
|
-
b = ['c', 'd']
|
524
|
-
f = FileList['x', 'y']
|
525
|
-
g = FileList['w', 'z']
|
526
|
-
|
527
|
-
r = f + g
|
528
|
-
assert_equal ['x', 'y', 'w', 'z'], r
|
529
|
-
assert_equal FileList, r.class
|
530
|
-
|
531
|
-
r = a + g
|
532
|
-
assert_equal ['a', 'b', 'w', 'z'], r
|
533
|
-
assert_equal Array, r.class
|
534
|
-
|
535
|
-
r = f + b
|
536
|
-
assert_equal ['x', 'y', 'c', 'd'], r
|
537
|
-
assert_equal FileList, r.class
|
538
|
-
|
539
|
-
r = FileList['w', 'x', 'y', 'z'] - f
|
540
|
-
assert_equal ['w', 'z'], r
|
541
|
-
assert_equal FileList, r.class
|
542
|
-
|
543
|
-
r = FileList['w', 'x', 'y', 'z'] & f
|
544
|
-
assert_equal ['x', 'y'], r
|
545
|
-
assert_equal FileList, r.class
|
546
|
-
|
547
|
-
r = f * 2
|
548
|
-
assert_equal ['x', 'y', 'x', 'y'], r
|
549
|
-
assert_equal FileList, r.class
|
550
|
-
|
551
|
-
r = f * ','
|
552
|
-
assert_equal 'x,y', r
|
553
|
-
assert_equal String, r.class
|
554
|
-
|
555
|
-
r = f | ['a', 'x']
|
556
|
-
assert_equal ['a', 'x', 'y'].sort, r.sort
|
557
|
-
assert_equal FileList, r.class
|
558
|
-
end
|
559
|
-
|
560
|
-
def test_other_array_returning_methods
|
561
|
-
f = FileList['a', nil, 'b']
|
562
|
-
r = f.compact
|
563
|
-
assert_equal ['a', 'b'], r
|
564
|
-
assert_equal FileList, r.class
|
565
|
-
|
566
|
-
f = FileList['a', 'b']
|
567
|
-
r = f.concat(['x', 'y'])
|
568
|
-
assert_equal ['a', 'b', 'x', 'y'], r
|
569
|
-
assert_equal FileList, r.class
|
570
|
-
|
571
|
-
f = FileList['a', ['b', 'c'], FileList['d', 'e']]
|
572
|
-
r = f.flatten
|
573
|
-
assert_equal ['a', 'b', 'c', 'd', 'e'], r
|
574
|
-
assert_equal FileList, r.class
|
575
|
-
|
576
|
-
f = FileList['a', 'b', 'a']
|
577
|
-
r = f.uniq
|
578
|
-
assert_equal ['a', 'b'], r
|
579
|
-
assert_equal FileList, r.class
|
580
|
-
|
581
|
-
f = FileList['a', 'b', 'c', 'd']
|
582
|
-
r = f.values_at(1,3)
|
583
|
-
assert_equal ['b', 'd'], r
|
584
|
-
assert_equal FileList, r.class
|
585
|
-
end
|
586
|
-
|
587
|
-
def test_file_utils_can_use_filelists
|
588
|
-
cfiles = FileList['testdata/*.c']
|
589
|
-
|
590
|
-
cp cfiles, @cdir, :verbose => false
|
591
|
-
|
592
|
-
assert File.exist?(File.join(@cdir, 'abc.c'))
|
593
|
-
assert File.exist?(File.join(@cdir, 'xyz.c'))
|
594
|
-
assert File.exist?(File.join(@cdir, 'x.c'))
|
595
|
-
end
|
596
|
-
|
597
|
-
def create_test_data
|
598
|
-
verbose(false) do
|
599
|
-
|
600
|
-
mkdir "testdata" unless File.exist? "testdata"
|
601
|
-
mkdir "testdata/CVS" rescue nil
|
602
|
-
mkdir "testdata/.svn" rescue nil
|
603
|
-
@cdir = "testdata/cfiles"
|
604
|
-
mkdir @cdir rescue nil
|
605
|
-
touch "testdata/.dummy"
|
606
|
-
touch "testdata/x.bak"
|
607
|
-
touch "testdata/x~"
|
608
|
-
touch "testdata/core"
|
609
|
-
touch "testdata/x.c"
|
610
|
-
touch "testdata/xyz.c"
|
611
|
-
touch "testdata/abc.c"
|
612
|
-
touch "testdata/abc.h"
|
613
|
-
touch "testdata/abc.x"
|
614
|
-
touch "testdata/existing"
|
615
|
-
end
|
616
|
-
end
|
617
|
-
|
618
|
-
end
|