fwtoolkit 0.9.3 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/fwt +2 -112
- data/features/cocoapods/setup.feature +60 -0
- data/features/frank/model.feature +20 -0
- data/features/frank/setup.feature +28 -0
- data/features/git/create.feature +29 -0
- data/features/project/create.feature +25 -0
- data/features/step_definitions/aruba_steps.rb +11 -0
- data/features/step_definitions/git_steps.rb +30 -0
- data/features/step_definitions/project_steps.rb +50 -0
- data/features/step_definitions/rvm_steps.rb +11 -0
- data/features/step_definitions/system_steps.rb +8 -0
- data/features/support/env.rb +23 -0
- data/features/support/lib_test/aruba_fwt.rb +30 -0
- data/features/support/lib_test/aruba_mod.rb +28 -0
- data/features/support/lib_test/fake_gem.rb +47 -0
- data/features/xcode/create.feature +42 -0
- data/lib/fwtoolkit/cli/bootstrap.rb +75 -0
- data/lib/fwtoolkit/cli/ci.rb +52 -0
- data/lib/fwtoolkit/cli/cocoapods.rb +73 -0
- data/lib/fwtoolkit/cli/ext/thor.rb +35 -0
- data/lib/fwtoolkit/cli/frank.rb +113 -0
- data/lib/fwtoolkit/cli/fw_actions/template_dir.rb +59 -0
- data/lib/fwtoolkit/cli/fw_actions.rb +2 -0
- data/lib/fwtoolkit/cli/git.rb +42 -0
- data/lib/fwtoolkit/cli/ota.rb +109 -0
- data/lib/fwtoolkit/cli/ota_client/hockeyapp_client.rb +70 -0
- data/lib/fwtoolkit/cli/project.rb +83 -0
- data/lib/fwtoolkit/cli/thorutils.rb +14 -0
- data/lib/fwtoolkit/cli/xcode.rb +105 -0
- data/lib/fwtoolkit/cli.rb +27 -36
- data/lib/fwtoolkit/config/config.sample +8 -0
- data/lib/fwtoolkit/config.rb +41 -0
- data/lib/fwtoolkit/configfile.rb +36 -0
- data/lib/fwtoolkit/executable/executable.rb +45 -0
- data/lib/fwtoolkit/executable.rb +1 -0
- data/lib/fwtoolkit/ext/gem.rb +9 -0
- data/lib/fwtoolkit/ext/hash_yaml.rb +17 -0
- data/lib/fwtoolkit/git_client/git_client.rb +225 -0
- data/lib/fwtoolkit/git_client.rb +1 -0
- data/lib/fwtoolkit/projectfile.rb +50 -0
- data/lib/fwtoolkit/rake/ext/rake.rb +7 -0
- data/lib/fwtoolkit/rake/tasks/ci.rb +25 -0
- data/lib/fwtoolkit/rake/tasks/config.rb +13 -0
- data/lib/fwtoolkit/rake/tasks/ota.rb +31 -0
- data/lib/fwtoolkit/rake/tasks/project.rb +28 -0
- data/lib/fwtoolkit/rake/tasks/test.rb +59 -0
- data/lib/fwtoolkit/rake/tasks/xcode.rb +69 -0
- data/lib/fwtoolkit/rake/tasks.rb +20 -0
- data/lib/fwtoolkit/version.rb +1 -1
- data/lib/fwtoolkit.rb +4 -7
- data/spec/git_client_spec.rb +316 -0
- data/spec/project_config_spec.rb +40 -0
- data/spec/rake/project.rb +28 -0
- data/spec/rake/test.rb +85 -0
- data/spec/rake/xcode.rb +66 -0
- data/spec/support/aruba-doubles-rspec.rb +21 -0
- data/spec/support/ctx_rake.rb +23 -0
- data/spec/support/double_helper.rb +13 -0
- data/spec/support/project_generator.rb +45 -0
- data/templates/default_project/frank/%project_name%/%target_name%/%class_prefix%AppDelegate+Frank.h.tt +15 -0
- data/templates/{cucumber/AppDelegate+Frank.m.erb → default_project/frank/%project_name%/%target_name%/%class_prefix%AppDelegate+Frank.m.tt} +25 -21
- data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/example.feature +0 -0
- data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/step_definitions/launch_steps.rb +0 -0
- data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/support/env.rb +0 -0
- data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/support/mimic.rb +0 -0
- data/templates/default_project/frank/~template_config.rb +11 -0
- data/templates/default_project/frank_seed_core_data/%project_name%/Frank/features/support/models/%class_name%.rb.tt +30 -0
- data/templates/default_project/frank_seed_support/%project_name%/Frank/features/support/models/factories.rb.tt +10 -0
- data/templates/{cucumber → default_project/frank_seed_support/%project_name%/Frank}/features/support/views/my_objects_json.erb +0 -0
- data/templates/{cucumber → default_project/frank_seed_support/%project_name%/Frank}/features/support/views/my_objects_xml.erb +0 -0
- data/templates/{fwt/gitignore.erb → default_project/git/.gitignore} +0 -0
- data/templates/{fwt/rvmrc.erb → default_project/rvm/.rvmrc.tt} +2 -2
- data/templates/default_project/rvm/Gemfile +4 -0
- data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/project.pbxproj.tt +583 -0
- data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/project.xcworkspace/contents.xcworkspacedata.tt +7 -0
- data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/xcshareddata/xcschemes/%project_name%-Release.xcscheme.tt +105 -0
- data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/xcshareddata/xcschemes/%project_name%-Testing.xcscheme.tt +105 -0
- data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/xcshareddata/xcschemes/%project_name%.xcscheme.tt +105 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/%class_prefix%AppDelegate.h.tt +15 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/%class_prefix%AppDelegate.m.tt +49 -0
- data/templates/{fwt/default_project/Info.plist.erb → default_project/xcode/%project_name%/%target_name%/Supporting Files/%project_name%-Info.plist} +0 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/%project_name%-Prefix.pch.tt +14 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/Settings.bundle/Root.plist +53 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/Settings.bundle/en.lproj/Root.strings +0 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/en.lproj/InfoPlist.strings +2 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/fw-shared.xcconfig +49 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/info.plist.h.tt +8 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/main.m.tt +18 -0
- data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/version.sh +159 -0
- data/templates/default_project/xcode/%project_name%/%tests_target_name%/%project_name%Tests.h.tt +13 -0
- data/templates/default_project/xcode/%project_name%/%tests_target_name%/%project_name%Tests.m.tt +32 -0
- data/templates/default_project/xcode/%project_name%/%tests_target_name%/Supporting Files/%tests_target_name%-Info.plist +22 -0
- data/templates/default_project/xcode/%project_name%/%tests_target_name%/Supporting Files/en.lproj/InfoPlist.strings +2 -0
- data/templates/default_project/xcode/%project_name%/Default.png +0 -0
- data/templates/default_project/xcode/%project_name%/Resources/Default-568h@2x.png +0 -0
- data/templates/default_project/xcode/%project_name%/Resources/Default.png +0 -0
- data/templates/default_project/xcode/%project_name%/Resources/Default@2x.png +0 -0
- data/templates/default_project/xcode/%project_name%.xcworkspace/contents.xcworkspacedata.tt +7 -0
- data/templates/default_project/xcode/FWProjectfile.tt +14 -0
- data/templates/default_project/xcode/Podfile.tt +4 -0
- data/templates/default_project/xcode/Rakefile.tt +14 -0
- data/templates/default_project/xcode/cruise_config.rb +3 -0
- data/templates/default_project/xcode/~template_config.rb +5 -0
- metadata +187 -141
- data/lib/fwtoolkit/tasks/build.rb +0 -121
- data/lib/fwtoolkit/tasks/ci.rb +0 -30
- data/lib/fwtoolkit/tasks/cocoapods.rb +0 -32
- data/lib/fwtoolkit/tasks/frank.rb +0 -119
- data/lib/fwtoolkit/tasks/helper.rb +0 -16
- data/lib/fwtoolkit/tasks/services.rb +0 -41
- data/lib/fwtoolkit/tasks.rb +0 -24
- data/lib/fwtoolkit/test/frank_model.rb +0 -120
- data/lib/fwtoolkit/test/misc_steps.rb +0 -9
- data/lib/fwtoolkit/test/model_helper.rb +0 -94
- data/lib/fwtoolkit/test/network_steps.rb +0 -60
- data/lib/fwtoolkit/test/pickle_steps.rb +0 -101
- data/lib/fwtoolkit/test/timeout_helper.rb +0 -21
- data/lib/fwtoolkit/test/ui_helper.rb +0 -19
- data/lib/fwtoolkit/test/ui_steps.rb +0 -17
- data/templates/cucumber/AppDelegate+Frank.h.erb +0 -15
- data/templates/fwt/Gemfile.erb +0 -3
- data/templates/fwt/Podfile.erb +0 -4
- data/templates/fwt/Rakefile.erb +0 -24
- data/templates/fwt/default_project/AppDelegate.h.erb +0 -12
- data/templates/fwt/default_project/AppDelegate.m.erb +0 -20
- data/templates/fwt/default_project/Prefix.pch.erb +0 -6
- data/templates/fwt/default_project/main.m.erb +0 -15
- data/templates/models/factories.rb.erb +0 -10
- data/templates/models/model.rb.erb +0 -30
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'fwtoolkit/configfile'
|
3
|
+
|
4
|
+
module FWToolkit
|
5
|
+
module Projectfile
|
6
|
+
extend self #singleton
|
7
|
+
|
8
|
+
extend FWToolkit::ConfigFile
|
9
|
+
|
10
|
+
def load!(project_root)
|
11
|
+
load_config! projectfile_for_root(project_root)
|
12
|
+
merge_config defaults_with_config(@config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_with_config!(config)
|
16
|
+
load_config_hash! config
|
17
|
+
merge_config defaults_with_config(config)
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate_config
|
21
|
+
unless @config.has_key?(:project_name) && @config.has_key?(:class_prefix)
|
22
|
+
raise NameError, "The project name has to be specified on the configuration file"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def projectfile_for_root(project_root)
|
30
|
+
File.join project_root, 'FWProjectFile'
|
31
|
+
end
|
32
|
+
|
33
|
+
def defaults_with_config(conf_hash)
|
34
|
+
d = Hash.new
|
35
|
+
d[:target_name] = conf_hash[:target_name] || conf_hash[:project_name]
|
36
|
+
d[:binary_name] = "#{conf_hash[:project_name]}"
|
37
|
+
d[:tests_target_name] = conf_hash[:tests_target_name] || "#{conf_hash[:project_name]}Tests"
|
38
|
+
d[:xcode_workspace] = "#{conf_hash[:project_name]}.xcworkspace"
|
39
|
+
d[:xcode_scheme] = { :dev => conf_hash[:project_name],
|
40
|
+
:testing => "#{conf_hash[:project_name]}-Testing",
|
41
|
+
:release => "#{conf_hash[:project_name]}-Release" }
|
42
|
+
d[:xcode_project] = "#{File.join(conf_hash[:project_name], conf_hash[:project_name])}.xcodeproj"
|
43
|
+
d[:source_root] = File.join conf_hash[:project_name], d[:target_name]
|
44
|
+
d[:tests_source_root] = File.join conf_hash[:project_name], d[:tests_target_name]
|
45
|
+
d[:frank_root] = File.join conf_hash[:project_name], d[:target_name], 'Frank'
|
46
|
+
d[:frankified_app] = File.join d[:frank_root], 'frankified_build', 'Frankified.app'
|
47
|
+
d
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fwtoolkit/projectfile'
|
3
|
+
|
4
|
+
module FWToolkit
|
5
|
+
module Rake
|
6
|
+
class CITask < ::Rake::Task
|
7
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
8
|
+
include Config
|
9
|
+
def initialize(&block)
|
10
|
+
yield self if block_given?
|
11
|
+
define_task
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def define_task
|
18
|
+
namespace :ci do
|
19
|
+
desc 'Build'
|
20
|
+
task :build => ['project:update', 'xcode:ci:testing', 'test:build', 'test:ci:frank']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# require 'rake'
|
2
|
+
# require 'fwtoolkit/projectfile'
|
3
|
+
# require 'fwtoolkit/config'
|
4
|
+
# require 'motion-hockeyapp'
|
5
|
+
#
|
6
|
+
# module FWToolkit
|
7
|
+
# module Rake
|
8
|
+
# class OTATask < Rake::Task
|
9
|
+
# include ::Rake::DSL if definied?(::Rare::DSL)
|
10
|
+
#
|
11
|
+
# def initialize(&block)
|
12
|
+
# yield self if block_given?
|
13
|
+
# define_task
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# private
|
18
|
+
#
|
19
|
+
# def define_task
|
20
|
+
# namespace :ota do
|
21
|
+
# desc 'Build IPA file'
|
22
|
+
# task :build_ipa do
|
23
|
+
# run! "xcrun -sdk 'iphoneos' PackageApplication -v '/tmp/artifacts/Applications/#{scheme}.app' -o '/tmp/artifacts/Applications/#{scheme}.ipa' --sign '#{certificate}' --embed '#{provisioning_profile}'"
|
24
|
+
# sh command
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# Need more schemes: debug, testing (releaseota), release all optional
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fwtoolkit/rake/tasks/config'
|
3
|
+
require 'fwtoolkit/projectfile'
|
4
|
+
|
5
|
+
module FWToolkit
|
6
|
+
module Rake
|
7
|
+
class ProjectTask < ::Rake::Task
|
8
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
9
|
+
include Config
|
10
|
+
def initialize(&block)
|
11
|
+
yield self if block_given?
|
12
|
+
define_task
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def define_task
|
19
|
+
namespace :project do
|
20
|
+
desc 'Update pods/gems and submodules'
|
21
|
+
task :update do
|
22
|
+
`fwt proj update`
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fwtoolkit/rake/ext/rake'
|
3
|
+
|
4
|
+
require 'fwtoolkit/rake/tasks/config'
|
5
|
+
require 'fwtoolkit/projectfile'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
module FWToolkit
|
9
|
+
module Rake
|
10
|
+
class TestTask < ::Rake::Task
|
11
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
12
|
+
include Config
|
13
|
+
def initialize(&block)
|
14
|
+
yield self if block_given?
|
15
|
+
define_task
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def define_task
|
22
|
+
namespace :test do
|
23
|
+
|
24
|
+
tasklib = Cucumber::Rake::Task.new(:frank, 'Run Frank acceptance tests')
|
25
|
+
task = ::Rake::Task['test:frank']
|
26
|
+
task.set_arg_names [:tags, :cucumber_options, :sim_launcher]
|
27
|
+
task.enhance_r do |t, args|
|
28
|
+
Projectfile.load! projectfile_path
|
29
|
+
args.with_defaults(:tags => '~@wip', :cucumber_options => '', :sim_launcher => nil)
|
30
|
+
ENV['APP_BUNDLE_PATH'] = File.join Dir.pwd, Projectfile.frankified_app
|
31
|
+
ENV['USE_SIM_LAUNCHER_SERVER'] = nil || args[:sim_launcher]
|
32
|
+
tasklib.cucumber_opts = "#{Projectfile.frank_root}/Features --tags=\"#{args[:tags]}\" #{args[:cucumber_options]}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace :test do
|
37
|
+
|
38
|
+
desc 'Build the frankified App'
|
39
|
+
task :build do
|
40
|
+
Projectfile.load! projectfile_path
|
41
|
+
`frank build --workspace #{Projectfile.xcode_workspace} --scheme #{Projectfile.xcode_scheme}`
|
42
|
+
end
|
43
|
+
|
44
|
+
namespace :ci do
|
45
|
+
desc 'Run Frank acceptance tests with CI options'
|
46
|
+
task :frank, :tags do |t, args|
|
47
|
+
Projectfile.load! projectfile_path
|
48
|
+
|
49
|
+
artifacts_dir = ENV['CC_BUILD_ARTIFACTS'] || '/tmp'
|
50
|
+
cucumber_options = "--format pretty --format html --out '#{artifacts_dir}/frank_results.html' --format rerun --out '#{artifacts_dir}/frank_rerun.txt'"
|
51
|
+
::Rake::Task['test:frank'].invoke args[:tags], cucumber_options, 'yes'
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'xcodebuild'
|
3
|
+
require 'fwtoolkit/rake/tasks/config'
|
4
|
+
require 'fwtoolkit/projectfile'
|
5
|
+
|
6
|
+
module FWToolkit
|
7
|
+
module Rake
|
8
|
+
class XcodeTask < ::Rake::Task
|
9
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
10
|
+
include Config
|
11
|
+
def initialize(&block)
|
12
|
+
yield self if block_given?
|
13
|
+
define_task
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def define_task
|
20
|
+
namespace :xcode do
|
21
|
+
Projectfile.load! projectfile_path
|
22
|
+
Config.load!
|
23
|
+
|
24
|
+
XcodeBuild::Tasks::BuildTask.new :debug do |t|
|
25
|
+
t.invoke_from_within = '.'
|
26
|
+
t.configuration = "Debug"
|
27
|
+
t.sdk = "iphonesimulator"
|
28
|
+
t.workspace = Projectfile.xcode_workspace
|
29
|
+
t.scheme = Projectfile.xcode_scheme
|
30
|
+
t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
|
31
|
+
t.add_build_setting 'CONFIGURATION_BUILD_DIR', Config.artifacts_tmp_dir
|
32
|
+
end
|
33
|
+
|
34
|
+
XcodeBuild::Tasks::BuildTask.new :testing do |t|
|
35
|
+
t.invoke_from_within = '.'
|
36
|
+
t.configuration = "Debug"
|
37
|
+
t.sdk = "iphoneos"
|
38
|
+
t.workspace = Projectfile.xcode_workspace
|
39
|
+
t.scheme = Projectfile.xcode_scheme
|
40
|
+
t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
|
41
|
+
t.add_build_setting 'CONFIGURATION_BUILD_DIR', Config.artifacts_tmp_dir
|
42
|
+
end
|
43
|
+
|
44
|
+
XcodeBuild::Tasks::BuildTask.new :release do |t|
|
45
|
+
t.invoke_from_within = '.'
|
46
|
+
t.configuration = "Release"
|
47
|
+
t.sdk = "iphoneos"
|
48
|
+
t.workspace = Projectfile.xcode_workspace
|
49
|
+
t.scheme = Projectfile.xcode_scheme
|
50
|
+
t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
|
51
|
+
t.add_build_setting 'CONFIGURATION_BUILD_DIR', Config.artifacts_tmp_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
namespace :ci do
|
55
|
+
XcodeBuild::Tasks::BuildTask.new :testing do |t|
|
56
|
+
t.invoke_from_within = '.'
|
57
|
+
t.configuration = "Debug"
|
58
|
+
t.sdk = "iphonesimulator"
|
59
|
+
t.workspace = Projectfile.xcode_workspace
|
60
|
+
t.scheme = Projectfile.xcode_scheme
|
61
|
+
t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
|
62
|
+
t.add_build_setting 'CONFIGURATION_BUILD_DIR', Config.artifacts_tmp_dir
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fwtoolkit/rake/tasks/ci'
|
2
|
+
require 'fwtoolkit/rake/tasks/ota'
|
3
|
+
require 'fwtoolkit/rake/tasks/project'
|
4
|
+
require 'fwtoolkit/rake/tasks/test'
|
5
|
+
require 'fwtoolkit/rake/tasks/xcode'
|
6
|
+
|
7
|
+
module FWToolkit
|
8
|
+
module Rake
|
9
|
+
def self.new_all(&block)
|
10
|
+
# Create a new rake task for each of the included/defined class that have 'Task' in their name and
|
11
|
+
# belongs to FWToolkit::Rake module
|
12
|
+
task_classes = self.constants.select do |c|
|
13
|
+
constant = self.const_get(c)
|
14
|
+
(Class === constant) && constant.name.include?('Task')
|
15
|
+
end
|
16
|
+
task_classes.each { |k| self.const_get(k).new(&block) }
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/fwtoolkit/version.rb
CHANGED
data/lib/fwtoolkit.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'core_data'
|
1
|
+
require 'fwtoolkit/ext/gem'
|
2
|
+
require 'fwtoolkit/cli'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Dir["tasks/**/*.rake"].each { |ext| load ext } if defined?(Rake)
|
4
|
+
module FWToolkit
|
5
|
+
end
|
@@ -0,0 +1,316 @@
|
|
1
|
+
require 'fwtoolkit/git_client'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
describe GitClient do
|
5
|
+
before do
|
6
|
+
@project_folder = Dir.mktmpdir
|
7
|
+
@repo = GitClient::Repository.new @project_folder
|
8
|
+
raise "Can't create temp folder" unless @project_folder
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
FileUtils.rm_rf(@project_folder)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "initialize and empty repository on an new folder" do
|
16
|
+
@repo.init
|
17
|
+
File.exists?(File.join(@project_folder, '.git')).should be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "fails to initialise a repository on a folder containing a git repo" do
|
21
|
+
Dir.mkdir File.join(@project_folder, '.git')
|
22
|
+
expect { @repo.init }.to raise_error(GitClient::GitError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "correctly identify if a folder contains a git repository" do
|
26
|
+
@repo.initialized?.should be_false
|
27
|
+
Dir.mkdir File.join(@project_folder, '.git')
|
28
|
+
@repo.initialized?.should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "identifies the current branch" do
|
32
|
+
create_sample_repo
|
33
|
+
@repo.current_branch.should == 'master'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "identifies existing and non existing branches" do
|
37
|
+
create_sample_repo
|
38
|
+
@repo.branch_exist?('master').should be_true
|
39
|
+
@repo.branch_exist?('deleted-branch').should be_false
|
40
|
+
end
|
41
|
+
|
42
|
+
it "switches to an existing different branch" do
|
43
|
+
create_sample_repo
|
44
|
+
@repo.switch_branch 'test1'
|
45
|
+
@repo.current_branch.should == 'test1'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "switches to a new branch creating it" do
|
49
|
+
create_sample_repo
|
50
|
+
@repo.switch_branch 'test-new'
|
51
|
+
@repo.current_branch.should == 'test-new'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "complains when switching to a non existent branch" do
|
55
|
+
create_empty_repo
|
56
|
+
expect { @repo.switch_branch 'fake_branch', false }.to raise_error GitClient::GitError
|
57
|
+
end
|
58
|
+
|
59
|
+
it "identifies a clean working directory" do
|
60
|
+
create_empty_repo
|
61
|
+
@repo.workdir_clean?.should == true
|
62
|
+
FileUtils.cd(@project_folder) { FileUtils.touch 'new_file.c' }
|
63
|
+
@repo.workdir_clean?.should == false
|
64
|
+
end
|
65
|
+
|
66
|
+
it "identifies untracked files" do
|
67
|
+
create_sample_repo
|
68
|
+
@repo.status[:untracked].include?('untracked.c').should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "identifies not up to date files on the index" do
|
72
|
+
create_sample_repo
|
73
|
+
change_the_file 'added.c'
|
74
|
+
@repo.status[:idx_not_up_to_date].include?('added.c').should be_true
|
75
|
+
end
|
76
|
+
|
77
|
+
it "identifies files added to the index" do
|
78
|
+
create_sample_repo
|
79
|
+
@repo.status[:idx_added].include?('added.c').should be_true
|
80
|
+
end
|
81
|
+
|
82
|
+
it "identifies files modified on the index" do
|
83
|
+
create_sample_repo
|
84
|
+
change_the_file 'added_and_committed.c'
|
85
|
+
add_the_file 'added_and_committed.c'
|
86
|
+
@repo.status[:idx_modified].include?('added_and_committed.c').should be_true
|
87
|
+
end
|
88
|
+
|
89
|
+
it "identifies files deleted on the index" do
|
90
|
+
create_sample_repo
|
91
|
+
remove_committed_file_from_git
|
92
|
+
@repo.status[:idx_deleted].include?('added_and_committed.c').should be_true
|
93
|
+
end
|
94
|
+
|
95
|
+
it "identifies files renamed on the index" do
|
96
|
+
create_sample_repo
|
97
|
+
move_committed_file
|
98
|
+
@repo.status[:idx_renamed].include?('added_and_committed.c').should be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "adds files to the index" do
|
102
|
+
create_sample_repo
|
103
|
+
FileUtils.cd(@project_folder) { FileUtils.touch 'new_file.c' }
|
104
|
+
@repo.add_files_to_index 'new_file.c'
|
105
|
+
tracked_file = false
|
106
|
+
FileUtils.cd(@project_folder) { `git ls-files new_file.c --error-unmatch`; tracked_file = $?.success? }
|
107
|
+
tracked_file.should be_true
|
108
|
+
end
|
109
|
+
|
110
|
+
it "list all remotes when they exist" do
|
111
|
+
create_sample_repo
|
112
|
+
remotes = @repo.remotes
|
113
|
+
remotes[:origin].should eq 'git@github.com:/Company/repo.git'
|
114
|
+
remotes[:upstream].should eq 'git@github.com:/Company/cool-repo.git'
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns an empty remote list when none exists" do
|
118
|
+
create_empty_repo
|
119
|
+
@repo.remotes.should be_empty
|
120
|
+
end
|
121
|
+
|
122
|
+
it "list all submodules when they exists" do
|
123
|
+
create_repo_with_submodules
|
124
|
+
submodules = @repo.submodules
|
125
|
+
submodules['my_module'].should eq 'git://github.com/dummy_user/my_module.git'
|
126
|
+
submodules['sub/my_module2'].should eq 'git://github.com/dummy_user/my_module2.git'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "returns an empty submodules list when none exists" do
|
130
|
+
create_empty_repo
|
131
|
+
@repo.submodules.should be_empty
|
132
|
+
end
|
133
|
+
|
134
|
+
it "commits to the repository" do
|
135
|
+
create_sample_repo
|
136
|
+
commit_hash = @repo.commit "My commit message"
|
137
|
+
valid_commit?(commit_hash).should be_true
|
138
|
+
end
|
139
|
+
|
140
|
+
it "merges into the current branch" do
|
141
|
+
create_mergable_repo
|
142
|
+
file_exists_in_repo?('test1_file.c').should be_false
|
143
|
+
@repo.merge('test1')
|
144
|
+
file_exists_in_repo?('test1_file.c').should be_true
|
145
|
+
last_commit_merge?.should be_true
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
it "merges into a specific branch" do
|
150
|
+
create_mergable_repo
|
151
|
+
file_exists_in_repo?('test1_file.c').should be_false
|
152
|
+
@repo.merge('test1', 'test2')
|
153
|
+
last_commit_merge?.should be_true
|
154
|
+
|
155
|
+
@repo.current_branch.should eq "test2"
|
156
|
+
file_exists_in_repo?('test1_file.c').should be_true
|
157
|
+
end
|
158
|
+
|
159
|
+
it "complains when trying to merge from a non existing branch" do
|
160
|
+
create_mergable_repo
|
161
|
+
expect { @repo.merge 'fake_branch' }.to raise_error GitClient::GitError
|
162
|
+
end
|
163
|
+
|
164
|
+
it "complains when trying to merge into a non existing branch" do
|
165
|
+
create_mergable_repo
|
166
|
+
expect { @repo.merge 'test1', 'fake_branch' }.to raise_error GitClient::GitError
|
167
|
+
end
|
168
|
+
|
169
|
+
it "rebases into the current branch" do
|
170
|
+
create_mergable_repo
|
171
|
+
file_exists_in_repo?('test1_file.c').should be_false
|
172
|
+
@repo.rebase('test1')
|
173
|
+
file_exists_in_repo?('test1_file.c').should be_true
|
174
|
+
end
|
175
|
+
|
176
|
+
it "rebases into a specific branch" do
|
177
|
+
create_mergable_repo
|
178
|
+
file_exists_in_repo?('test1_file.c').should be_false
|
179
|
+
@repo.rebase('test1', 'test2')
|
180
|
+
@repo.current_branch.should eq "test2"
|
181
|
+
|
182
|
+
file_exists_in_repo?('test1_file.c').should be_true
|
183
|
+
end
|
184
|
+
|
185
|
+
it "complains when trying to rebase from a non existing branch" do
|
186
|
+
create_mergable_repo
|
187
|
+
expect { @repo.rebase 'fake_branch' }.to raise_error GitClient::GitError
|
188
|
+
end
|
189
|
+
|
190
|
+
it "complains when trying to rebase into a non existing branch" do
|
191
|
+
create_mergable_repo
|
192
|
+
expect { @repo.rebase 'test1', 'fake_branch' }.to raise_error GitClient::GitError
|
193
|
+
end
|
194
|
+
|
195
|
+
it "saves the stash" do
|
196
|
+
create_sample_repo
|
197
|
+
add_the_file 'untracked.c'
|
198
|
+
@repo.save_stash
|
199
|
+
@repo.status.should be_empty
|
200
|
+
end
|
201
|
+
|
202
|
+
it "pops a stash" do
|
203
|
+
create_repo_with_stashed_data
|
204
|
+
@repo.workdir_clean?.should be_true
|
205
|
+
@repo.pop_stash
|
206
|
+
@repo.workdir_clean?.should be_false
|
207
|
+
end
|
208
|
+
|
209
|
+
private
|
210
|
+
|
211
|
+
def create_empty_repo
|
212
|
+
FileUtils.cd(@project_folder) do
|
213
|
+
`git init`
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def create_sample_repo
|
218
|
+
create_empty_repo
|
219
|
+
FileUtils.cd(@project_folder) do
|
220
|
+
write_content_to_file 'added_and_committed.c', '//my c line'
|
221
|
+
write_content_to_file 'added.c', '//my c line new'
|
222
|
+
write_content_to_file 'untracked.c', '//my c line untracked'
|
223
|
+
`git add added_and_committed.c`
|
224
|
+
`git commit -m"My first commit"`
|
225
|
+
`git add added.c`
|
226
|
+
`git branch test1`
|
227
|
+
`git branch test2`
|
228
|
+
`git remote add origin git@github.com:/Company/repo.git`
|
229
|
+
`git remote add upstream git@github.com:/Company/cool-repo.git`
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def create_repo_with_submodules
|
234
|
+
create_sample_repo
|
235
|
+
write_content_to_file '.gitmodules', <<-GITMODULES
|
236
|
+
[submodule "my_module"]
|
237
|
+
path = my_module
|
238
|
+
url = "git://github.com/dummy_user/my_module.git"
|
239
|
+
[submodule "my_module2"]
|
240
|
+
path = sub/my_module2
|
241
|
+
url = "git://github.com/dummy_user/my_module2.git"
|
242
|
+
GITMODULES
|
243
|
+
end
|
244
|
+
|
245
|
+
def create_mergable_repo
|
246
|
+
create_empty_repo
|
247
|
+
FileUtils.cd(@project_folder) do
|
248
|
+
FileUtils.touch('master_file.c')
|
249
|
+
`git add .`
|
250
|
+
`git commit -m"First Commit"`
|
251
|
+
`git checkout -b test1 2>&1`
|
252
|
+
`git branch test2`
|
253
|
+
write_content_to_file 'test1_file.c', '//my c line on test1'
|
254
|
+
`git add test1_file.c`
|
255
|
+
`git commit -m "Test1 branchs commit"`
|
256
|
+
`git checkout master 2>&1`
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def create_repo_with_stashed_data
|
261
|
+
create_sample_repo
|
262
|
+
add_the_file 'untracked.c'
|
263
|
+
FileUtils.cd(@project_folder) do
|
264
|
+
`git stash save`
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def write_content_to_file(filename, content)
|
269
|
+
FileUtils.cd(@project_folder) do
|
270
|
+
File.open(filename, 'w') {|f| f.write(content) }
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def change_the_file(filename)
|
275
|
+
write_content_to_file(filename,'//another c line')
|
276
|
+
end
|
277
|
+
|
278
|
+
def add_the_file(filename)
|
279
|
+
FileUtils.cd(@project_folder) do
|
280
|
+
`git add #{filename}`
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def remove_committed_file_from_git
|
285
|
+
FileUtils.cd(@project_folder) do
|
286
|
+
`git rm added_and_committed.c`
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def move_committed_file
|
291
|
+
FileUtils.cd(@project_folder) do
|
292
|
+
FileUtils.mv('added_and_committed.c', 'moved.c')
|
293
|
+
`git rm added_and_committed.c`
|
294
|
+
`git add moved.c`
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def valid_commit?(sha1)
|
299
|
+
FileUtils.cd(@project_folder) do
|
300
|
+
`git merge-base #{sha1} master`
|
301
|
+
end
|
302
|
+
$?.success?
|
303
|
+
end
|
304
|
+
|
305
|
+
def last_commit_merge?
|
306
|
+
last_commit_sha = nil
|
307
|
+
FileUtils.cd(@project_folder) do
|
308
|
+
last_commit_sha = `git rev-list --merges HEAD~1..HEAD`
|
309
|
+
end
|
310
|
+
$?.success? && last_commit_sha && last_commit_sha.length > 0
|
311
|
+
end
|
312
|
+
|
313
|
+
def file_exists_in_repo?(filename)
|
314
|
+
File.exists? File.join(@project_folder, filename)
|
315
|
+
end
|
316
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'fwtoolkit/projectfile'
|
2
|
+
require 'support/project_generator'
|
3
|
+
|
4
|
+
describe "FWToolkit::Project" do
|
5
|
+
|
6
|
+
class DummyClass
|
7
|
+
end
|
8
|
+
|
9
|
+
let!(:project) { ProjectGenerator.new }
|
10
|
+
let(:project_folder) { project.project_folder }
|
11
|
+
let(:project_class) { DummyClass.new }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@project_class.extend FWToolkit::Projectfile
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:each) do
|
18
|
+
FileUtils.rm_rf(project_folder)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "correctly parses a full projectfile" do
|
22
|
+
project.create_test_project ProjectGenerator::PRJFILE_COMPLETE_CONFIG
|
23
|
+
FWToolkit::Projectfile.load! project_folder
|
24
|
+
FWToolkit::Projectfile.config.should == ProjectGenerator::PRJFILE_COMPLETE_CONFIG
|
25
|
+
end
|
26
|
+
|
27
|
+
it "correctly adds defaults to an incomplete projectfile" do
|
28
|
+
project.create_test_project ProjectGenerator::PRJFILE_STANDARD_CONFIG
|
29
|
+
FWToolkit::Projectfile.load! project_folder
|
30
|
+
FWToolkit::Projectfile.config.should == ProjectGenerator::PRJFILE_COMPLETE_CONFIG
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises an exception if the minimal config is not specified" do
|
34
|
+
invalid_config = ProjectGenerator::PRJFILE_COMPLETE_CONFIG.clone
|
35
|
+
invalid_config.delete(:project_name)
|
36
|
+
|
37
|
+
project.create_test_project invalid_config
|
38
|
+
expect { FWToolkit::Projectfile.load! project_folder }.to raise_error(NameError)
|
39
|
+
end
|
40
|
+
end
|