sprout 0.7.246 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/CHANGELOG.md +10 -0
- data/Gemfile +28 -0
- data/MIT-LICENSE +3 -2
- data/POSTINSTALL.rdoc +28 -0
- data/README.textile +152 -0
- data/bin/sprout +1 -131
- data/bin/sprout-generator +10 -0
- data/bin/sprout-library +11 -0
- data/bin/sprout-tool +10 -0
- data/lib/sprout.rb +4 -500
- data/lib/sprout/archive_unpacker.rb +122 -206
- data/lib/sprout/base.rb +90 -0
- data/lib/sprout/concern.rb +30 -0
- data/lib/sprout/dir.rb +23 -0
- data/lib/sprout/errors.rb +94 -0
- data/lib/sprout/executable.rb +496 -0
- data/lib/sprout/executable/boolean.rb +35 -0
- data/lib/sprout/executable/collection_param.rb +53 -0
- data/lib/sprout/executable/file_param.rb +53 -0
- data/lib/sprout/executable/files.rb +26 -0
- data/lib/sprout/executable/number.rb +10 -0
- data/lib/sprout/executable/param.rb +222 -0
- data/lib/sprout/executable/parameter_factory.rb +28 -0
- data/lib/sprout/executable/path.rb +21 -0
- data/lib/sprout/executable/paths.rb +21 -0
- data/lib/sprout/executable/string_param.rb +15 -0
- data/lib/sprout/executable/strings.rb +11 -0
- data/lib/sprout/executable/url.rb +10 -0
- data/lib/sprout/executable/urls.rb +10 -0
- data/lib/sprout/file_target.rb +76 -0
- data/lib/sprout/generator/base.rb +233 -0
- data/lib/sprout/generator/command.rb +67 -0
- data/lib/sprout/generator/directory_manifest.rb +49 -0
- data/lib/sprout/generator/file_manifest.rb +55 -0
- data/lib/sprout/generator/manifest.rb +13 -0
- data/lib/sprout/generator/template_manifest.rb +13 -0
- data/lib/sprout/generators/generator/generator_generator.rb +48 -0
- data/lib/sprout/generators/generator/templates/generator_class.rb +17 -0
- data/lib/sprout/generators/generator/templates/generator_executable +9 -0
- data/lib/sprout/generators/generator/templates/generator_template +1 -0
- data/lib/sprout/generators/generator/templates/generator_test.rb +37 -0
- data/lib/sprout/generators/generator/templates/generator_test_helper.rb +16 -0
- data/lib/sprout/generators/library/library_generator.rb +20 -0
- data/lib/sprout/generators/library/templates/library.gemspec +19 -0
- data/lib/sprout/generators/library/templates/library.rb +15 -0
- data/lib/sprout/generators/ruby/ruby_generator.rb +59 -0
- data/lib/sprout/generators/ruby/templates/ruby_base.rb +10 -0
- data/lib/sprout/generators/ruby/templates/ruby_executable +6 -0
- data/lib/sprout/generators/ruby/templates/ruby_gemfile +4 -0
- data/lib/sprout/generators/ruby/templates/ruby_input.rb +7 -0
- data/lib/sprout/generators/tool/templates/Gemfile +4 -0
- data/lib/sprout/generators/tool/templates/tool.gemspec +22 -0
- data/lib/sprout/generators/tool/templates/tool.rb +38 -0
- data/lib/sprout/generators/tool/tool_generator.rb +36 -0
- data/lib/sprout/library.rb +111 -0
- data/lib/sprout/log.rb +1 -0
- data/lib/sprout/platform.rb +71 -0
- data/lib/sprout/process_runner.rb +80 -40
- data/lib/sprout/progress_bar.rb +341 -0
- data/lib/sprout/rdoc_parser.rb +91 -0
- data/lib/sprout/remote_file_loader.rb +72 -50
- data/lib/sprout/remote_file_target.rb +44 -152
- data/lib/sprout/ruby_feature.rb +167 -0
- data/lib/sprout/specification.rb +197 -0
- data/lib/sprout/string.rb +19 -0
- data/lib/sprout/system.rb +35 -0
- data/lib/sprout/system/base_system.rb +225 -0
- data/lib/sprout/system/java_system.rb +9 -0
- data/lib/sprout/system/osx_system.rb +26 -0
- data/lib/sprout/system/unix_system.rb +72 -0
- data/lib/sprout/system/vista_system.rb +16 -0
- data/lib/sprout/system/win_nix_system.rb +41 -0
- data/lib/sprout/system/win_system.rb +76 -0
- data/lib/sprout/test/sprout_test_case.rb +211 -0
- data/lib/sprout/version.rb +9 -4
- data/rakefile.rb +85 -144
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/sprout.gemspec +26 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.exe +0 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.rb +0 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.swc +0 -0
- data/test/fixtures/archive_unpacker/tgz/some folder.tgz +0 -0
- data/test/fixtures/archive_unpacker/tgz/some_file.tgz +0 -0
- data/test/fixtures/archive_unpacker/zip/some folder.zip +0 -0
- data/test/fixtures/archive_unpacker/zip/some_file.zip +0 -0
- data/test/fixtures/examples/app_generator.rb +127 -0
- data/test/fixtures/examples/echo_inputs.rb +151 -0
- data/test/fixtures/executable/echochamber_gem/bin/echochamber +3 -0
- data/test/fixtures/executable/echochamber_gem/echo_chamber.rb +10 -0
- data/test/fixtures/executable/flex3sdk_gem/flex3sdk.rb +11 -0
- data/test/fixtures/executable/flex3sdk_gem/mxmlc +3 -0
- data/test/fixtures/executable/flex3sdk_gem/mxmlc.bat +3 -0
- data/test/fixtures/executable/mxmlc.rb +805 -0
- data/test/fixtures/executable/params/input.as +0 -0
- data/test/fixtures/executable/params/input2.as +0 -0
- data/test/fixtures/executable/params/input3.as +0 -0
- data/test/fixtures/executable/params/mxmlc +5 -0
- data/test/fixtures/executable/path with spaces/input.as b/data/test/fixtures/executable/path with → spaces/input.as +0 -0
- data/test/fixtures/executable/path with spaces/input2.as b/data/test/fixtures/executable/path with → spaces/input2.as +0 -0
- data/test/fixtures/executable/path with spaces/input3.as b/data/test/fixtures/executable/path with → spaces/input3.as +0 -0
- data/test/fixtures/executable/paths/folder1/file1 +0 -0
- data/test/fixtures/executable/paths/folder1/file2 +0 -0
- data/test/fixtures/executable/paths/folder1/file3 +0 -0
- data/test/fixtures/executable/paths/folder2/file4 +0 -0
- data/test/fixtures/executable/paths/folder2/file5 +0 -0
- data/test/fixtures/executable/paths/folder3/file6 +0 -0
- data/test/fixtures/executable/src/Main.as +0 -0
- data/test/fixtures/executable/windows_line_endings +47 -0
- data/test/fixtures/generators/song_generator.rb +11 -0
- data/test/fixtures/generators/song_subclass/least_favorite.rb +10 -0
- data/test/fixtures/generators/song_subclass/templates/Song.txt +3 -0
- data/test/fixtures/generators/temp_generator.rb +24 -0
- data/test/fixtures/generators/templates/Main.as +9 -0
- data/test/fixtures/generators/templates/OtherFileTemplate +1 -0
- data/test/fixtures/generators/templates/SomeFile +1 -0
- data/test/fixtures/generators/templates/SomeSubclassFile +2 -0
- data/test/fixtures/generators/templates/Song.txt +3 -0
- data/test/fixtures/generators/templates/destroy +0 -0
- data/test/fixtures/generators/templates/generate +0 -0
- data/test/fixtures/library/archive/Archive.swc +0 -0
- data/test/fixtures/library/sources/lib/a/A.as +0 -0
- data/test/fixtures/library/sources/lib/b/B.as +0 -0
- data/test/fixtures/library/sources/src/Source.as +0 -0
- data/test/fixtures/process_runner/chmod_script.sh +3 -0
- data/test/fixtures/process_runner/dir with spaces/chmod_script.sh +3 -0
- data/test/fixtures/process_runner/failure +5 -0
- data/test/fixtures/process_runner/success +4 -0
- data/test/fixtures/remote_file_loader/md5/echochamber-test.zip +0 -0
- data/test/fixtures/remote_file_loader/md5/file_with_known_md5 +0 -0
- data/test/fixtures/remote_file_target/bin/echochamber +3 -0
- data/test/fixtures/remote_file_target/bin/echochamber.bat +3 -0
- data/test/fixtures/remote_file_target/echochamber-test.zip +0 -0
- data/test/fixtures/specification/asunit4.rb +25 -0
- data/test/fixtures/specification/ext/AsUnit-4.1.pre.swc +0 -0
- data/test/fixtures/specification/flashplayer.rb +30 -0
- data/test/fixtures/specification/flex4sdk.rb +72 -0
- data/test/fixtures/specification/flexunit4.sproutspec +17 -0
- data/test/fixtures/specification/lib/as3reflection/Reflection.as +0 -0
- data/test/fixtures/specification/src/AsUnit.as +0 -0
- data/test/fixtures/user/mxmlc_crlf +3 -0
- data/test/unit/archive_unpacker_test.rb +108 -0
- data/test/unit/boolean_param_test.rb +38 -0
- data/test/unit/executable_option_parser_test.rb +142 -0
- data/test/unit/executable_param_test.rb +76 -0
- data/test/unit/executable_test.rb +237 -0
- data/test/unit/fake_executable_task.rb +22 -0
- data/test/unit/fake_other_executable.rb +20 -0
- data/test/unit/fake_process_runner.rb +29 -0
- data/test/unit/file_param_test.rb +61 -0
- data/test/unit/file_target_test.rb +42 -0
- data/test/unit/files_param_test.rb +72 -0
- data/test/unit/generator_generator_test.rb +85 -0
- data/test/unit/generator_test.rb +333 -0
- data/test/unit/library_generator_test.rb +41 -0
- data/test/unit/library_test.rb +88 -0
- data/test/unit/osx_system_test.rb +20 -0
- data/test/unit/path_param_test.rb +43 -0
- data/test/unit/paths_param_test.rb +53 -0
- data/test/unit/platform_test.rb +76 -0
- data/test/unit/process_runner_test.rb +104 -0
- data/test/unit/rdoc_parser_test.rb +15 -0
- data/test/unit/remote_file_loader_test.rb +34 -0
- data/test/unit/remote_file_target_test.rb +105 -0
- data/test/unit/ruby_feature_test.rb +108 -0
- data/test/unit/ruby_generator_test.rb +70 -0
- data/test/unit/specification_test.rb +73 -0
- data/test/unit/sprout_test.rb +170 -0
- data/test/unit/sprout_test_helper.rb +18 -0
- data/test/unit/string_param_test.rb +19 -0
- data/test/unit/string_test.rb +20 -0
- data/test/unit/strings_param_test.rb +27 -0
- data/test/unit/test_helper.rb +1 -0
- data/test/unit/tool_generator_test.rb +43 -0
- data/test/unit/unix_system_test.rb +52 -0
- data/test/unit/user_test.rb +147 -0
- data/test/unit/vista_system_test.rb +40 -0
- data/test/unit/win_nix_system_test.rb +26 -0
- data/test/unit/win_system_test.rb +61 -0
- metadata +318 -113
- data/doc/Bundle +0 -14
- data/doc/Generator +0 -35
- data/doc/Library +0 -63
- data/doc/Task +0 -21
- data/doc/Tool +0 -20
- data/lib/platform.rb +0 -113
- data/lib/progress_bar.rb +0 -354
- data/lib/sprout/builder.rb +0 -51
- data/lib/sprout/bundle_resolver.rb +0 -349
- data/lib/sprout/commands/generate.rb +0 -9
- data/lib/sprout/dynamic_accessors.rb +0 -40
- data/lib/sprout/general_tasks.rb +0 -6
- data/lib/sprout/generator.rb +0 -7
- data/lib/sprout/generator/base_mixins.rb +0 -186
- data/lib/sprout/generator/named_base.rb +0 -227
- data/lib/sprout/project_model.rb +0 -278
- data/lib/sprout/simple_resolver.rb +0 -88
- data/lib/sprout/tasks/erb_resolver.rb +0 -118
- data/lib/sprout/tasks/gem_wrap_task.rb +0 -214
- data/lib/sprout/tasks/git_task.rb +0 -134
- data/lib/sprout/tasks/library_task.rb +0 -118
- data/lib/sprout/tasks/sftp_task.rb +0 -248
- data/lib/sprout/tasks/ssh_task.rb +0 -153
- data/lib/sprout/tasks/tool_task.rb +0 -836
- data/lib/sprout/tasks/zip_task.rb +0 -158
- data/lib/sprout/tool_task_model.rb +0 -19
- data/lib/sprout/user.rb +0 -415
- data/lib/sprout/version_file.rb +0 -89
- data/lib/sprout/zip_util.rb +0 -61
- data/samples/gem_wrap/rakefile.rb +0 -17
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
require 'sprout/generators/library/library_generator'
|
4
|
+
|
5
|
+
class LibraryGeneratorTest < Test::Unit::TestCase
|
6
|
+
include SproutTestCase
|
7
|
+
|
8
|
+
context "A generated library" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
@temp = File.join(fixtures, 'generators', 'library')
|
12
|
+
FileUtils.mkdir_p @temp
|
13
|
+
@generator = Sprout::LibraryGenerator.new
|
14
|
+
@generator.path = @temp
|
15
|
+
@generator.logger = StringIO.new
|
16
|
+
end
|
17
|
+
|
18
|
+
teardown do
|
19
|
+
remove_file @temp
|
20
|
+
end
|
21
|
+
|
22
|
+
should "generate a new library" do
|
23
|
+
@generator.input = 'flexunit'
|
24
|
+
@generator.version = '4.2.pre'
|
25
|
+
@generator.execute
|
26
|
+
|
27
|
+
assert_file @temp
|
28
|
+
assert_file File.join(@temp, 'flexunit.gemspec') do |content|
|
29
|
+
assert_matches /s.name\s+= Flexunit::NAME/, content
|
30
|
+
assert_matches /s.version\s+= Flexunit::VERSION/, content
|
31
|
+
assert_matches /s.author\s+= "Your Name"/, content
|
32
|
+
end
|
33
|
+
assert_file File.join(@temp, 'flexunit.rb') do |content|
|
34
|
+
assert_matches /NAME\s+= 'flexunit'/, content
|
35
|
+
assert_matches /VERSION\s+= '4.2.pre'/, content
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class LibraryTest < Test::Unit::TestCase
|
4
|
+
include SproutTestCase
|
5
|
+
|
6
|
+
context "a new archive library" do
|
7
|
+
setup do
|
8
|
+
@path = File.join fixtures, 'library', 'archive'
|
9
|
+
@archive = File.join @path, 'Archive.swc'
|
10
|
+
create_and_register_library :fake_archive_lib, @archive
|
11
|
+
end
|
12
|
+
|
13
|
+
should "be able to load registered libraries" do
|
14
|
+
lib = Sprout::Library.load :fake_archive_lib
|
15
|
+
assert_not_nil lib
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "a new precompiled library" do
|
20
|
+
setup do
|
21
|
+
fixture = File.join fixtures, 'library'
|
22
|
+
@lib_dir = File.join fixture, 'project_lib'
|
23
|
+
sources = File.join fixture, 'sources'
|
24
|
+
@src = File.join sources, 'src', 'Source.as'
|
25
|
+
Sprout::Library.project_path = @lib_dir
|
26
|
+
create_and_register_library :fake_swc_lib, @src
|
27
|
+
end
|
28
|
+
|
29
|
+
should "create rake file tasks for single files" do
|
30
|
+
Sprout::Library.define_task :fake_swc_lib
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "a new source library" do
|
35
|
+
setup do
|
36
|
+
fixture = File.join fixtures, 'library'
|
37
|
+
@lib_dir = File.join fixture, 'project_lib'
|
38
|
+
sources = File.join fixture, 'sources'
|
39
|
+
@lib_a = File.join sources, 'lib', 'a'
|
40
|
+
@lib_b = File.join sources, 'lib', 'b'
|
41
|
+
@src = File.join sources, 'src'
|
42
|
+
Sprout::Library.project_path = @lib_dir
|
43
|
+
create_and_register_library :fake_source_lib, [@src, @lib_a, @lib_b]
|
44
|
+
end
|
45
|
+
|
46
|
+
teardown do
|
47
|
+
Sprout::Library.project_path = nil
|
48
|
+
remove_file @lib_dir
|
49
|
+
end
|
50
|
+
|
51
|
+
should "be able to load registered libraries" do
|
52
|
+
lib = Sprout::Library.load :fake_source_lib
|
53
|
+
assert_not_nil lib
|
54
|
+
paths = lib.path.dup
|
55
|
+
assert_equal @src, paths.shift
|
56
|
+
assert_equal @lib_a, paths.shift
|
57
|
+
assert_equal @lib_b, paths.shift
|
58
|
+
end
|
59
|
+
|
60
|
+
should "create rake file tasks for directories" do
|
61
|
+
Sprout::Library.define_task :fake_source_lib
|
62
|
+
Rake::application[:resolve_sprout_libraries].invoke
|
63
|
+
|
64
|
+
library_dir = File.join(@lib_dir, 'fake_source_lib')
|
65
|
+
assert_file library_dir
|
66
|
+
assert_file File.join(library_dir, 'Source.as')
|
67
|
+
assert_file File.join(library_dir, 'a')
|
68
|
+
assert_file File.join(library_dir, 'b')
|
69
|
+
end
|
70
|
+
|
71
|
+
should "load the library from the load_path" do
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def create_and_register_library name, path, pkg_name=nil, pkg_version=nil
|
79
|
+
lib = OpenStruct.new
|
80
|
+
lib.name = name
|
81
|
+
lib.path = path
|
82
|
+
lib.pkg_name = pkg_name unless pkg_name.nil?
|
83
|
+
lib.pkg_version = pkg_version unless pkg_version.nil?
|
84
|
+
|
85
|
+
Sprout::Library.register lib
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class OSXSystemTest < Test::Unit::TestCase
|
4
|
+
include SproutTestCase
|
5
|
+
|
6
|
+
context "new osx system" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@user = Sprout::System::OSXSystem.new
|
10
|
+
@user.stubs(:home).returns '/Users/someone'
|
11
|
+
end
|
12
|
+
|
13
|
+
should "capitalize application name" do
|
14
|
+
File.stubs(:exists?).returns true
|
15
|
+
assert_equal '/Users/someone/Library/Sprouts', @user.application_home('sprouts')
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class PathParamTest < Test::Unit::TestCase
|
4
|
+
include SproutTestCase
|
5
|
+
|
6
|
+
context "a new PathParam" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@path1 = File.join(fixtures, 'executable', 'paths', 'folder1')
|
10
|
+
|
11
|
+
@param = Sprout::Executable::Path.new
|
12
|
+
@param.belongs_to = FakeExecutableTask.new
|
13
|
+
@param.name = 'path'
|
14
|
+
end
|
15
|
+
|
16
|
+
should "accept a collection of paths" do
|
17
|
+
@param.value = @path1
|
18
|
+
|
19
|
+
assert_equal "-path=#{@path1}", @param.to_shell
|
20
|
+
# All child files have been added as prerequisites:
|
21
|
+
assert_equal 3, @param.belongs_to.prerequisites.size
|
22
|
+
end
|
23
|
+
|
24
|
+
should "accept a custom file expression" do
|
25
|
+
@param.file_expression = "file2"
|
26
|
+
@param.value = @path1
|
27
|
+
assert_equal "-path=#{@path1}", @param.to_shell
|
28
|
+
# All child files have been added as prerequisites:
|
29
|
+
assert_equal 1, @param.belongs_to.prerequisites.size
|
30
|
+
end
|
31
|
+
|
32
|
+
should "accept hidden_name parameter" do
|
33
|
+
@param.hidden_name = true
|
34
|
+
@param.value = @path1
|
35
|
+
assert_equal @path1, @param.to_shell
|
36
|
+
# All child files have been added as prerequisites:
|
37
|
+
assert_equal 3, @param.belongs_to.prerequisites.size
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class PathsParamTest < Test::Unit::TestCase
|
4
|
+
include SproutTestCase
|
5
|
+
|
6
|
+
context "a new PathsParam" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@path1 = File.join(fixtures, 'executable', 'paths', 'folder1')
|
10
|
+
@path2 = File.join(fixtures, 'executable', 'paths', 'folder2')
|
11
|
+
@path3 = File.join(fixtures, 'executable', 'paths', 'folder3')
|
12
|
+
|
13
|
+
@param = Sprout::Executable::Paths.new
|
14
|
+
@param.belongs_to = FakeExecutableTask.new
|
15
|
+
@param.name = 'paths'
|
16
|
+
end
|
17
|
+
|
18
|
+
should "accept a collection of paths" do
|
19
|
+
@param.value << @path1
|
20
|
+
@param.value << @path2
|
21
|
+
@param.value << @path3
|
22
|
+
|
23
|
+
as_each_system do |sys|
|
24
|
+
assert_equal "-paths+=#{sys.clean_path(@path1)} -paths+=#{sys.clean_path(@path2)} -paths+=#{sys.clean_path(@path3)}", @param.to_shell
|
25
|
+
end
|
26
|
+
|
27
|
+
# All child files have been added as prerequisites:
|
28
|
+
assert_equal 6, @param.belongs_to.prerequisites.size
|
29
|
+
end
|
30
|
+
|
31
|
+
should "accept a custom file expression" do
|
32
|
+
@param.file_expression = "file2"
|
33
|
+
@param.value << @path1
|
34
|
+
|
35
|
+
as_each_system do |sys|
|
36
|
+
assert_equal "-paths+=#{sys.clean_path(@path1)}", @param.to_shell
|
37
|
+
end
|
38
|
+
|
39
|
+
# All child files have been added as prerequisites:
|
40
|
+
assert_equal 1, @param.belongs_to.prerequisites.size
|
41
|
+
end
|
42
|
+
|
43
|
+
should "accept hidden_name parameter" do
|
44
|
+
@param.hidden_name = true
|
45
|
+
@param.value << @path1
|
46
|
+
assert_equal @path1, @param.to_shell
|
47
|
+
# All child files have been added as prerequisites:
|
48
|
+
assert_equal 3, @param.belongs_to.prerequisites.size
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class PlatformTest < Test::Unit::TestCase
|
4
|
+
include SproutTestCase
|
5
|
+
|
6
|
+
context "platform" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@platform = Sprout::Platform.new
|
10
|
+
end
|
11
|
+
|
12
|
+
['cygwin', 'mingw', 'bccwin'].each do |variant|
|
13
|
+
context variant do
|
14
|
+
should "know if they're windows nix" do
|
15
|
+
@platform.stubs(:ruby_platform).returns variant
|
16
|
+
assert @platform.windows?, "Windows?"
|
17
|
+
assert @platform.windows_nix?, "Windows Nix?"
|
18
|
+
assert !@platform.java?, "Java?"
|
19
|
+
assert !@platform.mac?, "Mac?"
|
20
|
+
assert !@platform.unix?, "Unix?"
|
21
|
+
assert !@platform.linux?, "Linux?"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
['vista', 'mswin', 'wince', 'emx'].each do |variant|
|
27
|
+
context variant do
|
28
|
+
should "know if they're windows" do
|
29
|
+
@platform.stubs(:ruby_platform).returns variant
|
30
|
+
assert @platform.windows?, "Windows?"
|
31
|
+
assert !@platform.java?, "Java?"
|
32
|
+
assert !@platform.mac?, "Mac?"
|
33
|
+
assert !@platform.unix?, "Unix?"
|
34
|
+
assert !@platform.windows_nix?, "Windows Nix?"
|
35
|
+
assert !@platform.linux?, "Linux?"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
['solaris', 'redhat', 'ubuntu'].each do |variant|
|
41
|
+
context variant do
|
42
|
+
should "know if they're unix" do
|
43
|
+
@platform.stubs(:ruby_platform).returns variant
|
44
|
+
assert @platform.unix?, "Unix?"
|
45
|
+
assert @platform.linux?, "Linux?"
|
46
|
+
assert !@platform.java?, "Java?"
|
47
|
+
assert !@platform.windows?, "Windows?"
|
48
|
+
assert !@platform.mac?, "Mac?"
|
49
|
+
assert !@platform.windows_nix?, "Windows Nix?"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
should "know if they're java" do
|
55
|
+
@platform.stubs(:ruby_platform).returns "java"
|
56
|
+
assert @platform.java?, "Java?"
|
57
|
+
assert !@platform.mac?, "Mac?"
|
58
|
+
assert !@platform.unix?, "Unix?"
|
59
|
+
assert !@platform.windows?, "Windows?"
|
60
|
+
assert !@platform.windows_nix?, "Windows Nix?"
|
61
|
+
assert !@platform.linux?, "Linux?"
|
62
|
+
end
|
63
|
+
|
64
|
+
should "know if they're mac" do
|
65
|
+
@platform.stubs(:ruby_platform).returns "darwin"
|
66
|
+
assert @platform.mac?, "Mac?"
|
67
|
+
assert @platform.unix?, "Unix?"
|
68
|
+
assert !@platform.java?, "Java?"
|
69
|
+
assert !@platform.windows?, "Windows?"
|
70
|
+
assert !@platform.windows_nix?, "Windows Nix?"
|
71
|
+
assert !@platform.linux?, "Linux?"
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ProcessRunnerTest < Test::Unit::TestCase
|
4
|
+
include SproutTestCase
|
5
|
+
|
6
|
+
context "process runner" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@fixture = File.expand_path File.join(fixtures, 'process_runner')
|
10
|
+
@script = File.join @fixture, 'chmod_script.sh'
|
11
|
+
@script_with_spaces = File.join @fixture, 'dir with spaces', 'chmod_script.sh'
|
12
|
+
|
13
|
+
pid = nil
|
14
|
+
write = StringIO.new
|
15
|
+
read = StringIO.new "Hello World"
|
16
|
+
error = StringIO.new
|
17
|
+
|
18
|
+
@runner = Sprout::ProcessRunner.new
|
19
|
+
@runner.stubs(:open4_popen4_block).returns( [pid, write, read, error] )
|
20
|
+
end
|
21
|
+
|
22
|
+
teardown do
|
23
|
+
FileUtils.chmod 0744, @script
|
24
|
+
FileUtils.chmod 0744, @script_with_spaces
|
25
|
+
end
|
26
|
+
|
27
|
+
#--------------------------------------------------
|
28
|
+
context "on nix" do
|
29
|
+
|
30
|
+
should "accept and forward multiple arguments" do
|
31
|
+
@runner.expects(:execute_with_block).once.with("ls", "-la").returns nil
|
32
|
+
@runner.execute_open4 "ls", "-la"
|
33
|
+
end
|
34
|
+
|
35
|
+
should "accept and forward no arguments" do
|
36
|
+
@runner.expects(:execute_with_block).once.with("ls").returns nil
|
37
|
+
@runner.execute_open4 "ls"
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with invalid executable mode" do
|
41
|
+
setup do
|
42
|
+
FileUtils.chmod(0644, @script)
|
43
|
+
FileUtils.chmod(0644, @script_with_spaces)
|
44
|
+
# Raise the Errno::EACCESS (Bad File Mode) error
|
45
|
+
# On the first call only - this should trigger the
|
46
|
+
# File mode update, when encountered
|
47
|
+
@runner.stubs(:open4_popen4_block).once.raises Errno::EACCES
|
48
|
+
end
|
49
|
+
|
50
|
+
context "and arguments" do
|
51
|
+
should "update file mode" do
|
52
|
+
execute_with_open4_and_bad_mode @script, "-n FooBar"
|
53
|
+
end
|
54
|
+
|
55
|
+
context "and spaces in the path" do
|
56
|
+
should "modify invalid file modes for executables" do
|
57
|
+
execute_with_open4_and_bad_mode @script_with_spaces, "-n FooBar"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "and no arguments" do
|
63
|
+
should "update file mode" do
|
64
|
+
execute_with_open4_and_bad_mode @script
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
#--------------------------------------------------
|
72
|
+
context "on win32" do
|
73
|
+
should "accept and forward multiple arguments" do
|
74
|
+
# Comment out the following line to actually execute the process on Windows:
|
75
|
+
@runner.expects(:execute_with_block).once.with("dir").returns nil
|
76
|
+
@runner.execute_win32("dir")
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
context "an unknown process" do
|
84
|
+
should "raise an exception if the executable doesn't exist" do
|
85
|
+
assert_raise Sprout::Errors::ProcessRunnerError do
|
86
|
+
@runner.stubs(:open4_popen4_block).raises Errno::ENOENT
|
87
|
+
@runner.execute_open4('SomeUnknownExecutableThatCantBeInYourPath', '--some-arg true --other-arg false')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def execute_with_open4_and_bad_mode(command, options="")
|
97
|
+
assert !File.stat(command).executable?, "File should not be executable to begin"
|
98
|
+
@runner.expects(:update_executable_mode)
|
99
|
+
@runner.execute_open4 command, options
|
100
|
+
assert_matches /^Hello World/, @runner.read
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'test/fixtures/examples/echo_inputs'
|
3
|
+
|
4
|
+
class ExecutableOptionParserTest < Test::Unit::TestCase
|
5
|
+
include SproutTestCase
|
6
|
+
|
7
|
+
context "a new RDoc parser" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@parser = Sprout::RDocParser.new
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|