aboutsummaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorBranan Purvine-Riley <branan@puppetlabs.com>2012-05-25 12:07:36 -0700
committerBranan Purvine-Riley <branan@puppetlabs.com>2012-05-25 12:30:24 -0700
commit6bdc09719a58e83c9f4fd17832540807f446838a (patch)
tree68e416120b8632f0eb20c8564d6afd40a24f108a /Rakefile
parent25652f4645e09a89a3e5d749958f89d00050175d (diff)
downloadpuppet-tftp-6bdc09719a58e83c9f4fd17832540807f446838a.tar.gz
puppet-tftp-6bdc09719a58e83c9f4fd17832540807f446838a.tar.bz2
Update for the new module template
* Add `rake spec_full` and friends * Remove recursive symlink * Prepend fixtures modulepath instead of overriding * Update travis config to use spec_full
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile72
1 files changed, 64 insertions, 8 deletions
diff --git a/Rakefile b/Rakefile
index 6f28836..ab25667 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,20 +1,71 @@
-require 'rubygems'
require 'rake'
require 'rspec/core/rake_task'
+require 'yaml'
-task :default do
- system("rake -T")
-end
-
-task :specs => [:spec]
+task :default => [:spec]
-desc "Run all rspec-puppet tests"
+desc "Run all module spec tests (Requires rspec-puppet gem)"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ['--color']
- # ignores fixtures directory.
t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
end
+# This is a helper for the self-symlink entry of fixtures.yml
+def source_dir
+ File.dirname(__FILE__)
+end
+
+def fixtures(category)
+ begin
+ fixtures = YAML.load_file(".fixtures.yml")["fixtures"]
+ rescue Errno::ENOENT
+ return {}
+ end
+
+ if not fixtures
+ abort("malformed fixtures.yml")
+ end
+
+ result = {}
+ if fixtures.include? category
+ fixtures[category].each do |fixture, source|
+ target = "spec/fixtures/modules/#{fixture}"
+ real_source = eval('"'+source+'"')
+ result[real_source] = target
+ end
+ end
+ return result
+end
+
+desc "Create the fixtures directory"
+task :spec_prep do
+ fixtures("repositories").each do |repo, target|
+ File::exists?(target) || system("git clone #{repo} #{target}")
+ end
+
+ FileUtils::mkdir_p("spec/fixtures/modules")
+ fixtures("symlinks").each do |source, target|
+ File::exists?(target) || FileUtils::ln_s(source, target)
+ end
+end
+
+desc "Clean up the fixtures directory"
+task :spec_clean do
+ fixtures("repositories").each do |repo, target|
+ FileUtils::rm_rf(target)
+ end
+
+ fixtures("symlinks").each do |source, target|
+ FileUtils::rm(target)
+ end
+end
+
+task :spec_full do
+ Rake::Task[:spec_prep].invoke
+ Rake::Task[:spec].invoke
+ Rake::Task[:spec_clean].invoke
+end
+
desc "Build puppet module package"
task :build do
# This will be deprecated once puppet-module is a face.
@@ -27,6 +78,11 @@ task :build do
end
end
+desc "Clean a built module package"
+task :clean do
+ FileUtils.rm_rf("pkg/")
+end
+
desc "Check puppet manifests with puppet-lint"
task :lint do
# This requires pull request: https://github.com/rodjek/puppet-lint/pull/81