Merge pull request #60 from branan/ppa_filename
authorJames Turnbull <james@lovedthanlost.net>
Wed, 23 May 2012 17:16:49 +0000 (10:16 -0700)
committerJames Turnbull <james@lovedthanlost.net>
Wed, 23 May 2012 17:16:49 +0000 (10:16 -0700)
(#14657) Fix filename when there is a period in the PPA

.fixtures.yml [new file with mode: 0644]
.gemfile [moved from Gemfile with 100% similarity]
.travis.yml
Rakefile
spec/fixtures/modules/apt [deleted symlink]
spec/spec_helper.rb

diff --git a/.fixtures.yml b/.fixtures.yml
new file mode 100644 (file)
index 0000000..dbd5621
--- /dev/null
@@ -0,0 +1,5 @@
+fixtures:
+  repositories:
+    "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
+  symlinks:
+    "apt": "#{source_dir}"
similarity index 100%
rename from Gemfile
rename to .gemfile
index a4ec2c12e1d51056c718500a1ec80ff629d45f67..0ec5a08732b5d5d469c0dcd0d194344513f32f81 100644 (file)
@@ -2,9 +2,8 @@ language: ruby
 rvm:
   - 1.8.7
 before_script:
-  - "git clone git://github.com/puppetlabs/puppetlabs-stdlib.git spec/fixtures/modules/stdlib"
 after_script:
-script: "rake spec"
+script: "rake spec_full"
 branches:
   only:
     - master
@@ -14,3 +13,4 @@ env:
   - PUPPET_VERSION=2.6.9
 notifications:
   email: false
+gemfile: .gemfile
index 5cbef6b45ce404644298cfb0b2b03c3388f5b73c..20fc384a20af23090189d1f7ee8a2af3d6d6a4eb 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,6 @@
 require 'rake'
 require 'rspec/core/rake_task'
+require 'yaml'
 
 task :default => [:spec]
 
@@ -9,6 +10,61 @@ RSpec::Core::RakeTask.new(:spec) do |t|
   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
+
+  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.
diff --git a/spec/fixtures/modules/apt b/spec/fixtures/modules/apt
deleted file mode 120000 (symlink)
index 1b20c9f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../
\ No newline at end of file
index 46fe2371c96ac7301a50a8575c465fbdfab0ff88..660e21823c075e580de649459aba06d32cc0c998 100644 (file)
@@ -6,9 +6,13 @@ def param_value(subject, type, title, param)
   subject.resource(type, title).send(:parameters)[param.to_sym]
 end
 
+Puppet.parse_config
+puppet_module_path = Puppet[:modulepath]
+
 fixture_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
 
 RSpec.configure do |c|
-  c.module_path = File.join(fixture_path, 'modules')
+  fixture_module_path = File.join(fixture_path, 'modules')
+  c.module_path = [fixture_module_path, puppet_module_path].join(":")
   c.manifest_dir = File.join(fixture_path, 'manifests')
 end