From: <jh...@us...> - 2010-11-25 00:07:50
|
Revision: 225 http://etch.svn.sourceforge.net/etch/?rev=225&view=rev Author: jheiss Date: 2010-11-25 00:07:42 +0000 (Thu, 25 Nov 2010) Log Message: ----------- https://sourceforge.net/apps/trac/etch/ticket/8 Add support for an /etc/etch.conf config file to the client. This allows users to set the etch server, the directory to use for local configuration (if desired instead of using a server), and the SSH key permanently. These were previously only configurable on the command line. The config file also allows the user to set a PATH that will be in force for any commands etch runs. The PATH was previously hard-coded in the client. In Etch::Client.initialize replace the :varbase option with :file_system_root. The :varbase option allowed the test suite to specify an alternative to /var/etch for the client so that the test suite doesn't have to run as root and doesn't interfere with actual etch client usage on the system where the test suite is run. The replacement :file_system_root option allows the test suite to define a base directory under which the client will look for both /var/etch and /etc/etch.conf. This allows the test suite to test various config file settings, again without interfering with actual etch client usage on the development system. Change --test-base to --test-root in the etch executable to reflect the Etch::Client option change. In the start_server method in the test suite implement a check that the server has started up before returning, rather than sleeping for 5 seconds and hoping that is enough time. Under heavy load it sometimes isn't enough time, causing the test suite to fail unnecessarily. And under light load the server starts up much quicker than 5 seconds, so it is nice to not have to wait around unnecessarily. Update the run_etch method in the test suite to take optional arguments in an options hash, rather than as individual arguments. This cleans up the method signature and makes the code that calls run_etch more self-documenting. Added options to allow callers to override the --server and --key options passed to etch, and an option for specifying the testname so that we can pass that to assert. Modified Paths: -------------- trunk/client/Rakefile trunk/client/etch trunk/client/etchclient.rb trunk/test/etchtest.rb trunk/test/test_actions.rb trunk/test/test_attributes.rb trunk/test/test_auth.rb trunk/test/test_commands.rb trunk/test/test_delete.rb trunk/test/test_depend.rb trunk/test/test_file.rb trunk/test/test_history.rb trunk/test/test_link.rb trunk/test/test_local_requests.rb trunk/test/test_nodegroups.rb trunk/test/test_options.rb trunk/test/test_outputcapture.rb trunk/test/test_scripts.rb trunk/test/test_transitions.rb Added Paths: ----------- trunk/client/etch.conf trunk/test/test_conf.rb Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/client/Rakefile 2010-11-25 00:07:42 UTC (rev 225) @@ -81,10 +81,9 @@ if options[:etcdir] etcdir = File.join(destdir, options[:etcdir]) - # FIXME: Need to add support for etch.conf to the code - #mkdir_p(etcdir) - #cp('etch.conf', etcdir, :preserve => true) - #chmod(0644, File.join(etcdir, 'etch.conf')) + mkdir_p(etcdir) + cp('etch.conf', etcdir, :preserve => true) + chmod(0644, File.join(etcdir, 'etch.conf')) # All of the supporting config files go into a subdirectory etcetchdir = File.join(etcdir, 'etch') mkdir_p(etcetchdir) Modified: trunk/client/etch =================================================================== --- trunk/client/etch 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/client/etch 2010-11-25 00:07:42 UTC (rev 225) @@ -62,8 +62,8 @@ opts.on('--key PRIVATE_KEY', 'Use this private key for signing messages to server.') do |opt| options[:key] = opt end -opts.on('--test-base TESTDIR', 'Use an alternate local working directory.') do |opt| - options[:varbase] = opt +opts.on('--test-root TESTDIR', 'For use by the test suite only.') do |opt| + options[:file_system_root] = opt end opts.on('--debug', 'Print lots of messages about what etch is doing.') do |opt| options[:debug] = opt Added: trunk/client/etch.conf =================================================================== --- trunk/client/etch.conf (rev 0) +++ trunk/client/etch.conf 2010-11-25 00:07:42 UTC (rev 225) @@ -0,0 +1,18 @@ +# The default server url is https://etch +#server = https://etch + +# Etch is usually run from cron, and cron usually executes jobs with a very +# minimal PATH environment variable setting. You may want etch to have a more +# complete PATH setting so that pre and post commands are more readily found. +#path = /bin:/usr/bin:/sbin:/usr/sbin + +# Etch can read configuration from a local directory rather than from a +# server. If set this will override the server setting. +#local = /var/etch/configs + +# Etch will try to find an SSH host key and use it to sign all requests to the +# etch server. Several standard locations for SSH keys are searched by +# default, if your key is not in a standard location you can point etch to it. +# See https://sourceforge.net/apps/trac/etch/wiki/ClientAuthentication +#key = /etc/ssh/ssh_host_rsa_key + Modified: trunk/client/etchclient.rb =================================================================== --- trunk/client/etchclient.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/client/etchclient.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -41,7 +41,8 @@ CONFIRM_SKIP = 2 CONFIRM_QUIT = 3 PRIVATE_KEY_PATHS = ["/etc/ssh/ssh_host_rsa_key", "/etc/ssh_host_rsa_key"] - CONFIGDIR = '/etc' + DEFAULT_CONFIGDIR = '/etc' + DEFAULT_VARBASE = '/var/etch' # We need these in relation to the output capturing ORIG_STDOUT = STDOUT.dup @@ -52,7 +53,6 @@ def initialize(options) @server = options[:server] ? options[:server] : 'https://etch' @tag = options[:tag] - @varbase = options[:varbase] ? options[:varbase] : '/var/etch' @local = options[:local] ? File.expand_path(options[:local]) : nil @debug = options[:debug] @dryrun = options[:dryrun] @@ -63,11 +63,66 @@ @disableforce = options[:disableforce] @lockforce = options[:lockforce] - # Ensure we have a sane path, particularly since we are often run from - # cron. - # FIXME: Read from config file - ENV['PATH'] = '/bin:/usr/bin:/sbin:/usr/sbin:/opt/csw/bin:/opt/csw/sbin' + @configdir = DEFAULT_CONFIGDIR + @varbase = DEFAULT_VARBASE + @file_system_root = '/' # Not sure if this needs to be more portable + # This option is only intended for use by the test suite + if options[:file_system_root] + @file_system_root = options[:file_system_root] + @varbase = File.join(@file_system_root, @varbase) + @configdir = File.join(@file_system_root, @configdir) + end + + @configfile = File.join(@configdir, 'etch.conf') + + if File.exist?(@configfile) + IO.foreach(@configfile) do |line| + line.chomp! + next if (line =~ /^\s*$/); # Skip blank lines + next if (line =~ /^\s*#/); # Skip comments + line.strip! # Remove leading/trailing whitespace + key, value = line.split(/\s*=\s*/, 2) + if key == 'server' + # A setting for the server to use which comes from upstream + # (generally from a command line option) takes precedence + # over the config file + if !options[:server] + @server = value + # Warn the user, as this could potentially be confusing + # if they don't realize there's a config file lying + # around + warn "Using server #{@server} from #{@configfile}" if @debug + else + # "command line override" isn't necessarily accurate, we don't + # know why the caller passed us an option to override the config + # file, but most of the time it will be due to a command line + # option and I want the message to be easily understood by users. + # If someone can come up with some better wording without turning + # the message into something as long as this comment that would be + # welcome. + warn "Ignoring 'server' option in #{@configfile} due to command line override" if @debug + end + elsif key == 'local' + if !options[:local] && !options[:server] + @local = value + warn "Using local directory #{@local} from #{@configfile}" if @debug + else + warn "Ignoring 'local' option in #{@configfile} due to command line override" if @debug + end + elsif key == 'key' + if !options[:key] + @key = value + warn "Using key #{@key} from #{@configfile}" if @debug + else + warn "Ignoring 'key' option in #{@configfile} due to command line override" if @debug + end + elsif key == 'path' + ENV['PATH'] = value + end + end + end + @origbase = File.join(@varbase, 'orig') @historybase = File.join(@varbase, 'history') @lockbase = File.join(@varbase, 'locks') @@ -141,17 +196,17 @@ http = Net::HTTP.new(@filesuri.host, @filesuri.port) if @filesuri.scheme == "https" # Eliminate the OpenSSL "using default DH parameters" warning - if File.exist?(File.join(CONFIGDIR, 'etch', 'dhparams')) - dh = OpenSSL::PKey::DH.new(IO.read(File.join(CONFIGDIR, 'etch', 'dhparams'))) + if File.exist?(File.join(@configdir, 'etch', 'dhparams')) + dh = OpenSSL::PKey::DH.new(IO.read(File.join(@configdir, 'etch', 'dhparams'))) Net::HTTP.ssl_context_accessor(:tmp_dh_callback) http.tmp_dh_callback = proc { dh } end http.use_ssl = true - if File.exist?(File.join(CONFIGDIR, 'etch', 'ca.pem')) - http.ca_file = File.join(CONFIGDIR, 'etch', 'ca.pem') + if File.exist?(File.join(@configdir, 'etch', 'ca.pem')) + http.ca_file = File.join(@configdir, 'etch', 'ca.pem') http.verify_mode = OpenSSL::SSL::VERIFY_PEER - elsif File.directory?(File.join(CONFIGDIR, 'etch', 'ca')) - http.ca_path = File.join(CONFIGDIR, 'etch', 'ca') + elsif File.directory?(File.join(@configdir, 'etch', 'ca')) + http.ca_path = File.join(@configdir, 'etch', 'ca') http.verify_mode = OpenSSL::SSL::VERIFY_PEER end end Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/etchtest.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -5,6 +5,7 @@ require 'test/unit' require 'tempfile' require 'fileutils' +require 'net/http' module EtchTests # Roughly ../server and ../client @@ -104,9 +105,26 @@ # Pick a random port in the 3001-6000 range (range somewhat randomly chosen) port = 3001 + rand(3000) if pid = fork - # FIXME: replace this with a check that the server has started - puts "Giving the server some time to start up" - sleep(5) + # Give the server up to 30s to start, checking every second + serverstarted = false + catch :serverstarted do + 30.times do + begin + Net::HTTP.start('localhost', port) do |http| + response = http.head("/") + if response.kind_of?(Net::HTTPSuccess) + serverstarted = true + throw :serverstarted + end + end + rescue => e + end + sleep(1) + end + end + if !serverstarted + raise "Etch server failed to start" + end else if UNICORN exec("cd #{SERVERDIR} && unicorn_rails -p #{port}") @@ -122,12 +140,29 @@ Process.waitpid(server[:pid]) end - def run_etch(server, testbase, errors_expected=false, extra_args='', port=nil) - extra_args = extra_args + " --debug" - if !port - port = server[:port] + def run_etch(server, testroot, options={}) + extra_args = '' + if options[:extra_args] + extra_args += options[:extra_args] end - if errors_expected + extra_args += " --debug" + + port = server[:port] + if options[:port] + port = options[:port] + end + + server = "--server=http://localhost:#{port}" + if options[:server] + server = options[:server] + end + + key = "--key=#{File.dirname(__FILE__)}/keys/testkey" + if options[:key] + key = options[:key] + end + + if options[:errors_expected] # Warn the user that errors are expected. Otherwise it can be # disconcerting if you're watching the tests run and see errors. #sleep 3 @@ -136,11 +171,11 @@ puts "#" #sleep 3 end - result = system("ruby #{CLIENTDIR}/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} --key=#{File.dirname(__FILE__)}/keys/testkey #{extra_args}") - if errors_expected - assert(!result) + result = system("ruby #{CLIENTDIR}/etch --generate-all --test-root=#{testroot} #{server} #{key} #{extra_args}") + if options[:errors_expected] + assert(!result, options[:testname]) else - assert(result) + assert(result, options[:testname]) end end Modified: trunk/test/test_actions.rb =================================================================== --- trunk/test/test_actions.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_actions.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -19,8 +19,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" # Generate another file to use as our link target @destfile = released_tempfile @@ -76,7 +76,7 @@ # Run etch #puts "Running initial action test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the actions were executed # The setup actions will get run several times as we loop @@ -100,7 +100,7 @@ # Run etch again and make sure that the exec_once command wasn't run # again - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal("exec_once\n", get_file_contents("#{@repodir}/exec_once"), 'exec_once_2nd_check') end @@ -142,7 +142,7 @@ # Run etch #puts "Running initial action test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), 'failed setup') @@ -185,7 +185,7 @@ # Run etch #puts "Running failed pre test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), 'failed pre') @@ -234,7 +234,7 @@ # Run etch #puts "Running failed test test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the original was restored, and that post was run twice assert_equal(origcontents, get_file_contents(@targetfile), 'failed test target') @@ -270,7 +270,7 @@ # Run etch #puts "Running failed test_before_post test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that post was not run assert(!File.exist?("#{@repodir}/post"), 'failed test_before_post post') @@ -286,7 +286,7 @@ # Run etch #puts "Running failed test symlink test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the original symlink was restored assert_equal(@destfile, File.readlink(@targetfile), 'failed test symlink') @@ -303,7 +303,7 @@ # Run etch #puts "Running failed test directory test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the original directory was restored assert(File.directory?(@targetfile), 'failed test directory') @@ -325,7 +325,7 @@ # Run etch #puts "Running failed test no original file test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the lack of an original file was restored assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), 'failed test no original file') @@ -372,7 +372,7 @@ # Run etch #puts "Running nested target with test test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(nestedtargetfile), 'nested target with test') @@ -415,7 +415,7 @@ # Run etch #puts "Running XML escape test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the action was executed assert_equal("post\n", get_file_contents("#{@repodir}/post_with_escape"), 'post with escape') @@ -458,7 +458,7 @@ # Run etch #puts "Running environment variable test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the action was executed assert_equal("testvalue\n", get_file_contents("#{@repodir}/post_with_env_output"), 'post with environment variable') @@ -466,7 +466,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) FileUtils.rm_f(@destfile) end Modified: trunk/test/test_attributes.rb =================================================================== --- trunk/test/test_attributes.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_attributes.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -21,8 +21,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_group_attributes @@ -58,9 +58,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -89,9 +87,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -134,9 +130,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -173,9 +167,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -204,9 +196,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -250,9 +240,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -289,9 +277,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -320,9 +306,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -359,9 +343,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -398,9 +380,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -429,9 +409,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -468,9 +446,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -509,9 +485,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -548,9 +522,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -584,9 +556,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -615,9 +585,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -626,7 +594,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_auth.rb =================================================================== --- trunk/test/test_auth.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_auth.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -32,8 +32,8 @@ @server = start_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" # Make sure the server will initially think this is a new client hostname = Facter['fqdn'].value @@ -91,7 +91,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -122,7 +122,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -161,7 +161,7 @@ # Run etch with the wrong key to force a bad signature #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true, "--key=#{File.join(File.dirname(__FILE__), 'keys', 'testkey2')}") + run_etch(@server, @testroot, :errors_expected => true, :key => "--key=#{File.join(File.dirname(__FILE__), 'keys', 'testkey2')}") # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -206,7 +206,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -219,7 +219,7 @@ sleep 3 repodir2 = initialize_repository server2 = start_server(repodir2) - run_etch(server2, @testbase) + run_etch(server2, @testroot) stop_server(server2) remove_repository(repodir2) @@ -249,7 +249,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -258,7 +258,7 @@ def teardown stop_server(@server) remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_commands.rb =================================================================== --- trunk/test/test_commands.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_commands.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -19,8 +19,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_commands_basic @@ -47,7 +47,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(testname, get_file_contents(@targetfile), testname) @@ -76,10 +76,8 @@ end # Run etch - # The assertion here is handled by run_etch as we're passing it an - # argument indicating that we expect failure. #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) end def test_commands_guard_succeeds @@ -108,7 +106,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was not touched assert_equal(testname, get_file_contents(@targetfile), testname) @@ -146,7 +144,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that both steps ran and in the proper order assert_equal("firststep\nsecondstep\n", get_file_contents(@targetfile), testname) @@ -191,7 +189,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that both commands ran, ordering doesn't matter assert_equal(['firstcmd', 'secondcmd'], get_file_contents(@targetfile).split("\n").sort, testname) @@ -237,7 +235,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that both commands ran and in the proper order assert_equal("firstcmd\nsecondcmd\n", get_file_contents(@targetfile), testname) @@ -291,7 +289,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the command-generated file and the regular file were created # properly @@ -336,7 +334,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that only the desired step executed assert_equal("notingroup\n", get_file_contents(@targetfile), testname) @@ -360,15 +358,13 @@ end # Run etch - # The assertion here is handled by run_etch as we're passing it an - # argument indicating that we expect failure. #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) end def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Added: trunk/test/test_conf.rb =================================================================== --- trunk/test/test_conf.rb (rev 0) +++ trunk/test/test_conf.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -0,0 +1,180 @@ +#!/usr/bin/ruby -w + +# +# Test etch's handling of its configuration file, etch.conf +# + +require File.join(File.dirname(__FILE__), 'etchtest') + +class EtchConfTests < Test::Unit::TestCase + include EtchTests + + def setup + # Generate a file to use as our etch target/destination + @targetfile = released_tempfile + #puts "Using #{@targetfile} as target file" + + # Generate a directory for our test repository + @repodir = initialize_repository + @server = get_server(@repodir) + + # Create a directory to use as a working directory for the client + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" + end + + def test_conf_server + # + # Test the server setting in etch.conf + # + testname = 'etch.conf server setting' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file></warning_file> + <source> + <plain>source</plain> + </source> + </file> + </config> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + # Test that it fails with a bogus etch.conf server setting + Dir.mkdir("#{@testroot}/etc") + File.open("#{@testroot}/etc/etch.conf", 'w') do |file| + file.puts "server = http://bogushost:0" + end + + # The --server option normally used by run_etch will override the config + # file, signal run_etch to leave out the --server option + run_etch(@server, @testroot, :server => '', :errors_expected => true) + + # And confirm that it now succeeds with a correct etch.conf server setting + File.open("#{@testroot}/etc/etch.conf", 'w') do |file| + file.puts "server = http://localhost:#{@server[:port]}" + end + + # The --server option normally used by run_etch will override the config + # file, signal run_etch to leave out the --server option + run_etch(@server, @testroot, :server => '') + assert_equal(sourcecontents, get_file_contents(@targetfile)) + end + + def test_conf_local + # + # Test the local setting in etch.conf + # + testname = 'etch.conf local setting' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file></warning_file> + <source> + <plain>source</plain> + </source> + </file> + </config> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + # Test that it fails with a bogus etch.conf local setting + Dir.mkdir("#{@testroot}/etc") + File.open("#{@testroot}/etc/etch.conf", 'w') do |file| + file.puts "local = /not/a/valid/path" + end + + # Although the config file local setting will override it, tell run_etch + # to leave out the --server option to avoid confusion + run_etch(@server, @testroot, :server => '', :errors_expected => true) + + # And confirm that it now succeeds with a correct etch.conf local setting + File.open("#{@testroot}/etc/etch.conf", 'w') do |file| + file.puts "local = #{@repodir}" + end + + # Although the config file local setting will override it, tell run_etch + # to leave out the --server option to avoid confusion + run_etch(@server, @testroot, :server => '') + assert_equal(sourcecontents, get_file_contents(@targetfile)) + end + + def test_conf_key + # FIXME + + # The --key option normally used by run_etch will override the config + # file, signal run_etch to leave out the --key option + #run_etch(@server, @testroot, :key => '') + end + + def test_conf_path + # + # Test the path setting in etch.conf + # + testname = 'etch.conf path setting' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file></warning_file> + <source> + <plain>source</plain> + </source> + </file> + <post> + <exec>testpost</exec> + </post> + </config> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + Dir.mkdir("#{@repodir}/pathtest") + File.open("#{@repodir}/pathtest/testpost", 'w') do |file| + file.puts '#!/bin/sh' + file.puts "touch #{@repodir}/pathtest/testpost.output" + end + File.chmod(0755, "#{@repodir}/pathtest/testpost") + + # Test that it fails without an etch.conf path setting + run_etch(@server, @testroot) + assert(!File.exist?("#{@repodir}/pathtest/testpost.output")) + + Dir.mkdir("#{@testroot}/etc") + File.open("#{@testroot}/etc/etch.conf", 'w') do |file| + file.puts "path = /bin:/usr/bin:/sbin:/usr/sbin:#{@repodir}/pathtest" + end + + # And confirm that it now succeeds with an etch.conf path setting + run_etch(@server, @testroot) + assert(File.exist?("#{@repodir}/pathtest/testpost.output")) + end + + def teardown + remove_repository(@repodir) + FileUtils.rm_rf(@testroot) + FileUtils.rm_rf(@targetfile) + end +end Modified: trunk/test/test_delete.rb =================================================================== --- trunk/test/test_delete.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_delete.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -19,8 +19,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" # Generate another file to use as our link target @destfile = released_tempfile @@ -47,7 +47,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -73,7 +73,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the link was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -101,7 +101,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the directory was not deleted assert(File.directory?(@targetfile), testname) @@ -130,7 +130,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the directory was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -153,7 +153,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that we still don't have a file. That's rather unlikely, # this is really more a test that etch doesn't throw an error if @@ -187,7 +187,7 @@ # Run etch #puts "Running duplicate script instructions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert(!File.exist?(@targetfile), 'duplicate script instructions') @@ -220,7 +220,7 @@ # Run etch #puts "Running contradictory script instructions test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file wasn't removed assert(File.exist?(@targetfile), 'contradictory script instructions') @@ -229,7 +229,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) FileUtils.rm_rf(@destfile) end Modified: trunk/test/test_depend.rb =================================================================== --- trunk/test/test_depend.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_depend.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -21,8 +21,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_depends @@ -76,7 +76,7 @@ # Run etch #puts "Running initial dependency test" - run_etch(@server, @testbase, false) + run_etch(@server, @testroot) # Verify that the files were created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'dependency file 1') @@ -138,7 +138,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase, false, @targetfile) + run_etch(@server, @testroot, :extra_args => @targetfile) # Verify that the files were created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'single request dependency file 1') @@ -202,7 +202,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true, @targetfile) + run_etch(@server, @testroot, :errors_expected => true, :extra_args => @targetfile) # Verify that the files weren't modified assert_equal(origcontents, get_file_contents(@targetfile), 'circular dependency file 1') @@ -256,7 +256,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the regular file and the command-generated file were created # properly @@ -268,7 +268,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_file.rb =================================================================== --- trunk/test/test_file.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_file.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -19,8 +19,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_files @@ -49,7 +49,7 @@ # Run etch #puts "Running initial file test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = '' @@ -86,7 +86,7 @@ # Run etch #puts "Running initial file test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = '' @@ -127,7 +127,7 @@ # Run etch #puts "Running different warning file test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = '' @@ -164,7 +164,7 @@ # Run etch #puts "Running no warning file test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'no warning file') @@ -194,7 +194,7 @@ # Run etch #puts "Running different line comment test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = '' @@ -233,7 +233,7 @@ # Run etch #puts "Running comment open/close test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = "/*\n" @@ -273,7 +273,7 @@ # Run etch #puts "Running warning on second line test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = sourcecontents_firstline @@ -311,7 +311,7 @@ # Run etch #puts "Running no space around warning test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly correctcontents = '' @@ -344,7 +344,7 @@ # Run etch #puts "Running file ownership and permissions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file ownership got set correctly # Most systems don't support give-away chown, so this test won't work @@ -380,7 +380,7 @@ # Run etch #puts "Running file ownership w/ bogus owner/group names" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the ownership defaulted to UID/GID 0 # Most systems don't support give-away chown, so this test won't work @@ -416,7 +416,7 @@ # Run etch #puts "Running always_manage_metadata test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file permissions got set correctly perms = File.stat(@targetfile).mode & 07777 @@ -456,7 +456,7 @@ # Run etch #puts "Running duplicate plain instructions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate plain instructions') @@ -495,7 +495,7 @@ # Run etch #puts "Running contradictory plain instructions test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory plain instructions') @@ -531,7 +531,7 @@ # Run etch #puts "Running duplicate template instructions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate template instructions') @@ -570,7 +570,7 @@ # Run etch #puts "Running contradictory template instructions test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory template instructions') @@ -606,7 +606,7 @@ # Run etch #puts "Running duplicate script instructions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate script instructions') @@ -645,7 +645,7 @@ # Run etch #puts "Running contradictory script instructions test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory script instructions') @@ -684,7 +684,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(specialtargetfile), testname) @@ -692,7 +692,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_history.rb =================================================================== --- trunk/test/test_history.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_history.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -20,11 +20,11 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" - @origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") - @historydir = File.join(@testbase, 'history', "#{@targetfile}.HISTORY") + @origfile = File.join(@testroot, 'var', 'etch', 'orig', "#{@targetfile}.ORIG") + @historydir = File.join(@testroot, 'var', 'etch', 'history', "#{@targetfile}.HISTORY") end def test_history @@ -60,7 +60,7 @@ # Run etch #puts "Running initial history test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(origcontents, get_file_contents(@origfile), 'original backup of file') assert_equal(origcontents, get_file_contents(File.join(@historydir, '0000')), '0000 history file') @@ -77,7 +77,7 @@ # Run etch #puts "Running update test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(origcontents, get_file_contents(@origfile), 'original backup of file unchanged') assert_equal(origcontents, get_file_contents(File.join(@historydir, '0000')), '0000 history file') @@ -107,7 +107,7 @@ # Run etch #puts "Running revert test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(origcontents, get_file_contents(@targetfile), 'original contents reverted') assert(!File.exist?(@origfile), 'reverted original file') @@ -128,7 +128,7 @@ # Run etch #puts "Running revert test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(updatedorigcontents, get_file_contents(@targetfile), 'Updated original contents unchanged') assert(!File.exist?(@origfile), 'reverted original file') @@ -177,7 +177,7 @@ # Run etch #puts "Running history setup test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(origcontents + "\n", get_file_contents(@origfile), 'original backup of file via setup') assert_equal(sourcecontents + origcontents + "\n", get_file_contents(@targetfile), 'contents using original backup of file via setup') @@ -217,7 +217,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) origcontents = "This is the original text for #{testname}" @@ -245,7 +245,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(origcontents + "\n", get_file_contents(@origfile), testname) end @@ -283,7 +283,7 @@ # Run etch #puts "Running history link test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(@destfile, File.readlink(@origfile), 'original backup of link') assert_match("#{@targetfile} -> #{@destfile}", get_file_contents(File.join(@historydir, '0000')), '0000 history file of link') @@ -328,7 +328,7 @@ # Run etch #puts "Running history directory test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert(File.directory?(@origfile), 'original backup of directory') # Verify that etch backed up the original directory properly @@ -347,7 +347,7 @@ # differently in that case # - origtarfile = File.join(@testbase, 'orig', "#{@targetfile}.TAR") + origtarfile = File.join(@testroot, 'var', 'etch', 'orig', "#{@targetfile}.TAR") # Make the original target a directory File.delete(@targetfile) @@ -376,7 +376,7 @@ # Run etch #puts "Running history directory contents test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # In this case, because we converted a directory to something else the # original will be a tarball of the directory @@ -445,7 +445,7 @@ # Run etch #puts "Running history conversion test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(mockorigcontents, get_file_contents(File.join(@historydir, '0000')), 'RCS conv 0000 history file') assert_equal(mocksourcecontents, get_file_contents(File.join(@historydir, '0001')), 'RCS conv 0001 history file') @@ -454,7 +454,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_link.rb =================================================================== --- trunk/test/test_link.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_link.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -24,8 +24,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" # Generate a couple more files to use as our link targets @destfile = released_tempfile @@ -51,7 +51,7 @@ # Run etch #puts "Running initial link test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(@destfile, File.readlink(@targetfile), 'link create') @@ -72,7 +72,7 @@ # Run etch #puts "Running link update test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(@destfile2, File.readlink(@targetfile), 'link update') @@ -101,7 +101,7 @@ # Run etch #puts "Running link update from non-existent file test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(@destfile, File.readlink(@targetfile), 'link update from non-existent file') end @@ -127,7 +127,7 @@ # Run etch #puts "Running link to non-existent destination test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the link was not created assert(!File.symlink?(@targetfile), 'link to non-existent destination') @@ -151,7 +151,7 @@ # Run etch #puts "Running link to non-existent destination with override test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the link was updated properly assert_equal(@destfile, File.readlink(@targetfile), 'link to non-existent destination with override') @@ -180,7 +180,7 @@ # Run etch #puts "Running relative link test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the link was updated properly assert_equal(reldestfile, File.readlink(@targetfile), 'relative link') @@ -207,7 +207,7 @@ # Run etch #puts "Running link ownership and permissions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the link ownership got set correctly # Most systems don't support give-away chown, so this test won't work @@ -242,7 +242,7 @@ # Run etch #puts "Running duplicate dest instructions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(@destfile, File.readlink(@targetfile), 'duplicate dest instructions') end @@ -266,7 +266,7 @@ # Run etch #puts "Running contradictory dest instructions test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the link wasn't created assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory dest instructions') @@ -295,7 +295,7 @@ # Run etch #puts "Running duplicate script instructions test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) assert_equal(@destfile, File.readlink(@targetfile), 'duplicate script instructions') end @@ -326,7 +326,7 @@ # Run etch #puts "Running contradictory script instructions test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the link wasn't created assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory script instructions') @@ -334,7 +334,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) FileUtils.rm_f(@destfile) FileUtils.rm_f(@destfile2) Modified: trunk/test/test_local_requests.rb =================================================================== --- trunk/test/test_local_requests.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_local_requests.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -19,8 +19,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_local_requests_script @@ -44,7 +44,7 @@ end # Create the local request file - requestdir = File.join(@testbase, 'requests', @targetfile) + requestdir = File.join(@testroot, 'var', 'etch', 'requests', @targetfile) requestfile = File.join(requestdir, 'testrequest') FileUtils.mkdir_p(requestdir) File.open(requestfile, 'w') do |file| @@ -68,7 +68,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -95,7 +95,7 @@ end # Create the local request file - requestdir = File.join(@testbase, 'requests', @targetfile) + requestdir = File.join(@testroot, 'var', 'etch', 'requests', @targetfile) requestfile = File.join(requestdir, 'testrequest') FileUtils.mkdir_p(requestdir) File.open(requestfile, 'w') do |file| @@ -120,7 +120,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly # Our whitespace in the heredoc above gets added to the generated file, so @@ -131,7 +131,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_nodegroups.rb =================================================================== --- trunk/test/test_nodegroups.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_nodegroups.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -20,8 +20,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_group @@ -51,7 +51,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -92,7 +92,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -133,7 +133,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase) + run_etch(@server, @testroot) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -177,7 +177,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) # Verify that the file wasn't modified assert_equal(oldsourcecontents, get_file_contents(@targetfile), testname) @@ -185,7 +185,7 @@ def teardown remove_repository(@repodir) - FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@testroot) FileUtils.rm_rf(@targetfile) end end Modified: trunk/test/test_options.rb =================================================================== --- trunk/test/test_options.rb 2010-11-25 00:05:46 UTC (rev 224) +++ trunk/test/test_options.rb 2010-11-25 00:07:42 UTC (rev 225) @@ -20,8 +20,8 @@ @server = get_server(@repodir) # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" + @testroot = tempdir + #puts "Using #{@testroot} as client working directory" end def test_killswitch @@ -62,7 +62,7 @@ # Run etch #puts "Running killswitch test" - run_etch(@server, @testbase, true) + run_etch(@server, @testroot, :errors_expected => true) assert_equal(origcontents, get_file_contents(@targetfile), 'killswitch') end @@ -100,7 +100,7 @@ # Run etch #puts "Running --dry-run test" - run_etch(@server, @testbase, false, '--dry-run') + ... [truncated message content] |