Permalink
Browse files

updated/fixed some tests. All tests now upgraded to the new testing f…

…ramework.

Removed old test framework.
  • Loading branch information...
azimux committed Oct 5, 2011
1 parent 7d32bb3 commit 5d807ccee4de9d6edb04209764ba1c8b79da10fc
View
@@ -1,12 +1,7 @@
.svn
-test/workdir
-test/applications/rails_app
nbproject/
*~
tmp/*
pkg/
-test/repositories/
-test/cleanreps/
-test/test_svn_global_opts/
test/tmp
-doc/*
+doc/*
View
@@ -10,79 +10,6 @@ $LOAD_PATH << File.join(root_dir, 'lib')
require File.join(root_dir, 'lib', 'externals', 'ext')
-desc "Creates the starting repositories needed to run the tests.
-If you plan on running the tests, you only need
- to run this once."
-task :prep_test do
- Dir.chdir File.join(root_dir, 'test') do
-
- puts `rm -rf cleanreps`
- Dir.mkdir('cleanreps')
- Dir.chdir('cleanreps') do
- %w(redhillonrails_core foreign_key_migrations empty_plugin).each do |p|
- puts `cp ../setup/#{p}.svn.gz .`
- puts `gzip -d #{p}.svn.gz`
- puts `svnadmin create #{p}`
- puts `svnadmin load #{p} < #{p}.svn`
- end
-
- puts `git clone --bare git://github.com/azimux/engines.git engines.git`
-
- %w(acts_as_list ssl_requirement).each do |p|
- puts `git clone --bare git://github.com/rails/#{p}.git #{p}.git`
- end
-
- if File.exists? 'C:\\tmp\\rails'
- puts `cp -a C:\\tmp\\rails full_rails`
- elsif File.exists? '/tmp/rails'
- puts `cp -a /tmp/rails full_rails`
- else
- puts `git clone git://github.com/rails/rails.git full_rails`
- end
- puts `cp -a full_rails fake_rails`
-
- #let's make the repo smaller by removing all but 1 file from each
- #directory to save time
- Dir.chdir 'fake_rails' do
- puts `rm -rf .git`
- raise "something wrong with rm" if File.exists? '.git'
- end
-
- dirs = []
- Find.find('fake_rails') do |f|
- dirs << f if File.directory?(f)
- end
-
- dirs.each do |dir|
- files = Dir.entries(dir)
-
- Dir.chdir(dir) do
- files = files.select {|e|e != ".gitignore" && File.file?(e)}.sort
- files.shift #let's keep the first file in the list.
- files.each do |file|
- File.delete(file)
- end
- end
- end
-
- raise "why is rails already here?" if File.exists? 'rails.git'
-
- Dir.mkdir('rails.git')
-
- Dir.chdir('rails.git') do
- puts `git init --bare`
- end
-
- Dir.chdir 'fake_rails' do
- puts `git init`
- puts `git add .`
- puts `git commit -m "rails with all but 1 file per directory deleted"`
- puts `git push ../rails.git master`
- end
- end
- end
-end
-
Rake::TestTask.new('test') do |task|
task.libs = [File.expand_path('lib'),File.expand_path('test')]
task.pattern = './test/test_*.rb'
View
@@ -81,6 +81,9 @@ module Externals
COMMANDS = FULL_COMMANDS + SHORT_COMMANDS + MAIN_COMMANDS
+ COULD_NOT_DETERMINE_SCM = 1
+ NO_EXTERNALS_FILE = 2
+
Dir.entries(File.join(File.dirname(__FILE__), '..', 'externals','scms')).each do |project|
require "externals/scms/#{project}" if project =~ /_project.rb$/
end
@@ -404,7 +407,10 @@ def freeze args, options
end
def install args, options
- init args, options unless File.exists? '.externals'
+ if !File.exists? '.externals'
+ STDERR.puts "This project does not appear to be managed by externals. Try 'ext init' first"
+ exit NO_EXTERNALS_FILE
+ end
repository = args[0]
path = args[1]
@@ -415,10 +421,11 @@ def install args, options
scm ||= infer_scm(repository)
unless scm
- raise "Unable to determine SCM from the repository name.
+ STDERR.puts "Unable to determine SCM from the repository name.
You need to either specify the scm used to manage the subproject
that you are installing. Use an option to specify it
(such as --git or --svn)"
+ exit COULD_NOT_DETERMINE_SCM
end
project = self.class.project_class(scm).new(:repository => repository,
@@ -10,4 +10,15 @@ def cp_a source, dest, options = {}
def rm_rf_ie file, options = {}
rm_rf file, options if File.exists? file
end
+
+ alias rm_rf_old rm_rf
+ #going to try to give a delay after calling rm if necessary...
+ def rm_rf *args
+ rm_rf_old *args
+ tries = 0
+ while File.exists?(args[0]) && tries < 10
+ sleep 1
+ tries += 1
+ end
+ end
end
@@ -6,7 +6,7 @@ module Externals
module Test
class FakeRailsRepository < Repository
def initialize
- super "rails.git", "fake"
+ super "rails.git", "fake3"
end
def build_here
@@ -16,7 +16,8 @@ def build_here
rm_rf "fake_rails"
`git clone #{repository.clean_dir} fake_rails`
-
+ raise unless $? == 0
+
#let's make the repo smaller by removing all but 1 file from each
#directory to save time
Dir.chdir 'fake_rails' do
@@ -46,13 +47,62 @@ def build_here
Dir.chdir('rails.git') do
puts `git init --bare`
+ raise unless $? == 0
end
Dir.chdir 'fake_rails' do
puts `git init`
+ raise unless $? == 0
puts `git add .`
+ raise unless $? == 0
puts `git commit -m "rails with all but 1 file per directory deleted"`
+ raise unless $? == 0
+ puts `git push ../rails.git master`
+ raise unless $? == 0
+
+ head1 = nil
+ head2 = nil
+ # let's make a couple commits...
+ open "heads", "a" do |file|
+ head1 = `git show HEAD`.match(/^\s*commit\s+([0-9a-f]{40})\s*$/)[1]
+ raise unless head1
+ file.puts head1
+ raise unless $? == 0
+ end
+ puts `git add .`
+ raise unless $? == 0
+ puts `git commit -m "dummy commit 1"`
+ raise unless $? == 0
+ puts `git push ../rails.git master`
+ raise unless $? == 0
+
+ open "heads", "a" do |file|
+ head2 = `git show HEAD`.match(/^\s*commit\s+([0-9a-f]{40})\s*$/)[1]
+ raise unless head2
+ raise unless head1 != head2
+ file.puts head2
+ raise unless $? == 0
+ end
+ puts `git add .`
+ raise unless $? == 0
+ puts `git commit -m "dummy commit 2"`
+ raise unless $? == 0
+ puts `git push ../rails.git master`
+ raise unless $? == 0
+
+ open "heads", "a" do |file|
+ head2 = `git show HEAD`.match(/^\s*commit\s+([0-9a-f]{40})\s*$/)[1]
+ raise unless head2
+ raise unless head1 != head2
+ file.puts head2
+ raise unless $? == 0
+ end
+ puts `git add .`
+ raise unless $? == 0
+ puts `git commit -m "dummy commit 3"`
+ raise unless $? == 0
puts `git push ../rails.git master`
+ raise unless $? == 0
end
rm_rf "fake_rails"
end
@@ -13,7 +13,7 @@ class RailsAppSvnRepository < Repository
include SvnRepositoryHelper
def initialize
- super "rails_app", "svn"
+ super "rails_app", "svn2"
dependents.merge!(
:acts_as_list => GitRepositoryFromInternet.new("acts_as_list.git"),
:ssl_requirement => GitRepositoryFromInternet.new("ssl_requirement.git"),
@@ -68,9 +68,10 @@ def build_here
# raise unless $? == 0
#install some git subprojects
- [:rails, :acts_as_list].each do |proj|
- Ext.run "install", dependents[proj].clean_dir
- end
+ Ext.run "install", dependents[:acts_as_list].clean_dir
+ #we have to use file:// to test export, because without that
+ #git clone optimizes by copying and igores --depth
+ Ext.run "install", "file://#{dependents[:rails].clean_dir}"
#install a couple svn managed subprojects
[
@@ -79,6 +79,10 @@ def pristine_dir
# builds/copies the test repository if needed
def prepare
+ #let's mark ourselves as dirty if any of our dependents are dirty
+ if dependents.values.detect(&:'dirty?')
+ mark_dirty
+ end
dependents.values.each {|child| child.prepare}
if dirty?
Oops, something went wrong.

0 comments on commit 5d807cc

Please sign in to comment.