Permalink
Browse files

Merge remote-tracking branch 'local-staging/master'

Conflicts:
	lib/cli/commands/apps.rb
	lib/cli/commands/misc.rb
	lib/cli/commands/user.rb
	lib/cli/frameworks.rb
	lib/cli/version.rb
  • Loading branch information...
2 parents 0f8a26c + 1c12284 commit 8fa445623c62e9ee3ce283e0ede3f03df8c3aa6e Patrick Bozeman committed Oct 19, 2011
View
@@ -1,3 +1,4 @@
Gemfile.lock
+.build
*.gem
.DS_Store
View
@@ -0,0 +1,3 @@
+[submodule "spec/assets/tests"]
+ path = spec/assets/tests
+ url = https://github.com/cloudfoundry/vcap-test-assets.git
View
@@ -2,8 +2,7 @@ require 'rake'
require 'spec/rake/spectask'
desc "Run specs"
-task :spec do
- sh('bundle install')
+task :spec => :build do
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_opts = %w(-fs -c)
t.spec_files = FileList['spec/**/*_spec.rb']
@@ -15,3 +14,86 @@ task :test => :spec
desc "Synonym for spec"
task :tests => :spec
task :default => :spec
+
+def tests_path
+ if @tests_path == nil
+ @tests_path = File.join(Dir.pwd, "spec/assets/tests")
+ end
+ @tests_path
+end
+TESTS_PATH = tests_path
+
+BUILD_ARTIFACT = File.join(Dir.pwd, "spec/assets/.build")
+
+TESTS_TO_BUILD = ["#{TESTS_PATH}/java_web/java_tiny_app",
+# "#{TESTS_PATH}/grails/guestbook",
+ "#{TESTS_PATH}/lift/hello_lift",
+ "#{TESTS_PATH}/spring/roo-guestbook",
+ "#{TESTS_PATH}/spring/spring-osgi-hello",
+ ]
+
+desc "Build the tests. If the git hash associated with the test assets has not changed, nothing is built. To force a build, invoke 'rake build[--force]'"
+task :build, [:force] do |t, args|
+ sh('bundle install')
+ sh('git submodule update --init')
+ puts "\nBuilding tests"
+ if build_required? args.force
+ ENV['MAVEN_OPTS']="-XX:MaxPermSize=256M"
+ TESTS_TO_BUILD.each do |test|
+ puts "\tBuilding '#{test}'"
+ Dir.chdir test do
+ sh('mvn package -DskipTests') do |success, exit_code|
+ unless success
+ clear_build_artifact
+ do_mvn_clean('-q')
+ fail "\tFailed to build #{test} - aborting build"
+ end
+ end
+ end
+ puts "\tCompleted building '#{test}'"
+ end
+ save_git_hash
+ else
+ puts "Built artifacts in sync with test assets - no build required"
+ end
+end
+
+desc "Clean the build artifacts"
+task :clean do
+ puts "\nCleaning tests"
+ clear_build_artifact
+ TESTS_TO_BUILD.each do |test|
+ puts "\tCleaning '#{test}'"
+ Dir.chdir test do
+ do_mvn_clean
+ end
+ puts "\tCompleted cleaning '#{test}'"
+ end
+end
+
+def build_required? (force_build=nil)
+ if File.exists?(BUILD_ARTIFACT) == false or (force_build and force_build == "--force")
+ return true
+ end
+ Dir.chdir(tests_path) do
+ saved_git_hash = IO.readlines(BUILD_ARTIFACT)[0].split[0]
+ git_hash = `git rev-parse --short=8 --verify HEAD`
+ saved_git_hash.to_s.strip != git_hash.to_s.strip
+ end
+end
+
+def save_git_hash
+ Dir.chdir(tests_path) do
+ git_hash = `git rev-parse --short=8 --verify HEAD`
+ File.open(BUILD_ARTIFACT, 'w') {|f| f.puts("#{git_hash}")}
+ end
+end
+
+def clear_build_artifact
+ puts "\tClearing build artifact #{BUILD_ARTIFACT}"
+ File.unlink BUILD_ARTIFACT if File.exists? BUILD_ARTIFACT
+end
+
+def do_mvn_clean options=nil
+ sh("mvn clean #{options}")
+end
View
@@ -1,12 +1,11 @@
-
ROOT = File.expand_path(File.dirname(__FILE__))
+WINDOWS = !!(RUBY_PLATFORM =~ /mingw|mswin32|cygwin/)
-module VMC
+module VMC
autoload :Client, "#{ROOT}/vmc/client"
module Cli
-
autoload :Config, "#{ROOT}/cli/config"
autoload :Framework, "#{ROOT}/cli/frameworks"
autoload :Runner, "#{ROOT}/cli/runner"
View
@@ -22,12 +22,12 @@ def list_users
alias :users :list_users
def add_user(email=nil)
- email = @options[:email] unless email
+ email ||= @options[:email]
+ email ||= ask("Email") unless no_prompt
password = @options[:password]
- email = ask("Email: ") unless no_prompt || email
unless no_prompt || password
- password = ask("Password: ") {|q| q.echo = '*'}
- password2 = ask("Verify Password: ") {|q| q.echo = '*'}
+ password = ask("Password", :echo => "*")
+ password2 = ask("Verify Password", :echo => "*")
err "Passwords did not match, try again" if password != password2
end
err "Need a valid email" unless email
@@ -53,8 +53,11 @@ def delete_user(user_email)
if (apps && !apps.empty?)
unless no_prompt
- proceed = ask("\nDeployed applications and associated services will be DELETED, continue? [yN]: ")
- err "Aborted" if proceed.upcase != 'Y'
+ proceed = ask(
+ "\nDeployed applications and associated services will be DELETED, continue?",
+ :default => false
+ )
+ err "Aborted" unless proceed
end
cmd = Apps.new(@options)
apps.each { |app| cmd.delete_app(app[:name], true) }
Oops, something went wrong.

0 comments on commit 8fa4456

Please sign in to comment.