From: <jh...@us...> - 2009-02-06 17:23:15
|
Revision: 65 http://etch.svn.sourceforge.net/etch/?rev=65&view=rev Author: jheiss Date: 2009-02-06 17:23:12 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Add tests for duplicate and contradictory instructions Modified Paths: -------------- trunk/test/TODO trunk/test/delete.rb trunk/test/file.rb trunk/test/link.rb Modified: trunk/test/TODO =================================================================== --- trunk/test/TODO 2009-02-06 17:22:39 UTC (rev 64) +++ trunk/test/TODO 2009-02-06 17:23:12 UTC (rev 65) @@ -1,8 +1,6 @@ directory Basic operation Owner/group/perms - -config.xml: Etch aborts when given contradictory instructions Command-line options: Modified: trunk/test/delete.rb =================================================================== --- trunk/test/delete.rb 2009-02-06 17:22:39 UTC (rev 64) +++ trunk/test/delete.rb 2009-02-06 17:23:12 UTC (rev 65) @@ -164,6 +164,70 @@ # the assert within run_etch. assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) + # + # Test duplicate script instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <delete> + <script>source</script> + <script>source</script> + </delete> + </config> + EOF + end + + File.open(@targetfile, 'w') do |file| + file.puts('Original contents') + end + + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.puts("@contents << 'true'") + end + + # Run etch + #puts "Running duplicate script instructions test" + run_etch(@port, @testbase) + + assert(!File.exist?(@targetfile), 'duplicate script instructions') + + # + # Test contradictory script instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <delete> + <script>source</script> + <script>source2</script> + </delete> + </config> + EOF + end + + File.open(@targetfile, 'w') do |file| + file.puts('Original contents') + end + + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.puts("@contents << 'true'") + end + File.open("#{@repodir}/source/#{@targetfile}/source2", 'w') do |file| + file.puts("@contents << 'true'") + end + + # Run etch + #puts "Running contradictory script instructions test" + run_etch(@port, @testbase, true) + + # Verify that the file wasn't removed + assert(File.exist?(@targetfile), 'contradictory script instructions') + end def teardown Modified: trunk/test/file.rb =================================================================== --- trunk/test/file.rb 2009-02-06 17:22:39 UTC (rev 64) +++ trunk/test/file.rb 2009-02-06 17:23:12 UTC (rev 65) @@ -427,6 +427,232 @@ # And verify that the file contents didn't change assert_equal(testcontents, get_file_contents(@targetfile), 'always_manage_metadata contents') + + # + # Test duplicate plain instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file/> + <source> + <plain>source</plain> + <plain>source</plain> + </source> + </file> + </config> + EOF + end + + origcontents = "This is the original contents\n" + File.chmod(0644, @targetfile) # Need to give ourselves write perms + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + sourcecontents = "This is the source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + # Run etch + #puts "Running duplicate plain instructions test" + run_etch(@port, @testbase) + + # Verify that the file contents were updated + assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate plain instructions') + + # + # Test contradictory plain instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <source> + <plain>source</plain> + <plain>source2</plain> + </source> + </file> + </config> + EOF + end + + origcontents = "This is the original contents\n" + File.chmod(0644, @targetfile) # Need to give ourselves write perms + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + sourcecontents = "This is the first source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + source2contents = "This is the second source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source2", 'w') do |file| + file.write(source2contents) + end + + # Run etch + #puts "Running contradictory plain instructions test" + run_etch(@port, @testbase, true) + + # Verify that the file contents didn't change + assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory plain instructions') + + # + # Test duplicate template instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file/> + <source> + <template>source</template> + <template>source</template> + </source> + </file> + </config> + EOF + end + + origcontents = "This is the original contents\n" + File.chmod(0644, @targetfile) # Need to give ourselves write perms + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + sourcecontents = "This is the source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + # Run etch + #puts "Running duplicate template instructions test" + run_etch(@port, @testbase) + + # Verify that the file contents were updated + assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate template instructions') + + # + # Test contradictory template instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <source> + <template>source</template> + <template>source2</template> + </source> + </file> + </config> + EOF + end + + origcontents = "This is the original contents\n" + File.chmod(0644, @targetfile) # Need to give ourselves write perms + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + sourcecontents = "This is the first source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + source2contents = "This is the second source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source2", 'w') do |file| + file.write(source2contents) + end + + # Run etch + #puts "Running contradictory template instructions test" + run_etch(@port, @testbase, true) + + # Verify that the file contents didn't change + assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory template instructions') + + # + # Test duplicate script instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file/> + <source> + <script>source</script> + <script>source</script> + </source> + </file> + </config> + EOF + end + + origcontents = "This is the original contents\n" + File.chmod(0644, @targetfile) # Need to give ourselves write perms + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + sourcecontents = "This is the source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.puts("@contents << '#{sourcecontents}'") + end + + # Run etch + #puts "Running duplicate script instructions test" + run_etch(@port, @testbase) + + # Verify that the file contents were updated + assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate script instructions') + + # + # Test contradictory script instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <source> + <script>source</script> + <script>source2</script> + </source> + </file> + </config> + EOF + end + + origcontents = "This is the original contents\n" + File.chmod(0644, @targetfile) # Need to give ourselves write perms + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + sourcecontents = "This is the first source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + source2contents = "This is the second source contents\n" + File.open("#{@repodir}/source/#{@targetfile}/source2", 'w') do |file| + file.write(source2contents) + end + + # Run etch + #puts "Running contradictory script instructions test" + run_etch(@port, @testbase, true) + + # Verify that the file contents didn't change + assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory script instructions') + end def teardown Modified: trunk/test/link.rb =================================================================== --- trunk/test/link.rb 2009-02-06 17:22:39 UTC (rev 64) +++ trunk/test/link.rb 2009-02-06 17:23:12 UTC (rev 65) @@ -219,6 +219,116 @@ # Verify that the link permissions got set correctly perms = File.lstat(@targetfile).mode & 07777 assert_equal(0777, perms, 'link perms') + + # + # Test duplicate dest instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <link> + <dest>#{@destfile}</dest> + <dest>#{@destfile}</dest> + </link> + </config> + EOF + end + + File.delete(@targetfile) + + # Run etch + #puts "Running duplicate dest instructions test" + run_etch(@port, @testbase) + + assert_equal(@destfile, File.readlink(@targetfile), 'duplicate dest instructions') + + # + # Test contradictory dest instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <link> + <dest>#{@destfile}</dest> + <dest>#{@destfile2}</dest> + </link> + </config> + EOF + end + + File.delete(@targetfile) if File.symlink?(@targetfile) + + # Run etch + #puts "Running contradictory dest instructions test" + run_etch(@port, @testbase, true) + + # Verify that the link wasn't created + assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory dest instructions') + + # + # Test duplicate script instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <link> + <script>source</script> + <script>source</script> + </link> + </config> + EOF + end + + File.delete(@targetfile) if File.symlink?(@targetfile) + + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.puts("@contents << '#{@destfile}'") + end + + # Run etch + #puts "Running duplicate script instructions test" + run_etch(@port, @testbase) + + assert_equal(@destfile, File.readlink(@targetfile), 'duplicate script instructions') + + # + # Test contradictory script instructions + # + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <link> + <script>source</script> + <script>source2</script> + </link> + </config> + EOF + end + + File.delete(@targetfile) if File.symlink?(@targetfile) + + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.puts("@contents << '#{@destfile}'") + end + File.open("#{@repodir}/source/#{@targetfile}/source2", 'w') do |file| + file.puts("@contents << '#{@destfile2}'") + end + + # Run etch + #puts "Running contradictory script instructions test" + run_etch(@port, @testbase, true) + + # Verify that the link wasn't created + assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory script instructions') + end def teardown This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-09-11 23:06:49
|
Revision: 90 http://etch.svn.sourceforge.net/etch/?rev=90&view=rev Author: jheiss Date: 2009-09-11 23:06:37 +0000 (Fri, 11 Sep 2009) Log Message: ----------- Add timeout to output capturing so that ill-behaved daemons don't cause etch to hang around forever. Add unit tests for output capturing. Note that the output capturing timeout test is commented out as the timeout is rather long, thus causing the test to take a long time to run. Not quite sure the best way to handle that. Replace instances of assert(string.include?(substring)) with assert_match(substring, string) so that the user gets a better error if the assertion fails. Verified that it does a substring match if the first arg is a string instead of a regex (a la String#sub), as the documentation doesn't make that clear. Add support for local requests. Tests of client authentication Modify start_server method to return pid in addition to port, and modify stop_server method to take a pid to stop. This allows folks to run more than one server at a time. Modify run_etch method to run etch with a test key, otherwise etch tries to use the system's host key, which won't be readable unless you run the tests as root, so etch just skips over attaching an authentication signature to requests. Modified Paths: -------------- trunk/test/actions.rb trunk/test/attributes.rb trunk/test/delete.rb trunk/test/depend.rb trunk/test/etchtest.rb trunk/test/file.rb trunk/test/history.rb trunk/test/link.rb trunk/test/nodegroups.rb trunk/test/options.rb trunk/test/scripts.rb trunk/test/transitions.rb Added Paths: ----------- trunk/test/auth.rb trunk/test/keys/ trunk/test/keys/testkey trunk/test/keys/testkey.pub trunk/test/keys/testkey2 trunk/test/keys/testkey2.pub trunk/test/local_requests.rb trunk/test/outputcapture.rb Modified: trunk/test/actions.rb =================================================================== --- trunk/test/actions.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/actions.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -19,7 +19,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -85,8 +85,8 @@ # The setup actions will get run several times as we loop # back and forth with the server sending original sums and # contents. So just verify that they were run at least once. - assert(get_file_contents("#{@repodir}/server_setup").include?("server_setup\n"), 'server_setup') - assert(get_file_contents("#{@repodir}/setup").include?("setup\n"), 'setup') + assert_match("server_setup\n", get_file_contents("#{@repodir}/server_setup"), 'server_setup') + assert_match("setup\n", get_file_contents("#{@repodir}/setup"), 'setup') assert_equal("pre\n", get_file_contents("#{@repodir}/pre"), 'pre') assert_equal( "exec_once\n", get_file_contents("#{@repodir}/exec_once"), 'exec_once') @@ -372,7 +372,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/attributes.rb =================================================================== --- trunk/test/attributes.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/attributes.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -20,7 +20,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -627,7 +627,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Added: trunk/test/auth.rb =================================================================== --- trunk/test/auth.rb (rev 0) +++ trunk/test/auth.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1,259 @@ +#!/usr/bin/ruby -w + +# +# Test etch's handling of client authentication +# + +require 'test/unit' +require 'etchtest' +require 'tempfile' +require 'fileutils' +require 'net/http' +require 'rexml/document' +require 'facter' + +class EtchAuthTests < Test::Unit::TestCase + include EtchTests + + def setup + # Generate a file to use as our etch target/destination + @targetfile = Tempfile.new('etchtest').path + #puts "Using #{@targetfile} as target file" + + # Generate a directory for our test repository + @repodir = initialize_repository + @port, @pid = start_server(@repodir) + + # Create a directory to use as a working directory for the client + @testbase = tempdir + #puts "Using #{@testbase} as client working directory" + + # Make sure the server will initially think this is a new client + hostname = Facter['fqdn'].value + Net::HTTP.start('localhost', @port) do |http| + # Find our client id + response = http.get("/clients.xml?name=#{hostname}") + if !response.kind_of?(Net::HTTPSuccess) + response.error! + end + response_xml = REXML::Document.new(response.body) + client_id = nil + if response_xml.elements['/clients/client/id'] + client_id = response_xml.elements['/clients/client/id'].text + end + # Delete our client entry + if client_id + response = http.delete("/clients/#{client_id}.xml") + if !response.kind_of?(Net::HTTPSuccess) + response.error! + end + end + end + end + + # Test authentication when new clients are allowed + def test_auth_allow_new_clients + File.open(File.join(@repodir, 'etchserver.conf'), 'w') do |file| + file.puts 'auth_enabled=true' + file.puts 'auth_deny_new_clients=false' + end + + # + # New client, should work + # + testname = 'auth, allow new clients, new client' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <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 + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase) + + # Verify that the file was created properly + assert_equal(sourcecontents, get_file_contents(@targetfile), testname) + + # + # Existing client, should work + # + testname = 'auth, allow new clients, existing client' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <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 + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase) + + # Verify that the file was created properly + assert_equal(sourcecontents, get_file_contents(@targetfile), testname) + + # + # Existing client, bad signature, should be denied + # + testname = 'auth, allow new clients, existing client, bad signature' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <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 + + # Put some text into the original file so that we can make sure it + # is not touched. + origcontents = "This is the original text\n" + File.delete(@targetfile) + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + + # Run etch with the wrong key to force a bad signature + #puts "Running '#{testname}' test" + run_etch(@port, @testbase, true, '--key=keys/testkey2') + + # Verify that the file was not touched + assert_equal(origcontents, get_file_contents(@targetfile), testname) + end + # Test authentication when new clients are denied + def test_auth_deny_new_clients + File.open(File.join(@repodir, 'etchserver.conf'), 'w') do |file| + file.puts 'auth_enabled=true' + file.puts 'auth_deny_new_clients=true' + end + + # + # New client, should fail + # + testname = 'auth, deny new clients, new client' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <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 + + # Put some text into the original file so that we can make sure it + # is not touched. + origcontents = "This is the original text\n" + File.delete(@targetfile) + File.open(@targetfile, 'w') do |file| + file.write(origcontents) + end + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase, true) + + # Verify that the file was not touched + assert_equal(origcontents, get_file_contents(@targetfile), testname) + + # + # Add this client to the server so that it will now be considered + # an existing client + # + puts "# Starting a second copy of the server and adding this client to the database" + sleep 3 + repodir2 = initialize_repository + port2, pid2 = start_server(repodir2) + run_etch(port2, @testbase) + stop_server(pid2) + remove_repository(repodir2) + + # + # Existing client, should work + # + testname = 'auth, deny new clients, existing client' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <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 + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase) + + # Verify that the file was created properly + assert_equal(sourcecontents, get_file_contents(@targetfile), testname) + end + + def teardown + stop_server(@pid) + remove_repository(@repodir) + FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@targetfile) + end +end + Property changes on: trunk/test/auth.rb ___________________________________________________________________ Added: svn:executable + * Modified: trunk/test/delete.rb =================================================================== --- trunk/test/delete.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/delete.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -19,7 +19,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -231,7 +231,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/depend.rb =================================================================== --- trunk/test/depend.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/depend.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -21,7 +21,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -202,7 +202,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/etchtest.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -48,13 +48,13 @@ def start_server(repodir) ENV['etchserverbase'] = repodir # Pick a random port in the 3001-6000 range (range somewhat randomly chosen) - port = 3001 + rand(2999) - if @serverpid = fork + port = 3001 + rand(3000) + if pid = fork puts "Giving the server some time to start up" sleep(5) else Dir.chdir('../server/trunk') - #Dir.chdir('../server/branches/libxml') + # FIXME: silence the server (see various failed attempts...) # Causes ruby to fork, so we're left with a useless pid #exec("./script/server -d -p #{port}") # Causes ruby to invoke a copy of sh to run the command (to handle @@ -62,12 +62,12 @@ #exec("./script/server -p #{port} > /dev/null") exec("./script/server -p #{port}") end - port + [port, pid] end - def stop_server - Process.kill('TERM', @serverpid) - Process.waitpid(@serverpid) + def stop_server(pid) + Process.kill('TERM', pid) + Process.waitpid(pid) end def run_etch(port, testbase, errors_expected=false, extra_args='') @@ -80,9 +80,12 @@ puts "# Errors expected here" puts "#" sleep 3 - assert(!system("ruby ../client/trunk/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} #{extra_args}")) + end + result = system("ruby ../client/trunk/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} --key=keys/testkey #{extra_args}") + if errors_expected + assert(!result) else - assert(system("ruby ../client/trunk/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} #{extra_args}")) + assert(result) end end Modified: trunk/test/file.rb =================================================================== --- trunk/test/file.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/file.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -19,7 +19,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -656,7 +656,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/history.rb =================================================================== --- trunk/test/history.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/history.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -20,7 +20,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -220,7 +220,7 @@ assert_equal(@destfile, File.readlink(origfile), 'original backup of link') system("cd #{historydir} && co -q -f -r1.1 #{historyfile}") - assert(get_file_contents(historyfile).include?("#{@targetfile} -> #{@destfile}"), 'history backup of link') + assert_match("#{@targetfile} -> #{@destfile}", get_file_contents(historyfile), 'history backup of link') end def test_history_directory @@ -275,7 +275,7 @@ assert_equal(before_mode, File.stat(origfile).mode, 'original directory mode') # Check that the history log looks reasonable, it should contain an # 'ls -ld' of the directory - assert(get_file_contents(historyfile).include?(" #{@targetfile}"), 'history backup of directory') + assert_match(" #{@targetfile}", get_file_contents(historyfile), 'history backup of directory') end def test_history_directory_contents @@ -328,7 +328,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Added: trunk/test/keys/testkey =================================================================== --- trunk/test/keys/testkey (rev 0) +++ trunk/test/keys/testkey 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEoQIBAAKCAQEA7+HtwaFvMwwoquMEHrhMBHp0gsy4bXkmWrTc6bn37BTLnIr/ +fA6CkdzP+L/bvLbUzKh8mCRIiJNiuytz3AJEdBF4x2SrRO873iN6/32SN0dh8ER3 +CL2McR+SFgJO5LH59d7vi20VWpcquz3eog/siMb5N2r02D3j7n7fZqOLyQ+bjM29 +XaeuylPJlok7o0KXzp4lFqmLoN7EVAty1PsewYwb/k9RGAirwUW++nB/86qPs3kN +nwibNiGIYAW44U56MMXZuLTKZJOVaOcBDDbSKEK3QkqOPZFIAxMI49k0hDoMX5n3 +mi5n3QSS3p9BiK8elKke4KQZawsg088Q7obQGwIBIwKCAQAUj7VLHHc+48j4tF9w +WPCSq2kShpN3GQNJmnlV3L16orJd4AdFJdCtarK9jMmxFvxMDnEUWuGlTnYtTN4L +iypwWUTd5A6uIyJjf2JQadlVMgEUmCd1xxqqnE5ZqG0pi5kVExvYwDUHw9B2cwR0 +SoH9GF6BF8vYBU4NINFR8MLWuAdqix492wgh16aur/VvDIei4z8t8Ny/DHd8Hpwp +Kn3y5vfnNt5XMEHE53ZNUzYTsYHJtJzZ/y4aITfEu2+GvsNxpRCSnvDNehpppEiu +QYlgEi4fsR52ltyKfli9qKoxGFxN30RqrVDxATK9TDdRoOII9Tfra6txlfJtIj8N +cjzzAoGBAPwhFmTEGx09wh2NHQC9PFRE6EfZqc7xD8ohO3Tz1+N2dS4h6wHHUM43 +yD6hUatbEMrMcg+1zXt9r/V8lDS18QSjtKB2vmwkiHMjRQ4aQRmQCjC9kILnNzTY +FUEkUtAkuXEThKyWclmRpMcalZQ8oUjlsdYc/qElhgzprFa5lewdAoGBAPOQtaJy +kTKsaGi+EguBHr/IBVF6WwKlkt2KwDVWM33j5aGoOYKs2jOQRnF9qV2y2DALIS1P +RLCHmLLsPBmyATgJ4M0+DWTiz+4fz/hWTnXiDxcS/P1EJLDbO7xwK/giubu/kyzR +1gik/HvOOyfpDjNGdRGzvVLDBQebky/tZseXAoGBAPTs8S6v39NDTtrg2lh9UIxg +MhnpYyDM6sRazAs2BOuXpQg+NL/mMT1awoX7y63GLZHN6yU0Q/RONecoj/iwvj8F +baMxhcgjfTyl60+HN+zyUwrGxuWQJwAiXcpAivYVC+owN72ZdmWjbN6sHEbbz+Bq +Gng5bGIHMcNmp2owoERzAoGAFOCEmOU/pUH6Uh7rmpYJ8y5m2xkdvmX2pUZoPxYE +aeBVguKIliwSs/ZscCC2vuNxnbfPpMxHt1wUZxuQH3WoVUKs3mRnjE30kMDl8Lbw +yEaTlEN0xUBa6pZy1aM2+AL5+iZdEnhizYp8Cpyl/BtKXCqcUfl2oLGhWGxrs6ai +aOECgYAdCplM1lgfd9NsCe00kj6j4or+W6dOJuwZuYncLlnFOmtu+zNQyDUIL5tU +DYL6iCst2AzzoKrhlw5W/PdnMSrfKw2KnXhJnibZrucRuCrkjelhgEffQwA2/JQN +efPp5CZ2wZitEwSgKlCSERibHnRQKgXiDdSvXlpCMBY9qyPsdw== +-----END RSA PRIVATE KEY----- Added: trunk/test/keys/testkey.pub =================================================================== --- trunk/test/keys/testkey.pub (rev 0) +++ trunk/test/keys/testkey.pub 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7+HtwaFvMwwoquMEHrhMBHp0gsy4bXkmWrTc6bn37BTLnIr/fA6CkdzP+L/bvLbUzKh8mCRIiJNiuytz3AJEdBF4x2SrRO873iN6/32SN0dh8ER3CL2McR+SFgJO5LH59d7vi20VWpcquz3eog/siMb5N2r02D3j7n7fZqOLyQ+bjM29XaeuylPJlok7o0KXzp4lFqmLoN7EVAty1PsewYwb/k9RGAirwUW++nB/86qPs3kNnwibNiGIYAW44U56MMXZuLTKZJOVaOcBDDbSKEK3QkqOPZFIAxMI49k0hDoMX5n3mi5n3QSS3p9BiK8elKke4KQZawsg088Q7obQGw== testkey Added: trunk/test/keys/testkey2 =================================================================== --- trunk/test/keys/testkey2 (rev 0) +++ trunk/test/keys/testkey2 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAyKTk+SmvLUnZ1AYCDFw1NAqGwddGcavPJu2mQzx0sfZKVR6V +dUsE8pR4z2uZszEH/yqeA+hoxebjNWUgb7hV6FS+T5Vzwm9sIWeul/d6Erqu2bxU +DNfWamhsY+Xf+ubrnCEeSWku5EsFJNqLiwu7ZlzFG0f6l9kmUH3BGgralUaVWOeR +ci/GSDJ3phIA1XqRBR92ImlMp9nQY2kd9Hr3O3Ey90dwGKfY8a8sUqD1RKya/0+7 +JSbuWHUI4LMNKed8i4JkpH7QP2okXyPJtfq9GzShv5RRl/C5gVsLMvpajPX9tFKe +uk9z7BucQfZ5qDipR3m8RAcUwqOjZpz34RD1qwIBIwKCAQBbuRg3Y4NH5z8B1txd +a/sQedc0CqPcMUjBVrJn4R9nTAS5Mo13csBu5MmDZGOFHbqDRq6is2MYpBAYaL5e +9S6WGBx8JxBY4nqS7ZGkjmOwyl6PbAkqcUwTYu+4o5mXRP3+OwaH9ZHHcsCF4D/K +iQU2G8fR9QTXs7m+ZV+W4GPsdzot5GltI7Xg7ewZq0f6piMYUOwJLtc/ma+cW0F4 +ta9SyN6ORMOH5poJpNYTF6p7YvL6187aCKu8W4NVCeTTct5iJy/i2OQmiFFNIptz +gIbZV/GN0qdrdsoW0Z3VkZlVyKO+rjILV20PRxtSGOks26F1Peuak+iBEkugOKRY +hB4LAoGBAPCKt6C9/o9+HD3XerYKfyXN9+kxALH67mfKJcGuDA2NgyhitczrO2wK +cSmSFCtp86PhALM9NHIV54Psms6ZOZAE6IBhSM/mp5FOC42QvxJtKOkgwrFESeBi +IUpGICMEsaTvVICGzjh7oYD2Eiq1p9e+1xfDokauuLTxJ+wOnBUFAoGBANWJzEoV +cxjuDcVWcJ1Wr/5x9oidUiPRyzhzO70OYXoo1qO9Wzd0I/vyJW52yQTs0IOZlvNq +/4SWhVWqEpoCIqYP5CuC+41EeGE4XIgYkoOym1g4lNIYkv8NTzepq7gcnXKT4RC6 +sfzfDo+ITdDgcGBYKzEeQUF5kukG+SRQ097vAoGAdNWppdigNxFeLKp9blzeq/ZT +16oWR9Gm/zZM2mp64gLn7wtfngvbCJdbiThS8IPrXjoWSG4vapzsywyFtM4UpQmy +wgNd4VLGayXoWrQFCPMxIMbE9wPpXluMgylgEQJHp+H12Ab2czS8KLII0uqEuT9v +ybbLKaVSZoPC7v/IJ3cCgYEAwzwofj9/LLxkXKbNXKcHTwkb6p52/C2GmgL0yhvG +1ha1nQTlrwsZleS0gkC3yf0WabD/CnB0lnr9kCZ3aDx3c0G6q3Bw9i/5CG4LdR3H +yN3P26FyHyxpI7RlrzwKtvWXRC9usDWqC8SfmSwp44tfbgd38mTN8rhLzb07jurQ +VssCgYEAuu5KWdb2ns5CGAclpi/Qm/+si9jSCwq/JGiztrLwG6eJKCS3FPOMzjbt +3skfBA+yepewc3tQgCLYdPfuN0A4R28Yv3uET05ysp4O0AXaMhMx8t63uT+titOT +3if5nWOPnoCM1TCpNnnUQAptJF6R/XSX89FFaszGJfgNKI15+2Q= +-----END RSA PRIVATE KEY----- Added: trunk/test/keys/testkey2.pub =================================================================== --- trunk/test/keys/testkey2.pub (rev 0) +++ trunk/test/keys/testkey2.pub 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyKTk+SmvLUnZ1AYCDFw1NAqGwddGcavPJu2mQzx0sfZKVR6VdUsE8pR4z2uZszEH/yqeA+hoxebjNWUgb7hV6FS+T5Vzwm9sIWeul/d6Erqu2bxUDNfWamhsY+Xf+ubrnCEeSWku5EsFJNqLiwu7ZlzFG0f6l9kmUH3BGgralUaVWOeRci/GSDJ3phIA1XqRBR92ImlMp9nQY2kd9Hr3O3Ey90dwGKfY8a8sUqD1RKya/0+7JSbuWHUI4LMNKed8i4JkpH7QP2okXyPJtfq9GzShv5RRl/C5gVsLMvpajPX9tFKeuk9z7BucQfZ5qDipR3m8RAcUwqOjZpz34RD1qw== testkey2 Modified: trunk/test/link.rb =================================================================== --- trunk/test/link.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/link.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -20,7 +20,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -332,7 +332,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Added: trunk/test/local_requests.rb =================================================================== --- trunk/test/local_requests.rb (rev 0) +++ trunk/test/local_requests.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1,142 @@ +#!/usr/bin/ruby -w + +# +# Test etch's handling of local requests +# + +require 'test/unit' +require 'etchtest' +require 'tempfile' +require 'fileutils' + +class EtchLocalRequestsTests < Test::Unit::TestCase + include EtchTests + + def setup + # Generate a file to use as our etch target/destination + @targetfile = Tempfile.new('etchtest').path + #puts "Using #{@targetfile} as target file" + + # Generate a directory for our test repository + @repodir = initialize_repository + @port, @pid = start_server(@repodir) + + # Create a directory to use as a working directory for the client + @testbase = tempdir + #puts "Using #{@testbase} as client working directory" + end + + def test_local_requests_script + # + # Run a test with a local request and a script + # + testname = 'local request with script' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file/> + <source> + <script>source.script</script> + </source> + </file> + </config> + EOF + end + + # Create the local request file + requestdir = File.join(@testbase, 'requests', @targetfile) + requestfile = File.join(requestdir, 'testrequest') + FileUtils.mkdir_p(requestdir) + File.open(requestfile, 'w') do |file| + file.puts <<-EOF + <request> + <foo/> + </request> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source.script", 'w') do |file| + file.puts <<-EOF + require 'rexml/document' + doc = REXML::Document.new(@local_requests) + if doc.root.elements['/requests/request/foo'] + @contents << '#{sourcecontents}' + end + EOF + end + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase) + + # Verify that the file was created properly + assert_equal(sourcecontents, get_file_contents(@targetfile), testname) + end + + def test_local_requests_template + # + # Run a test with a local request and a template + # + testname = 'local request with template' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file/> + <source> + <template>source.template</template> + </source> + </file> + </config> + EOF + end + + # Create the local request file + requestdir = File.join(@testbase, 'requests', @targetfile) + requestfile = File.join(requestdir, 'testrequest') + FileUtils.mkdir_p(requestdir) + File.open(requestfile, 'w') do |file| + file.puts <<-EOF + <request> + <foo/> + </request> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source.template", 'w') do |file| + file.puts <<-EOF + <% sourcecontents = '#{sourcecontents}' %> + <% require 'rexml/document' %> + <% doc = REXML::Document.new(@local_requests) %> + <% if doc.root.elements['/requests/request/foo'] %> + <%= sourcecontents %> + <% end %> + EOF + end + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase) + + # Verify that the file was created properly + # Our whitespace in the heredoc above gets added to the generated file, so + # pass both strings through strip so we just compare the meat at the + # center. + assert_equal(sourcecontents.strip, get_file_contents(@targetfile).strip, testname) + end + + def teardown + stop_server(@pid) + remove_repository(@repodir) + FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@targetfile) + end +end + Property changes on: trunk/test/local_requests.rb ___________________________________________________________________ Added: svn:executable + * Modified: trunk/test/nodegroups.rb =================================================================== --- trunk/test/nodegroups.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/nodegroups.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -20,7 +20,7 @@ # Generate a directory for our test repository # Specify that the node should be put into 'testgroup' in nodes.xml @repodir = initialize_repository(['testgroup']) - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -187,7 +187,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/options.rb =================================================================== --- trunk/test/options.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/options.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -19,7 +19,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -108,7 +108,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Added: trunk/test/outputcapture.rb =================================================================== --- trunk/test/outputcapture.rb (rev 0) +++ trunk/test/outputcapture.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -0,0 +1,140 @@ +#!/usr/bin/ruby -w + +# +# Test output capturing +# + +require 'test/unit' +require 'etchtest' +require 'tempfile' +require 'fileutils' +require 'timeout' +$: << '../client/trunk' +require 'etch' + +class EtchOutputCaptureTests < Test::Unit::TestCase + include EtchTests + + def setup + # Generate a file to use as our etch target/destination + @targetfile = Tempfile.new('etchtest').path + #puts "Using #{@targetfile} as target file" + + # Generate a directory for our test repository + @repodir = initialize_repository + @port, @pid = start_server(@repodir) + + # Create a directory to use as a working directory for the client + @testbase = tempdir + #puts "Using #{@testbase} as client working directory" + end + + def test_output_capture + # + # Run a test where a post command outputs something, make sure that output + # is reported to the server. + # + testname = 'output capture' + + postoutput = "This is output from\nthe post\ncommand" + postcmd = Tempfile.new('etchoutputtest') + postcmd.puts '#!/bin/sh' + # echo may or may not add a trailing \n depending on which echo we end + # up, so use printf, which doesn't add things. + postcmd.puts "printf \"#{postoutput}\"" + postcmd.close + File.chmod(0755, postcmd.path) + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <source> + <plain>source</plain> + </source> + </file> + <post> + <exec>#{postcmd.path}</exec> + </post> + </config> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + # Run etch + #puts "Running '#{testname}' test" + run_etch(@port, @testbase) + + # Fetch the latest result for this client from the server and verify that + # it contains the output from the post command. + hostname = Facter['fqdn'].value + latest_result_message = '' + Net::HTTP.start('localhost', @port) do |http| + response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") + if !response.kind_of?(Net::HTTPSuccess) + response.error! + end + response_xml = REXML::Document.new(response.body) + latest_result_message = nil + if response_xml.elements['/results/result/message'] + latest_result_message = response_xml.elements['/results/result/message'].text + end + end + assert_match(postoutput, latest_result_message, testname) + end + + def test_output_capture_timeout + # + # Run a test where a post command does not properly daemonize, ensure that + # etch eventually times out. + # + testname = 'output capture timeout' + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <source> + <plain>source</plain> + </source> + </file> + <post> + <exec>ruby -e 'sleep #{Etch::Client::OUTPUT_CAPTURE_TIMEOUT + 30}' &</exec> + </post> + </config> + EOF + end + + sourcecontents = "Test #{testname}\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + begin + Timeout.timeout(Etch::Client::OUTPUT_CAPTURE_TIMEOUT + 15) do + # Run etch + #puts "Running '#{testname}' test" + # + # NOTE: This test is not normally run because the timeout is so long. + # Uncomment this run_etch line to run this test. + # + #run_etch(@port, @testbase) + end + rescue Timeout::Error + flunk('output capturing did not time out as expected') + end + end + + def teardown + stop_server(@pid) + remove_repository(@repodir) + FileUtils.rm_rf(@testbase) + FileUtils.rm_rf(@targetfile) + end +end Property changes on: trunk/test/outputcapture.rb ___________________________________________________________________ Added: svn:executable + * Modified: trunk/test/scripts.rb =================================================================== --- trunk/test/scripts.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/scripts.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -20,7 +20,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -409,7 +409,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/transitions.rb =================================================================== --- trunk/test/transitions.rb 2009-09-11 22:57:27 UTC (rev 89) +++ trunk/test/transitions.rb 2009-09-11 23:06:37 UTC (rev 90) @@ -20,7 +20,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port = start_server(@repodir) + @port, @pid = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -255,7 +255,7 @@ end def teardown - stop_server + stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-01-14 23:54:22
|
Revision: 252 http://etch.svn.sourceforge.net/etch/?rev=252&view=rev Author: jheiss Date: 2011-01-14 23:54:16 +0000 (Fri, 14 Jan 2011) Log Message: ----------- Pull some code for fetching the latest result from the server out into a method so that we can reuse it in other tests. Modified Paths: -------------- trunk/test/etchtest.rb trunk/test/test_outputcapture.rb Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2011-01-13 17:47:20 UTC (rev 251) +++ trunk/test/etchtest.rb 2011-01-14 23:54:16 UTC (rev 252) @@ -192,5 +192,23 @@ end end end + + # Fetch the latest result for this client from the server. Useful for + # verifying that results were logged to the server as expected. + def latest_result_message + hostname = Facter['fqdn'].value + lrm = '' + Net::HTTP.start('localhost', @server[:port]) do |http| + response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") + if !response.kind_of?(Net::HTTPSuccess) + response.error! + end + response_xml = REXML::Document.new(response.body) + if response_xml.elements['/results/result/message'] + lrm = response_xml.elements['/results/result/message'].text + end + end + lrm + end end Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2011-01-13 17:47:20 UTC (rev 251) +++ trunk/test/test_outputcapture.rb 2011-01-14 23:54:16 UTC (rev 252) @@ -66,21 +66,6 @@ run_etch(@server, @testroot, :testname => testname) - # Fetch the latest result for this client from the server and verify that - # it contains the output from the post command. - hostname = Facter['fqdn'].value - latest_result_message = '' - Net::HTTP.start('localhost', @server[:port]) do |http| - response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") - if !response.kind_of?(Net::HTTPSuccess) - response.error! - end - response_xml = REXML::Document.new(response.body) - latest_result_message = nil - if response_xml.elements['/results/result/message'] - latest_result_message = response_xml.elements['/results/result/message'].text - end - end assert_match(postoutput, latest_result_message, testname) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-07-08 23:30:49
|
Revision: 295 http://etch.svn.sourceforge.net/etch/?rev=295&view=rev Author: jheiss Date: 2011-07-08 23:30:43 +0000 (Fri, 08 Jul 2011) Log Message: ----------- Use "$:.unshift" rather than "$: <<" when manipulating the library search path. Otherwise the system paths are searched first. Modified Paths: -------------- trunk/test/test_outputcapture.rb trunk/test/unit/test_xml_abstraction.rb Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2011-07-08 23:18:47 UTC (rev 294) +++ trunk/test/test_outputcapture.rb 2011-07-08 23:30:43 UTC (rev 295) @@ -6,8 +6,8 @@ require "./#{File.dirname(__FILE__)}/etchtest" require 'timeout' -$: << File.join(EtchTests::CLIENTDIR, 'lib') -$: << File.join(EtchTests::SERVERDIR, 'lib') +$:.unshift(File.join(EtchTests::CLIENTDIR, 'lib')) +$:.unshift(File.join(EtchTests::SERVERDIR, 'lib')) require 'etch/client' class EtchOutputCaptureTests < Test::Unit::TestCase Modified: trunk/test/unit/test_xml_abstraction.rb =================================================================== --- trunk/test/unit/test_xml_abstraction.rb 2011-07-08 23:18:47 UTC (rev 294) +++ trunk/test/unit/test_xml_abstraction.rb 2011-07-08 23:30:43 UTC (rev 295) @@ -1,6 +1,6 @@ require 'test/unit' require 'tempfile' -$: << "#{File.dirname(File.expand_path(__FILE__))}/../../server/lib" +$:.unshift("#{File.dirname(File.expand_path(__FILE__))}/../../server/lib") require 'etch' # Test the XML abstraction methods in etch.rb This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-09-14 20:12:25
|
Revision: 91 http://etch.svn.sourceforge.net/etch/?rev=91&view=rev Author: jheiss Date: 2009-09-14 20:12:12 +0000 (Mon, 14 Sep 2009) Log Message: ----------- Update paths to reflect directory structure of SF svn repo. Modified Paths: -------------- trunk/test/etchtest.rb trunk/test/outputcapture.rb Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2009-09-11 23:06:37 UTC (rev 90) +++ trunk/test/etchtest.rb 2009-09-14 20:12:12 UTC (rev 91) @@ -53,7 +53,7 @@ puts "Giving the server some time to start up" sleep(5) else - Dir.chdir('../server/trunk') + Dir.chdir('../server') # FIXME: silence the server (see various failed attempts...) # Causes ruby to fork, so we're left with a useless pid #exec("./script/server -d -p #{port}") @@ -81,7 +81,7 @@ puts "#" sleep 3 end - result = system("ruby ../client/trunk/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} --key=keys/testkey #{extra_args}") + result = system("ruby ../client/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} --key=keys/testkey #{extra_args}") if errors_expected assert(!result) else Modified: trunk/test/outputcapture.rb =================================================================== --- trunk/test/outputcapture.rb 2009-09-11 23:06:37 UTC (rev 90) +++ trunk/test/outputcapture.rb 2009-09-14 20:12:12 UTC (rev 91) @@ -9,7 +9,7 @@ require 'tempfile' require 'fileutils' require 'timeout' -$: << '../client/trunk' +$: << '../client' require 'etch' class EtchOutputCaptureTests < Test::Unit::TestCase This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-08-12 06:24:58
|
Revision: 209 http://etch.svn.sourceforge.net/etch/?rev=209&view=rev Author: jheiss Date: 2010-08-12 06:24:51 +0000 (Thu, 12 Aug 2010) Log Message: ----------- In the test_nested_target method in test_actions.rb there was a section of code which called Tempfile.new('etchtest').path, then immediately deleted the file and replaced it with a directory. The Tempfile object would get garbage collected later and Tempfile would throw an error attempting to delete what was now a directory. Replace that with a call to deleted_tempfile so that Tempfile doesn't try to clean things up later. Replace a bunch of instances of Tempfile.new('etchtest').path with a new method released_tempfile, which explicitly does a close! on the Tempfile and then recreates the file. It may be overly paranoid of me, but it seems that depending on Ruby to more or less immediately garbage collect the Tempfile object is not ideal. Modified Paths: -------------- 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 Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/etchtest.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,12 +11,32 @@ SERVERDIR = "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/server" CLIENTDIR = "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/client" + # Creates a temporary file via Tempfile, capture the filename, tell Tempfile + # to clean up, then return the path. This gives the caller a filename that + # they should be able to write to, that was recently unused and unique, and + # that Tempfile won't try to clean up later. This can be useful when the + # caller might want a path to use for symlinks, directories, etc. where + # Tempfile might choke trying to clean up what it expects to be a plain + # file. + def deleted_tempfile + tmpfile = Tempfile.new('etchtest') + tmppath = tmpfile.path + tmpfile.close! + tmppath + end + # Creates a file via Tempfile but then arranges for Tempfile to release it + # so that the caller doesn't have to worry about Tempfile cleaning it up + # later at an inopportune time. It is up to the caller to ensure the file + # is cleaned up. + def released_tempfile + tmppath = deleted_tempfile + File.open(tmppath, 'w') {|file|} + tmppath + end # Haven't found a Ruby method for creating temporary directories, # so create a temporary file and replace it with a directory. def tempdir - tmpfile = Tempfile.new('etchtest') - tmpdir = tmpfile.path - tmpfile.close! + tmpdir = deleted_tempfile Dir.mkdir(tmpdir) tmpdir end Modified: trunk/test/test_actions.rb =================================================================== --- trunk/test/test_actions.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_actions.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -23,7 +23,7 @@ #puts "Using #{@testbase} as client working directory" # Generate another file to use as our link target - @destfile = Tempfile.new('etchtest').path + @destfile = released_tempfile #puts "Using #{@destfile} as link destination file" end @@ -345,8 +345,7 @@ # that /etc/foo exist first. # - nestedtargetdir = Tempfile.new('etchtest').path - File.delete(nestedtargetdir) + nestedtargetdir = deleted_tempfile nestedtargetfile = File.join(nestedtargetdir, 'etchnestedtest') FileUtils.mkdir_p("#{@repodir}/source/#{nestedtargetfile}") @@ -377,6 +376,8 @@ # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(nestedtargetfile), 'nested target with test') + + FileUtils.rm_rf(nestedtargetdir) end def test_action_with_xml_escape Modified: trunk/test/test_attributes.rb =================================================================== --- trunk/test/test_attributes.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_attributes.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -13,7 +13,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository Modified: trunk/test/test_auth.rb =================================================================== --- trunk/test/test_auth.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_auth.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -14,7 +14,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository Modified: trunk/test/test_commands.rb =================================================================== --- trunk/test/test_commands.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_commands.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as a target in commands - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -249,7 +249,7 @@ # testname = 'command with file dependency' - targetfile2 = Tempfile.new('etchtest').path + targetfile2 = released_tempfile FileUtils.mkdir_p("#{@repodir}/source/#{targetfile2}") File.open("#{@repodir}/source/#{targetfile2}/config.xml", 'w') do |file| file.puts <<-EOF Modified: trunk/test/test_delete.rb =================================================================== --- trunk/test/test_delete.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_delete.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -23,7 +23,7 @@ #puts "Using #{@testbase} as client working directory" # Generate another file to use as our link target - @destfile = Tempfile.new('etchtest').path + @destfile = released_tempfile #puts "Using #{@destfile} as link destination file" end Modified: trunk/test/test_depend.rb =================================================================== --- trunk/test/test_depend.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_depend.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,9 +11,9 @@ def setup # Generate a couple of files to use as our etch target/destinations - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" - @targetfile2 = Tempfile.new('etchtest').path + @targetfile2 = released_tempfile #puts "Using #{@targetfile2} as 2nd target file" # Generate a directory for our test repository Modified: trunk/test/test_file.rb =================================================================== --- trunk/test/test_file.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_file.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository Modified: trunk/test/test_history.rb =================================================================== --- trunk/test/test_history.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_history.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -12,7 +12,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -256,7 +256,7 @@ # # Generate another file to use as our link target - @destfile = Tempfile.new('etchtest').path + @destfile = released_tempfile # Make the original target a link File.delete(@targetfile) Modified: trunk/test/test_link.rb =================================================================== --- trunk/test/test_link.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_link.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -12,7 +12,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Delete the target file so that we're starting with nothing. Creating @@ -28,8 +28,8 @@ #puts "Using #{@testbase} as client working directory" # Generate a couple more files to use as our link targets - @destfile = Tempfile.new('etchtest').path - @destfile2 = Tempfile.new('etchtest').path + @destfile = released_tempfile + @destfile2 = released_tempfile #puts "Using #{@destfile} as link destination file" end Modified: trunk/test/test_local_requests.rb =================================================================== --- trunk/test/test_local_requests.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_local_requests.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository Modified: trunk/test/test_nodegroups.rb =================================================================== --- trunk/test/test_nodegroups.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_nodegroups.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository Modified: trunk/test/test_options.rb =================================================================== --- trunk/test/test_options.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_options.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -11,7 +11,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -136,7 +136,7 @@ </config> EOF end - targetfile2 = Tempfile.new('etchtest').path + targetfile2 = released_tempfile FileUtils.mkdir_p("#{@repodir}/source/#{targetfile2}") File.open("#{@repodir}/source/#{targetfile2}/config.xml", 'w') do |file| file.puts <<-EOF @@ -150,7 +150,7 @@ </config> EOF end - targetfile3 = Tempfile.new('etchtest').path + targetfile3 = released_tempfile FileUtils.mkdir_p("#{@repodir}/source/#{targetfile3}") File.open("#{@repodir}/source/#{targetfile3}/config.xml", 'w') do |file| file.puts <<-EOF @@ -172,7 +172,7 @@ end end - cmdtargetfile1 = Tempfile.new('etchtest').path + cmdtargetfile1 = released_tempfile FileUtils.mkdir_p("#{@repodir}/commands/etchtest1") File.open("#{@repodir}/commands/etchtest1/commands.xml", 'w') do |file| file.puts <<-EOF @@ -188,7 +188,7 @@ </commands> EOF end - cmdtargetfile2 = Tempfile.new('etchtest').path + cmdtargetfile2 = released_tempfile FileUtils.mkdir_p("#{@repodir}/commands/etchtest2") File.open("#{@repodir}/commands/etchtest2/commands.xml", 'w') do |file| file.puts <<-EOF @@ -204,7 +204,7 @@ </commands> EOF end - cmdtargetfile3 = Tempfile.new('etchtest').path + cmdtargetfile3 = released_tempfile FileUtils.mkdir_p("#{@repodir}/commands/etchtest3") File.open("#{@repodir}/commands/etchtest3/commands.xml", 'w') do |file| file.puts <<-EOF @@ -266,8 +266,8 @@ # testname = 'command line file requests with depends' - targetfile2 = Tempfile.new('etchtest').path - targetfile3 = Tempfile.new('etchtest').path + targetfile2 = released_tempfile + targetfile3 = released_tempfile FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| file.puts <<-EOF @@ -333,8 +333,8 @@ # testname = 'mixed command line requests with depends' - targetfile2 = Tempfile.new('etchtest').path - targetfile3 = Tempfile.new('etchtest').path + targetfile2 = released_tempfile + targetfile3 = released_tempfile FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| file.puts <<-EOF @@ -384,7 +384,7 @@ end end - cmdtargetfile1 = Tempfile.new('etchtest').path + cmdtargetfile1 = released_tempfile FileUtils.mkdir_p("#{@repodir}/commands/etchtest1") File.open("#{@repodir}/commands/etchtest1/commands.xml", 'w') do |file| file.puts <<-EOF Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_outputcapture.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -15,7 +15,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository Modified: trunk/test/test_scripts.rb =================================================================== --- trunk/test/test_scripts.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_scripts.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -12,7 +12,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -233,7 +233,7 @@ end # Generate a file to use as our link target - @destfile = Tempfile.new('etchtest').path + @destfile = released_tempfile File.open("#{@repodir}/source/#{@targetfile}/link.script", 'w') do |file| file.puts("@contents << '#{@destfile}'") end Modified: trunk/test/test_transitions.rb =================================================================== --- trunk/test/test_transitions.rb 2010-06-28 22:02:45 UTC (rev 208) +++ trunk/test/test_transitions.rb 2010-08-12 06:24:51 UTC (rev 209) @@ -12,7 +12,7 @@ def setup # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path + @targetfile = released_tempfile #puts "Using #{@targetfile} as target file" # Generate a directory for our test repository @@ -24,7 +24,7 @@ #puts "Using #{@testbase} as client working directory" # Generate another file to use as our link target - @destfile = Tempfile.new('etchtest').path + @destfile = released_tempfile end # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-01-07 03:32:27
|
Revision: 249 http://etch.svn.sourceforge.net/etch/?rev=249&view=rev Author: jheiss Date: 2011-01-07 03:32:19 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Add :testname option to all remaining run_etch calls. Modified Paths: -------------- trunk/test/test_actions.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 Modified: trunk/test/test_actions.rb =================================================================== --- trunk/test/test_actions.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_actions.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -33,6 +33,7 @@ # Basic tests to ensure that actions are performed under normal # circumstances # + testname = 'basic action test' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -74,9 +75,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running initial action test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the actions were executed # The setup actions will get run several times as we loop @@ -100,7 +99,7 @@ # Run etch again and make sure that the exec_once command wasn't run # again - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => 'action test, exec_once') assert_equal("exec_once\n", get_file_contents("#{@repodir}/exec_once"), 'exec_once_2nd_check') end @@ -109,6 +108,7 @@ # # Test a failed setup command to ensure etch aborts # + testname = 'failed setup' # Put some text into the original file so that we can make sure it # is not touched. @@ -140,9 +140,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running initial action test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), 'failed setup') @@ -152,6 +150,7 @@ # # Test a failed pre command to ensure etch aborts # + testname = 'failed pre' # Put some text into the original file so that we can make sure it # is not touched. @@ -183,9 +182,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running failed pre test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), 'failed pre') @@ -196,6 +193,7 @@ # Run a test where the test action fails, ensure that the original # target file is restored and any post actions re-run afterwards # + testname = 'failed test' # Put some text into the original file so that we can make sure it # is restored. @@ -232,9 +230,7 @@ file.write("Testing a failed test\n") end - # Run etch - #puts "Running failed test test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the original was restored, and that post was run twice assert_equal(origcontents, get_file_contents(@targetfile), 'failed test target') @@ -246,6 +242,7 @@ # Run a test where the test_before_post action fails, ensure that # post is not run # + testname = 'failed test_before_post' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -268,9 +265,7 @@ EOF end - # Run etch - #puts "Running failed test_before_post test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that post was not run assert(!File.exist?("#{@repodir}/post"), 'failed test_before_post post') @@ -279,14 +274,13 @@ # Run a test where the test action fails, and the original target file # is a symlink. Ensure that the symlink is restored. # + testname = 'failed test_before_post symlink' # Prepare the target File.delete(@targetfile) if File.exist?(@targetfile) File.symlink(@destfile, @targetfile) - # Run etch - #puts "Running failed test symlink test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the original symlink was restored assert_equal(@destfile, File.readlink(@targetfile), 'failed test symlink') @@ -295,15 +289,14 @@ # Run a test where the test action fails, and the original target file # is a directory. Ensure that the directory is restored. # + testname = 'failed test_before_post directory' # Prepare the target File.delete(@targetfile) if File.exist?(@targetfile) Dir.mkdir(@targetfile) File.open("#{@targetfile}/testfile", 'w') { |file| } - # Run etch - #puts "Running failed test directory test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the original directory was restored assert(File.directory?(@targetfile), 'failed test directory') @@ -314,6 +307,7 @@ # target file. Ensure that the end result is that there is no file left # behind. # + testname = 'failed test_before_post no original' # We can reuse the config.xml from the previous test @@ -323,9 +317,7 @@ end File.delete("#{@repodir}/post") if File.exist?("#{@repodir}/post") - # Run etch - #puts "Running failed test no original file test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the lack of an original file was restored assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), 'failed test no original file') @@ -344,6 +336,7 @@ # back if the test fails) is made as /etc/foo/bar.XXXXX, which requires # that /etc/foo exist first. # + testname = 'test action with nested target' nestedtargetdir = deleted_tempfile nestedtargetfile = File.join(nestedtargetdir, 'etchnestedtest') @@ -370,9 +363,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running nested target with test test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(nestedtargetfile), 'nested target with test') @@ -390,6 +381,7 @@ # So if the user wants to use something like && in an action they must # escape the & with & # + testname = 'XML escape' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -413,9 +405,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running XML escape test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the action was executed assert_equal("post\n", get_file_contents("#{@repodir}/post_with_escape"), 'post with escape') @@ -425,6 +415,7 @@ # # Test an action involving passing an environment variable # + testname = 'action with environment variable' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -456,9 +447,7 @@ end File.chmod(0755, "#{@repodir}/post_with_env") - # Run etch - #puts "Running environment variable test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the action was executed assert_equal("testvalue\n", get_file_contents("#{@repodir}/post_with_env_output"), 'post with environment variable') Modified: trunk/test/test_auth.rb =================================================================== --- trunk/test/test_auth.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_auth.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -89,9 +89,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -120,9 +118,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -159,9 +155,7 @@ file.write(origcontents) end - # Run etch with the wrong key to force a bad signature - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true, :key => "--key=#{File.join(File.dirname(__FILE__), 'keys', 'testkey2')}") + run_etch(@server, @testroot, :errors_expected => true, :key => "--key=#{File.join(File.dirname(__FILE__), 'keys', 'testkey2')}", :testname => testname) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -204,9 +198,7 @@ file.write(origcontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -219,7 +211,7 @@ sleep 3 repodir2 = initialize_repository server2 = start_server(repodir2) - run_etch(server2, @testroot) + run_etch(server2, @testroot, :testname => 'adding client to database') stop_server(server2) remove_repository(repodir2) @@ -247,9 +239,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) Modified: trunk/test/test_commands.rb =================================================================== --- trunk/test/test_commands.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_commands.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -45,9 +45,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(testname, get_file_contents(@targetfile), testname) @@ -75,9 +73,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) end def test_commands_guard_succeeds @@ -104,9 +100,7 @@ File.open(@targetfile, 'w') { |file| file.print(testname) } - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was not touched assert_equal(testname, get_file_contents(@targetfile), testname) @@ -142,9 +136,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that both steps ran and in the proper order assert_equal("firststep\nsecondstep\n", get_file_contents(@targetfile), testname) @@ -189,7 +181,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that both commands ran, ordering doesn't matter assert_equal(['firstcmd', 'secondcmd'], get_file_contents(@targetfile).split("\n").sort, testname) @@ -233,9 +225,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that both commands ran and in the proper order assert_equal("firstcmd\nsecondcmd\n", get_file_contents(@targetfile), testname) @@ -287,9 +277,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the command-generated file and the regular file were created # properly @@ -332,9 +320,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that only the desired step executed assert_equal("notingroup\n", get_file_contents(@targetfile), testname) @@ -357,9 +343,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) end def teardown Modified: trunk/test/test_delete.rb =================================================================== --- trunk/test/test_delete.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_delete.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -45,9 +45,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -71,9 +69,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the link was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -99,9 +95,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the directory was not deleted assert(File.directory?(@targetfile), testname) @@ -128,9 +122,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the directory was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -151,9 +143,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # 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 @@ -164,6 +154,7 @@ # # Test duplicate script instructions # + testname = 'duplicate script' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -185,15 +176,14 @@ file.puts("@contents << 'true'") end - # Run etch - #puts "Running duplicate script instructions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert(!File.exist?(@targetfile), 'duplicate script instructions') # # Test contradictory script instructions # + testname = 'contradictory script' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -218,9 +208,7 @@ file.puts("@contents << 'true'") end - # Run etch - #puts "Running contradictory script instructions test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file wasn't removed assert(File.exist?(@targetfile), 'contradictory script instructions') Modified: trunk/test/test_depend.rb =================================================================== --- trunk/test/test_depend.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_depend.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -29,6 +29,7 @@ # # Run a basic dependency test # + testname = 'initial dependency test' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -74,9 +75,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running initial dependency test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the files were created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'dependency file 1') @@ -136,9 +135,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :extra_args => @targetfile) + run_etch(@server, @testroot, :extra_args => @targetfile, :testname => testname) # Verify that the files were created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'single request dependency file 1') @@ -200,9 +197,7 @@ end end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true, :extra_args => @targetfile) + run_etch(@server, @testroot, :errors_expected => true, :extra_args => @targetfile, :testname => testname) # Verify that the files weren't modified assert_equal(origcontents, get_file_contents(@targetfile), 'circular dependency file 1') @@ -254,9 +249,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the regular file and the command-generated file were created # properly Modified: trunk/test/test_file.rb =================================================================== --- trunk/test/test_file.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_file.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -28,6 +28,7 @@ # # Run a test of basic file creation # + testname = 'initial file test' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -47,9 +48,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running initial file test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -64,6 +63,7 @@ # # Test with a template # + testname = 'file with template' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -84,9 +84,7 @@ file.write(templatecontents) end - # Run etch - #puts "Running initial file test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -101,6 +99,7 @@ # # Test using a different warning file # + testname = 'different warning file' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -125,9 +124,7 @@ file.write(warningcontents) end - # Run etch - #puts "Running different warning file test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -142,6 +139,7 @@ # # Test using no warning file # + testname = 'no warning file' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -162,9 +160,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running no warning file test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'no warning file') @@ -172,6 +168,7 @@ # # Test using a different line comment string # + testname = 'different line comment string' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -192,9 +189,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running different line comment test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -209,6 +204,7 @@ # # Test using comment open/close # + testname = 'comment open/close' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -231,9 +227,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running comment open/close test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = "/*\n" @@ -249,6 +243,7 @@ # # Test warning on second line # + testname = 'warning on second line' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -271,9 +266,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running warning on second line test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = sourcecontents_firstline @@ -289,6 +282,7 @@ # # Test no space around warning # + testname = 'no space around warning' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -309,9 +303,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running no space around warning test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -325,6 +317,7 @@ # # Test ownership and permissions # + testname = 'ownership and permissions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -342,9 +335,7 @@ EOF end - # Run etch - #puts "Running file ownership and permissions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file ownership got set correctly # Most systems don't support give-away chown, so this test won't work @@ -362,6 +353,7 @@ # # Test ownership w/ bogus owner/group names # + testname = 'file ownership w/ bogus owner/group names' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -378,9 +370,7 @@ EOF end - # Run etch - #puts "Running file ownership w/ bogus owner/group names" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the ownership defaulted to UID/GID 0 # Most systems don't support give-away chown, so this test won't work @@ -395,6 +385,7 @@ # # Run a test of always_manage_metadata # + testname = 'always_manage_metadata' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -414,9 +405,7 @@ file.write(testcontents) end - # Run etch - #puts "Running always_manage_metadata test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file permissions got set correctly perms = File.stat(@targetfile).mode & 07777 @@ -428,6 +417,7 @@ # # Test duplicate plain instructions # + testname = 'duplicate plain instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -454,9 +444,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running duplicate plain instructions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate plain instructions') @@ -464,6 +452,7 @@ # # Test contradictory plain instructions # + testname = 'contradictory plain instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -493,9 +482,7 @@ file.write(source2contents) end - # Run etch - #puts "Running contradictory plain instructions test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory plain instructions') @@ -503,6 +490,7 @@ # # Test duplicate template instructions # + testname = 'duplicate template instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -529,9 +517,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running duplicate template instructions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate template instructions') @@ -539,6 +525,7 @@ # # Test contradictory template instructions # + testname = 'contradictory template instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -568,9 +555,7 @@ file.write(source2contents) end - # Run etch - #puts "Running contradictory template instructions test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory template instructions') @@ -578,6 +563,7 @@ # # Test duplicate script instructions # + testname = 'duplicate script instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -604,9 +590,7 @@ file.puts("@contents << '#{sourcecontents}'") end - # Run etch - #puts "Running duplicate script instructions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate script instructions') @@ -614,6 +598,7 @@ # # Test contradictory script instructions # + testname = 'contradictory script instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -643,9 +628,7 @@ file.write(source2contents) end - # Run etch - #puts "Running contradictory script instructions test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory script instructions') @@ -682,9 +665,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(specialtargetfile), testname) Modified: trunk/test/test_history.rb =================================================================== --- trunk/test/test_history.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_history.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -31,6 +31,7 @@ # # Ensure original file is backed up and history log started # + testname = 'initial history test' # Put some text into the original file so that we can make sure it was # properly backed up. @@ -58,9 +59,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running initial history test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(origcontents, get_file_contents(@origfile), 'original backup of file') assert_equal(origcontents, get_file_contents(File.join(@historydir, '0000')), '0000 history file') @@ -69,15 +68,14 @@ # # Ensure history log is updated and original file does not change # + testname = 'history update' updatedsourcecontents = "This is a second test\n" File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| file.write(updatedsourcecontents) end - # Run etch - #puts "Running update test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) 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') @@ -87,6 +85,7 @@ # # Test revert feature # + testname = 'revert' # Intentionally mix revert with other instructions to make sure the file # is reverted and nothing else happens. @@ -105,9 +104,7 @@ EOF end - # Run etch - #puts "Running revert test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(origcontents, get_file_contents(@targetfile), 'original contents reverted') assert(!File.exist?(@origfile), 'reverted original file') @@ -120,15 +117,14 @@ # Update the contents of a reverted file and make sure etch doesn't # overwrite them, as it should no longer be managing the file. # + testname = 'no update to reverted file' updatedorigcontents = "This is new original text\n" File.open(@targetfile, 'w') do |file| file.write(updatedorigcontents) end - # Run etch - #puts "Running revert test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(updatedorigcontents, get_file_contents(@targetfile), 'Updated original contents unchanged') assert(!File.exist?(@origfile), 'reverted original file') @@ -149,6 +145,7 @@ # tries before we achieved convergence and the client sent the correct # original contents. # + testname = 'history setup' origcontents = "This is the original text" @@ -175,9 +172,7 @@ file.puts("@contents << IO.read(@original_file)") end - # Run etch - #puts "Running history setup test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) 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') @@ -215,9 +210,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => 'delayed history setup, first run') origcontents = "This is the original text for #{testname}" @@ -243,9 +236,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(origcontents + "\n", get_file_contents(@origfile), testname) end @@ -254,6 +245,7 @@ # # Ensure original file is backed up when it is a link # + testname = 'history link' # Generate another file to use as our link target @destfile = released_tempfile @@ -281,9 +273,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running history link test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) 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') @@ -293,6 +283,7 @@ # # Ensure original file is backed up when it is a directory # + testname = 'history directory' # Make the original target a directory File.delete(@targetfile) @@ -326,9 +317,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running history directory test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert(File.directory?(@origfile), 'original backup of directory') # Verify that etch backed up the original directory properly @@ -346,6 +335,7 @@ # being converted to something else, as the original backup is handled # differently in that case # + testname = 'history directory' origtarfile = File.join(@testroot, 'var', 'etch', 'orig', "#{@targetfile}.TAR") @@ -374,9 +364,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running history directory contents test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # In this case, because we converted a directory to something else the # original will be a tarball of the directory @@ -390,6 +378,7 @@ # # Test the conversion of old RCS history logs to the new format # + testname = 'history conversion' # Mock up an original file and RCS history log mockorigcontents = "This is the original text\n" @@ -443,9 +432,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running history conversion test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) 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') Modified: trunk/test/test_link.rb =================================================================== --- trunk/test/test_link.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_link.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -37,6 +37,7 @@ # # Run a test of creating a link # + testname = 'initial link' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -49,15 +50,14 @@ EOF end - # Run etch - #puts "Running initial link test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(@destfile, File.readlink(@targetfile), 'link create') # # Run a test of updating the link to point to a different destination # + testname = 'link update' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -70,9 +70,7 @@ EOF end - # Run etch - #puts "Running link update test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(@destfile2, File.readlink(@targetfile), 'link update') @@ -83,6 +81,7 @@ # we write out the updated link, in case it has problems with links to # files that don't exist (we had such a bug once). # + testname = 'link update from non-existent file' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -99,9 +98,7 @@ # previous test) File.delete(@destfile2) - # Run etch - #puts "Running link update from non-existent file test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(@destfile, File.readlink(@targetfile), 'link update from non-existent file') end @@ -111,6 +108,7 @@ # Run a test where we ask etch to create a link to a non-existent # destination. It should fail by design. # + testname = 'link to non-existent destination' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -125,9 +123,7 @@ File.delete(@destfile) - # Run etch - #puts "Running link to non-existent destination test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the link was not created assert(!File.symlink?(@targetfile), 'link to non-existent destination') @@ -136,6 +132,7 @@ # Then run the same test (link to non-existent destination) with the # override flag turned on to make sure etch does create the link. # + testname = 'link to non-existent destination with override' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -149,9 +146,7 @@ EOF end - # Run etch - #puts "Running link to non-existent destination with override test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the link was updated properly assert_equal(@destfile, File.readlink(@targetfile), 'link to non-existent destination with override') @@ -161,6 +156,7 @@ # # Test creating a relative link # + testname = 'relative link' # We'll use @destfile as the target, but need a relative path to it. # Conveniently Pathname has a function to figure that out for us. @@ -178,9 +174,7 @@ EOF end - # Run etch - #puts "Running relative link test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the link was updated properly assert_equal(reldestfile, File.readlink(@targetfile), 'relative link') @@ -190,6 +184,7 @@ # # Test ownership and permissions # + testname = 'link ownership and permissions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -205,9 +200,7 @@ EOF end - # Run etch - #puts "Running link ownership and permissions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the link ownership got set correctly # Most systems don't support give-away chown, so this test won't work @@ -227,6 +220,7 @@ # # Test duplicate dest instructions # + testname = 'duplicate dest instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -240,9 +234,7 @@ EOF end - # Run etch - #puts "Running duplicate dest instructions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(@destfile, File.readlink(@targetfile), 'duplicate dest instructions') end @@ -251,6 +243,7 @@ # # Test contradictory dest instructions # + testname = 'contradictory dest instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -264,9 +257,7 @@ EOF end - # Run etch - #puts "Running contradictory dest instructions test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the link wasn't created assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory dest instructions') @@ -276,6 +267,7 @@ # # Test duplicate script instructions # + testname = 'duplicate script instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -293,9 +285,7 @@ file.puts("@contents << '#{@destfile}'") end - # Run etch - #puts "Running duplicate script instructions test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(@destfile, File.readlink(@targetfile), 'duplicate script instructions') end @@ -304,6 +294,7 @@ # # Test contradictory script instructions # + testname = 'contradictory script instructions' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -324,9 +315,7 @@ file.puts("@contents << '#{@destfile2}'") end - # Run etch - #puts "Running contradictory script instructions test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the link wasn't created assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory script instructions') Modified: trunk/test/test_local_requests.rb =================================================================== --- trunk/test/test_local_requests.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_local_requests.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -66,9 +66,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -118,9 +116,7 @@ EOF end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly # Our whitespace in the heredoc above gets added to the generated file, so Modified: trunk/test/test_nodegroups.rb =================================================================== --- trunk/test/test_nodegroups.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_nodegroups.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -49,9 +49,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -90,9 +88,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -131,9 +127,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -175,9 +169,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that the file wasn't modified assert_equal(oldsourcecontents, get_file_contents(@targetfile), testname) Modified: trunk/test/test_options.rb =================================================================== --- trunk/test/test_options.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_options.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -29,6 +29,7 @@ # Test killswitch (not really a command-line option, but seems to # fit best in this file) # + testname = 'killswitch' # Put some text into the original file so that we can make sure it is # not touched. @@ -60,9 +61,7 @@ file.write('killswitch test') end - # Run etch - #puts "Running killswitch test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) assert_equal(origcontents, get_file_contents(@targetfile), 'killswitch') end @@ -71,6 +70,7 @@ # # Test --dry-run # + testname = '--dry-run' # Put some text into the original file so that we can make sure it is # not touched. @@ -98,9 +98,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running --dry-run test" - run_etch(@server, @testroot, :extra_args => '--dry-run') + run_etch(@server, @testroot, :extra_args => '--dry-run', :testname => testname) assert_equal(origcontents, get_file_contents(@targetfile), '--dry-run') end @@ -231,9 +229,7 @@ end end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :extra_args => "#{@targetfile} #{targetfile2} etchtest1 etchtest2") + run_etch(@server, @testroot, :extra_args => "#{@targetfile} #{targetfile2} etchtest1 etchtest2", :testname => testname) # Verify that only the requested files were created assert_equal(sourcecontents, get_file_contents(@targetfile), testname + ' file 1') @@ -318,9 +314,7 @@ end end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :extra_args => "#{@targetfile} #{targetfile2}") + run_etch(@server, @testroot, :extra_args => "#{@targetfile} #{targetfile2}", :testname => testname) # Verify that all were created assert_equal(sourcecontents, get_file_contents(@targetfile), testname + ' filesonly file 1') @@ -412,9 +406,7 @@ end end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot, :extra_args => "etchtest1 #{targetfile2}") + run_etch(@server, @testroot, :extra_args => "etchtest1 #{targetfile2}", :testname => testname) # Verify that all were created assert_equal(origcontents + testname, get_file_contents(cmdtargetfile1), testname + ' cmdandfile cmd 1') @@ -473,7 +465,7 @@ sleep(5) # Test that we don't follow redirects by default - run_etch(@server, @testroot, :errors_expected => true, :extra_args => '', :port => redirect_port) + run_etch(@server, @testroot, :errors_expected => true, :extra_args => '', :port => redirect_port, :testname => testname) assert_equal(origcontents, get_file_contents(@targetfile), testname) # Check that we do follow redirects with the appropriate option @@ -497,7 +489,7 @@ response.set_redirect( WEBrick::HTTPStatus::Found, "http://localhost:#{redirect_port}/") end - run_etch(@server, @testroot, :errors_expected => true, :port => redirect_port) + run_etch(@server, @testroot, :errors_expected => true, :port => redirect_port, :testname => testname) server.shutdown t.kill Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_outputcapture.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -64,9 +64,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Fetch the latest result for this client from the server and verify that # it contains the output from the post command. @@ -116,13 +114,10 @@ begin Timeout.timeout(Etch::Client::OUTPUT_CAPTURE_TIMEOUT + 15) do - # Run etch - #puts "Running '#{testname}' test" - # # NOTE: This test is not normally run because the timeout is so long. # Uncomment this run_etch line to run this test. # - #run_etch(@server, @testroot) + #run_etch(@server, @testroot, :testname => testname) end rescue Timeout::Error flunk('output capturing did not time out as expected') Modified: trunk/test/test_scripts.rb =================================================================== --- trunk/test/test_scripts.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_scripts.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -36,6 +36,7 @@ # # Start with a test of a script with a syntax error # + testname = 'script with syntax error' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -58,9 +59,7 @@ before_size = File.stat(@targetfile).size before_ctime = File.stat(@targetfile).ctime - # Run etch - #puts "Running script with syntax error test" - run_etch(@server, @testroot, :errors_expected => true) + run_etch(@server, @testroot, :errors_expected => true, :testname => testname) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'script with syntax error size comparison') @@ -69,6 +68,7 @@ # # Run a test where the script doesn't output anything # + testname = 'script with no output' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -91,9 +91,7 @@ before_size = File.stat(@targetfile).size before_ctime = File.stat(@targetfile).ctime - # Run etch - #puts "Running script with no output" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'script with no output size comparison') @@ -102,6 +100,7 @@ # # Run a test using a script to generate the contents of a file # + testname = 'script to generate the contents of a file' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -121,9 +120,7 @@ file.puts("@contents << '#{sourcecontents}'") end - # Run etch - #puts "Running file script test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -138,6 +135,7 @@ # # Run a test where the script reads the contents from another file # + testname = 'script reads the contents from another file' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -162,9 +160,7 @@ file.puts("@contents << IO.read('source')") end - # Run etch - #puts "Running file source script test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -179,6 +175,7 @@ # # Run a test where the script appends to the original file # + testname = 'script appends to the original file' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -202,9 +199,7 @@ file.puts("@contents << IO.read('source')") end - # Run etch - #puts "Running file source script test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly correctcontents = '' @@ -220,6 +215,7 @@ # # Run a test of using a script to generate a link # + testname = 'script to generate a link' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -238,9 +234,7 @@ file.puts("@contents << '#{@destfile}'") end - # Run etch - #puts "Running link script test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the link was created properly assert_equal(@destfile, File.readlink(@targetfile), 'link script') @@ -249,6 +243,7 @@ # Run a test where the script doesn't output anything in link # context # + testname = 'link script with no output' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -269,9 +264,7 @@ before_readlink = File.readlink(@targetfile) before_ctime = File.stat(@targetfile).ctime - # Run etch - #puts "Running link script with no output" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that etch didn't do anything to the file assert_equal(before_readlink, File.readlink(@targetfile), 'link script with no output readlink comparison') @@ -280,6 +273,7 @@ # # Run a test of using a script to generate a directory # + testname = 'script to generate a directory' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -296,9 +290,7 @@ file.puts("@contents << 'true'") end - # Run etch - #puts "Running directory script test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the directory was created assert(File.directory?(@targetfile), 'directory script') @@ -307,6 +299,7 @@ # Run a test where the script doesn't output anything in directory # context # + testname = 'directory script with no output' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -331,9 +324,7 @@ before_size = File.stat(@targetfile).size before_ctime = File.stat(@targetfile).ctime - # Run etch - #puts "Running directory script with no output" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'directory script with no output size comparison') @@ -342,6 +333,7 @@ # # Run a test of using a script to delete # + testname = 'script to delete' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -359,9 +351,7 @@ file.puts("@contents << 'true'") end - # Run etch - #puts "Running delete script test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was removed assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), 'delete script') @@ -370,6 +360,7 @@ # Run a test where the script doesn't output anything in delete # context # + testname = 'delete script with no output' # Recreate the target file origcontents = "This is the original text\n" @@ -396,9 +387,7 @@ before_size = File.stat(@targetfile).size before_ctime = File.stat(@targetfile).ctime - # Run etch - #puts "Running delete script with no output" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'delete script with no output size comparison') Modified: trunk/test/test_transitions.rb =================================================================== --- trunk/test/test_transitions.rb 2010-12-24 00:50:24 UTC (rev 248) +++ trunk/test/test_transitions.rb 2011-01-07 03:32:19 UTC (rev 249) @@ -44,6 +44,7 @@ # # File to link transition # + testname = 'file to link transition' FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| @@ -56,15 +57,14 @@ EOF end - # Run etch - #puts "Running file to link test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert_equal(@destfile, File.readlink(@targetfile), 'file to link') # # File to directory transition # + testname = 'file to directory transition' # Reset target FileUtils.rm_rf(@targetfile) @@ -81,9 +81,7 @@ EOF end - # Run etch - #puts "Running file to directory test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) assert(File.directory?(@targetfile), 'file to directory') end @@ -92,6 +90,7 @@ # # Link to file transition # + testname = 'link to file transition' # Reset target FileUtils.rm_rf(@targetfile) @@ -116,9 +115,7 @@ file.write(sourcecontents) end - # Run etch - #puts "Running link to file test" - run_etch(@server, @testroot) + run_etch(@server, @testroot, :testname => testname) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'link to file') @@ -128,6 +125,7 @@ # identical contents to the file contents we should be writing out # (to test that the comparison method doesn't follow symlinks) # + 'link w/ same contents to file transition' # Reset target FileUtils.rm_rf(@targetfile) @@ -... [truncated message content] |
From: <jh...@us...> - 2011-04-12 01:21:23
|
Revision: 266 http://etch.svn.sourceforge.net/etch/?rev=266&view=rev Author: jheiss Date: 2011-04-12 01:21:17 +0000 (Tue, 12 Apr 2011) Log Message: ----------- Add unit tests of XML abstraction functions Added Paths: ----------- trunk/test/unit/ trunk/test/unit/test_xml_abstraction.rb Added: trunk/test/unit/test_xml_abstraction.rb =================================================================== --- trunk/test/unit/test_xml_abstraction.rb (rev 0) +++ trunk/test/unit/test_xml_abstraction.rb 2011-04-12 01:21:17 UTC (rev 266) @@ -0,0 +1,465 @@ +require 'test/unit' +require 'tempfile' +$: << "#{File.dirname(File.expand_path(__FILE__))}/../../server/lib" +require 'etch' + +# Test the XML abstraction methods in etch.rb + +class TestXMLAbstraction < Test::Unit::TestCase + def test_xmlnewdoc + puts "Etch is using XML library: " + Etch.xmllib.to_s + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Document, Etch.xmlnewdoc) + when :nokogiri + assert_kind_of(Nokogiri::XML::Document, Etch.xmlnewdoc) + when :rexml + assert_kind_of(REXML::Document, Etch.xmlnewdoc) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlroot_and_xmlsetroot + doc = Etch.xmlnewdoc + Etch.xmlsetroot(doc, Etch.xmlnewelem('root', doc)) + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, Etch.xmlroot(doc)) + assert_equal('root', Etch.xmlroot(doc).name) + when :nokogiri + assert_kind_of(Nokogiri::XML::Node, Etch.xmlroot(doc)) + assert_equal('root', Etch.xmlroot(doc).name) + when :rexml + assert_kind_of(REXML::Node, Etch.xmlroot(doc)) + assert_equal('root', Etch.xmlroot(doc).name) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlload + goodfile = Tempfile.new('etch_xml_abstraction') + goodfile.puts '<root><element/></root>' + goodfile.close + doc = Etch.xmlload(goodfile.path) + badfile = Tempfile.new('etch_xml_abstraction') + badfile.puts '<badroot>' + badfile.close + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, Etch.xmlroot(doc)) + assert_equal('root', Etch.xmlroot(doc).name) + assert_raises(LibXML::XML::Error) { Etch.xmlload(badfile.path) } + when :nokogiri + assert_kind_of(Nokogiri::XML::Node, Etch.xmlroot(doc)) + assert_equal('root', Etch.xmlroot(doc).name) + assert_raises(Nokogiri::XML::SyntaxError) { Etch.xmlload(badfile.path) } + when :rexml + assert_kind_of(REXML::Node, Etch.xmlroot(doc)) + assert_equal('root', Etch.xmlroot(doc).name) + assert_raises(REXML::ParseException) { Etch.xmlload(badfile.path) } + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlloaddtd + dtdfile = Tempfile.new('etch_xml_abstraction') + dtdfile.puts '<!ELEMENT root (element)>' + dtdfile.puts '<!ELEMENT element EMPTY>' + dtdfile.close + dtd = Etch.xmlloaddtd(dtdfile.path) + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Dtd, dtd) + when :nokogiri + assert_kind_of(Nokogiri::XML::DTD, dtd) + when :rexml + assert_nil(dtd) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlvalidate + goodfile = Tempfile.new('etch_xml_abstraction') + goodfile.puts '<root><element/></root>' + goodfile.close + gooddoc = Etch.xmlload(goodfile.path) + + badfile = Tempfile.new('etch_xml_abstraction') + badfile.puts '<root/>' + badfile.close + baddoc = Etch.xmlload(badfile.path) + + dtdfile = Tempfile.new('etch_xml_abstraction') + dtdfile.puts '<!ELEMENT root (element)>' + dtdfile.puts '<!ELEMENT element EMPTY>' + dtdfile.close + dtd = Etch.xmlloaddtd(dtdfile.path) + + case Etch.xmllib + when :libxml + assert(Etch.xmlvalidate(gooddoc, dtd)) + assert_raises(LibXML::XML::Error) { Etch.xmlvalidate(baddoc, dtd) } + when :nokogiri + assert(Etch.xmlvalidate(gooddoc, dtd)) + assert_raises(RuntimeError) { Etch.xmlvalidate(baddoc, dtd) } + when :rexml + # REXML doesn't support validation, xmlvalidate will always return true + assert(Etch.xmlvalidate(gooddoc, dtd)) + assert(Etch.xmlvalidate(baddoc, dtd)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlnewelem + doc = Etch.xmlnewdoc + elem = Etch.xmlnewelem('element', doc) + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, elem) + assert_equal('element', elem.name) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, elem) + assert_equal('element', elem.name) + when :rexml + assert_kind_of(REXML::Element, elem) + assert_equal('element', elem.name) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmleach + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element/><element/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + counter = 0 + Etch.xmleach(doc, '/root/element') do |elem| + counter += 1 + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, elem) + assert_equal('element', elem.name) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, elem) + assert_equal('element', elem.name) + when :rexml + assert_kind_of(REXML::Element, elem) + assert_equal('element', elem.name) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + assert_equal(2, counter) + end + def test_xmleachall + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element><child/><otherchild/></element><element/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + counter = 0 + Etch.xmleachall(doc) do |elem| + counter += 1 + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, elem) + assert(['element', 'other'].include?(elem.name)) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, elem) + assert(['element', 'other'].include?(elem.name)) + when :rexml + assert_kind_of(REXML::Element, elem) + assert(['element', 'other'].include?(elem.name)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + assert_equal(3, counter) + + counter = 0 + Etch.xmleachall(Etch.xmlfindfirst(doc, '/root/element')) do |elem| + counter += 1 + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, elem) + assert(['child', 'otherchild'].include?(elem.name)) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, elem) + assert(['child', 'otherchild'].include?(elem.name)) + when :rexml + assert_kind_of(REXML::Element, elem) + assert(['child', 'otherchild'].include?(elem.name)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + assert_equal(2, counter) + + end + def test_xmleachattrall + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root attrone="foo" attrtwo="bar"/>' + file.close + doc = Etch.xmlload(file.path) + + counter = 0 + Etch.xmleachattrall(doc.root) do |attr| + counter += 1 + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Attr, attr) + assert(['attrone', 'attrtwo'].include?(attr.name)) + when :nokogiri + assert_kind_of(Nokogiri::XML::Attr, attr) + assert(['attrone', 'attrtwo'].include?(attr.name)) + when :rexml + assert_kind_of(REXML::Attribute, attr) + assert(['attrone', 'attrtwo'].include?(attr.name)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + assert_equal(2, counter) + end + def test_xmlarray + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element/><element/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + assert_kind_of(Array, Etch.xmlarray(doc, '/root/*')) + assert_equal(3, Etch.xmlarray(doc, '/root/*').length) + + assert_kind_of(Array, Etch.xmlarray(doc, '/root/element')) + assert_equal(2, Etch.xmlarray(doc, '/root/element').length) + + assert_kind_of(Array, Etch.xmlarray(doc, '/root/bogus')) + assert_equal(0, Etch.xmlarray(doc, '/root/bogus').length) + + Etch.xmlarray(doc, '/root/*').each do |elem| + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, elem) + assert(['element', 'other'].include?(elem.name)) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, elem) + assert(['element', 'other'].include?(elem.name)) + when :rexml + assert_kind_of(REXML::Element, elem) + assert(['element', 'other'].include?(elem.name)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + end + def test_xmlfindfirst + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element><child/><otherchild/></element><element/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + elem = Etch.xmlfindfirst(doc, '/root/element') + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, elem) + assert_equal('element', elem.name) + # This ensures we got the first <element> and not the second + assert_equal(2, elem.children.length) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, elem) + assert_equal('element', elem.name) + # This ensures we got the first <element> and not the second + assert_equal(2, elem.children.length) + when :rexml + assert_kind_of(REXML::Element, elem) + assert_equal('element', elem.name) + # This ensures we got the first <element> and not the second + assert_equal(2, elem.children.length) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmltext + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element>some text</element><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + assert_equal('some text', Etch.xmltext(Etch.xmlfindfirst(doc, '/root/element'))) + assert_equal('', Etch.xmltext(Etch.xmlfindfirst(doc, '/root/other'))) + end + def test_xmlsettext + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element>some text</element><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + Etch.xmlsettext(Etch.xmlfindfirst(doc, '/root/element'), 'new text') + assert_equal('new text', Etch.xmltext(Etch.xmlfindfirst(doc, '/root/element'))) + Etch.xmlsettext(Etch.xmlfindfirst(doc, '/root/other'), 'other text') + assert_equal('other text', Etch.xmltext(Etch.xmlfindfirst(doc, '/root/other'))) + end + def test_xmladd + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element/></root>' + file.close + doc = Etch.xmlload(file.path) + + Etch.xmladd(doc, '/root/element', 'childone') + Etch.xmladd(doc, '/root/element', 'childtwo', 'some text') + childone = Etch.xmlfindfirst(doc, '/root/element/childone') + childtwo = Etch.xmlfindfirst(doc, '/root/element/childtwo') + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, childone) + assert_equal('childone', childone.name) + assert_equal('', Etch.xmltext(childone)) + assert_kind_of(LibXML::XML::Node, childtwo) + assert_equal('childtwo', childtwo.name) + assert_equal('some text', Etch.xmltext(childtwo)) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, childone) + assert_equal('childone', childone.name) + assert_equal('', Etch.xmltext(childone)) + assert_kind_of(Nokogiri::XML::Element, childtwo) + assert_equal('childtwo', childtwo.name) + assert_equal('some text', Etch.xmltext(childtwo)) + when :rexml + assert_kind_of(REXML::Element, childone) + assert_equal('childone', childone.name) + assert_equal('', Etch.xmltext(childone)) + assert_kind_of(REXML::Element, childtwo) + assert_equal('childtwo', childtwo.name) + assert_equal('some text', Etch.xmltext(childtwo)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlcopyelem + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element><child/></element><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + original = Etch.xmlfindfirst(doc, '/root/element/child') + Etch.xmlcopyelem(original, Etch.xmlfindfirst(doc, '/root/other')) + copy = Etch.xmlfindfirst(doc, '/root/other/child') + # Change the child so that we can test that it is separate from the orignal + Etch.xmlsettext(copy, 'some text') + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, original) + assert_kind_of(LibXML::XML::Node, copy) + assert_equal('child', original.name) + assert_equal('', Etch.xmltext(original)) + assert_equal('child', copy.name) + assert_equal('some text', Etch.xmltext(copy)) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, original) + assert_kind_of(Nokogiri::XML::Element, copy) + assert_equal('child', original.name) + assert_equal('', Etch.xmltext(original)) + assert_equal('child', copy.name) + assert_equal('some text', Etch.xmltext(copy)) + when :rexml + assert_kind_of(REXML::Element, original) + assert_kind_of(REXML::Element, copy) + assert_equal('child', original.name) + assert_equal('', Etch.xmltext(original)) + assert_equal('child', copy.name) + assert_equal('some text', Etch.xmltext(copy)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlremove + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element><child/></element><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + Etch.xmlremove(doc, Etch.xmlfindfirst(doc, '/root/element')) + assert_nil(Etch.xmlfindfirst(doc, '/root/element')) + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, Etch.xmlfindfirst(doc, '/root/other')) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, Etch.xmlfindfirst(doc, '/root/other')) + when :rexml + assert_kind_of(REXML::Element, Etch.xmlfindfirst(doc, '/root/other')) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlremovepath + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element><child/></element><element/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + Etch.xmlremovepath(doc, '/root/element') + assert_nil(Etch.xmlfindfirst(doc, '/root/element')) + case Etch.xmllib + when :libxml + assert_kind_of(LibXML::XML::Node, Etch.xmlfindfirst(doc, '/root/other')) + when :nokogiri + assert_kind_of(Nokogiri::XML::Element, Etch.xmlfindfirst(doc, '/root/other')) + when :rexml + assert_kind_of(REXML::Element, Etch.xmlfindfirst(doc, '/root/other')) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlattradd + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element><child/></element><element/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + first = Etch.xmlarray(doc, '/root/element').first + second = Etch.xmlarray(doc, '/root/element').last + Etch.xmlattradd(first, 'attrname', 'attrvalue') + case Etch.xmllib + when :libxml + assert_equal('attrvalue', first.attributes['attrname']) + assert_nil(second.attributes['attrname']) + when :nokogiri + assert_equal('attrvalue', first['attrname']) + assert_nil(second['attrname']) + when :rexml + assert_equal('attrvalue', first.attributes['attrname']) + assert_nil(second.attributes['attrname']) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end + def test_xmlattrremove + file = Tempfile.new('etch_xml_abstraction') + file.puts '<root><element attrname="attrvalue"><child/></element><element attrname="othervalue"/><other/></root>' + file.close + doc = Etch.xmlload(file.path) + + first = Etch.xmlarray(doc, '/root/element').first + second = Etch.xmlarray(doc, '/root/element').last + + Etch.xmleachattrall(first) do |attr| + Etch.xmlattrremove(first, attr) + end + + case Etch.xmllib + when :libxml + assert_nil(first.attributes['attrname']) + assert_equal('othervalue', second.attributes['attrname']) + when :nokogiri + assert_nil(first['attrname']) + assert_equal('othervalue', second['attrname']) + when :rexml + assert_nil(first.attributes['attrname']) + assert_equal('othervalue', second.attributes['attrname']) + else + raise "Unknown XML library #{Etch.xmllib}" + end + end +end + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-05-05 00:27:51
|
Revision: 285 http://etch.svn.sourceforge.net/etch/?rev=285&view=rev Author: jheiss Date: 2011-05-05 00:27:45 +0000 (Thu, 05 May 2011) Log Message: ----------- Ensure that the client and server are invoked with the same ruby the user used to invoke the test suite. This allows us to test etch under various ruby versions, etc. Update to reflect client directory structure changes Modified Paths: -------------- trunk/test/test_options.rb trunk/test/test_outputcapture.rb Modified: trunk/test/test_options.rb =================================================================== --- trunk/test/test_options.rb 2011-05-04 22:22:48 UTC (rev 284) +++ trunk/test/test_options.rb 2011-05-05 00:27:45 UTC (rev 285) @@ -105,7 +105,7 @@ def test_help output = nil - IO.popen("ruby #{CLIENTDIR}/etch --help") do |pipe| + IO.popen("#{RUBY} #{CLIENTDIR}/bin/etch --help") do |pipe| output = pipe.readlines end # Make sure at least something resembling help output is there @@ -529,7 +529,7 @@ # Test that output from etch is appropriate #run_etch(@server, @testroot, :extra_args => '--list-files', :testname => testname) - output = `ruby #{CLIENTDIR}/etch --generate-all --test-root=#{@testroot} --key=#{File.dirname(__FILE__)}/keys/testkey --server=http://localhost:#{@server[:port]} --list-files` + output = `#{RUBY} #{CLIENTDIR}/bin/etch --generate-all --test-root=#{@testroot} --key=#{File.dirname(__FILE__)}/keys/testkey --server=http://localhost:#{@server[:port]} --list-files` assert(output.include?("Files under management:\n#{@targetfile}\n")) # Ensure that the target file wasn't touched Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2011-05-04 22:22:48 UTC (rev 284) +++ trunk/test/test_outputcapture.rb 2011-05-05 00:27:45 UTC (rev 285) @@ -6,9 +6,9 @@ require "./#{File.dirname(__FILE__)}/etchtest" require 'timeout' -$: << EtchTests::CLIENTDIR +$: << File.join(EtchTests::CLIENTDIR, 'lib') $: << File.join(EtchTests::SERVERDIR, 'lib') -require 'etchclient' +require 'etch/client' class EtchOutputCaptureTests < Test::Unit::TestCase include EtchTests @@ -86,7 +86,7 @@ </source> </file> <post> - <exec>ruby -e 'sleep #{Etch::Client::OUTPUT_CAPTURE_TIMEOUT + 30}' &</exec> + <exec>#{RUBY} -e 'sleep #{Etch::Client::OUTPUT_CAPTURE_TIMEOUT + 30}' &</exec> </post> </config> EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-10-13 19:28:32
|
Revision: 300 http://etch.svn.sourceforge.net/etch/?rev=300&view=rev Author: jheiss Date: 2011-10-13 19:28:26 +0000 (Thu, 13 Oct 2011) Log Message: ----------- Something seems to have changed such that __FILE__ is now a fully qualified path. As such our mechanism for requiring etchtest.rb in all the test files has stopped working. Switch it around to a cleaner mechanism that uses File.expand_path so that it doesn't matter whether we get the old or new __FILE__ behavior. Modified Paths: -------------- trunk/test/test_actions.rb trunk/test/test_attributes.rb trunk/test/test_auth.rb trunk/test/test_commands.rb trunk/test/test_conf.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_misc.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 Modified: trunk/test/test_actions.rb =================================================================== --- trunk/test/test_actions.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_actions.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of various actions: pre, post, setup, test, etc. # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchActionTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_attributes.rb =================================================================== --- trunk/test/test_attributes.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_attributes.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of attribute filtering in config.xml files # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'rubygems' # Might be needed to find facter require 'facter' Modified: trunk/test/test_auth.rb =================================================================== --- trunk/test/test_auth.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_auth.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of client authentication # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'net/http' require 'rexml/document' begin Modified: trunk/test/test_commands.rb =================================================================== --- trunk/test/test_commands.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_commands.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of configuration commands # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchCommandTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_conf.rb =================================================================== --- trunk/test/test_conf.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_conf.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of its configuration file, etch.conf # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'net/http' require 'rexml/document' require 'cgi' Modified: trunk/test/test_delete.rb =================================================================== --- trunk/test/test_delete.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_delete.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of deleting files # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchDeleteTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_depend.rb =================================================================== --- trunk/test/test_depend.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_depend.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of dependencies # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchDependTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_file.rb =================================================================== --- trunk/test/test_file.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_file.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of creating and updating regular files # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchFileTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_history.rb =================================================================== --- trunk/test/test_history.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_history.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -5,7 +5,7 @@ # history files # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchHistoryTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_link.rb =================================================================== --- trunk/test/test_link.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_link.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of creating and updating symbolic links # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'pathname' class EtchLinkTests < Test::Unit::TestCase Modified: trunk/test/test_local_requests.rb =================================================================== --- trunk/test/test_local_requests.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_local_requests.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of local requests # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchLocalRequestsTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_misc.rb =================================================================== --- trunk/test/test_misc.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_misc.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test miscellaneous items that don't fit elsewhere # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'webrick' class EtchMiscTests < Test::Unit::TestCase Modified: trunk/test/test_nodegroups.rb =================================================================== --- trunk/test/test_nodegroups.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_nodegroups.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test etch's handling of node groups and the node group hierarchy # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchNodeGroupTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_options.rb =================================================================== --- trunk/test/test_options.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_options.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test command line options to etch client # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'webrick' class EtchOptionTests < Test::Unit::TestCase Modified: trunk/test/test_outputcapture.rb =================================================================== --- trunk/test/test_outputcapture.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_outputcapture.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -4,7 +4,7 @@ # Test output capturing # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) require 'timeout' $:.unshift(File.join(EtchTests::CLIENTDIR, 'lib')) $:.unshift(File.join(EtchTests::SERVERDIR, 'lib')) Modified: trunk/test/test_scripts.rb =================================================================== --- trunk/test/test_scripts.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_scripts.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -5,7 +5,7 @@ # creation of links and directories, and control the deletion of files # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchScriptTests < Test::Unit::TestCase include EtchTests Modified: trunk/test/test_transitions.rb =================================================================== --- trunk/test/test_transitions.rb 2011-08-15 21:49:55 UTC (rev 299) +++ trunk/test/test_transitions.rb 2011-10-13 19:28:26 UTC (rev 300) @@ -5,7 +5,7 @@ # file, etc.) # -require "./#{File.dirname(__FILE__)}/etchtest" +require File.expand_path('etchtest', File.dirname(__FILE__)) class EtchTransitionTests < Test::Unit::TestCase include EtchTests This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2012-04-27 01:44:12
|
Revision: 326 http://etch.svn.sourceforge.net/etch/?rev=326&view=rev Author: jheiss Date: 2012-04-27 01:44:06 +0000 (Fri, 27 Apr 2012) Log Message: ----------- Update some instances of old search syntax to ransack syntax. Plus a few other minor updates in etchtest.rb Modified Paths: -------------- trunk/test/etchtest.rb trunk/test/test_auth.rb trunk/test/test_conf.rb Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2012-04-27 01:42:43 UTC (rev 325) +++ trunk/test/etchtest.rb 2012-04-27 01:44:06 UTC (rev 326) @@ -121,7 +121,7 @@ throw :serverstarted end end - rescue => e + rescue end sleep(1) end @@ -133,7 +133,7 @@ if UNICORN exec("cd #{SERVERDIR} && #{RUBY} `which unicorn_rails` -p #{port}") else - exec("cd #{SERVERDIR} && #{RUBY} ./script/server -p #{port}") + exec("cd #{SERVERDIR} && #{RUBY} `which rails` server -p #{port}") end end {:port => port, :pid => pid, :repo => serverbase} @@ -209,7 +209,7 @@ hostname = Facter['fqdn'].value lrm = '' Net::HTTP.start('localhost', @server[:port]) do |http| - response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") + response = http.get("/results.xml?q[client_name_eq]=#{hostname}&q[s]=created_at+desc") if !response.kind_of?(Net::HTTPSuccess) response.error! end Modified: trunk/test/test_auth.rb =================================================================== --- trunk/test/test_auth.rb 2012-04-27 01:42:43 UTC (rev 325) +++ trunk/test/test_auth.rb 2012-04-27 01:44:06 UTC (rev 326) @@ -39,7 +39,7 @@ hostname = Facter['fqdn'].value Net::HTTP.start('localhost', @server[:port]) do |http| # Find our client id - response = http.get("/clients.xml?name=#{hostname}") + response = http.get("/clients.xml?q[name_eq]=#{hostname}") if !response.kind_of?(Net::HTTPSuccess) response.error! end Modified: trunk/test/test_conf.rb =================================================================== --- trunk/test/test_conf.rb 2012-04-27 01:42:43 UTC (rev 325) +++ trunk/test/test_conf.rb 2012-04-27 01:44:06 UTC (rev 326) @@ -159,7 +159,7 @@ # these changes. Net::HTTP.start('localhost', @server[:port]) do |http| # Find our client id - response = http.get("/clients.xml?name=#{hostname}") + response = http.get("/clients.xml?q[name_eq]=#{hostname}") if !response.kind_of?(Net::HTTPSuccess) response.error! end @@ -169,8 +169,8 @@ client_id = response_xml.elements['/clients/client/id'].text # If there's an existing "sshrsakey" fact for this client then # delete it - response = http.get("/facts.xml?search[client_id]=#{client_id}&" + - "search[key]=sshrsakey") + response = http.get("/facts.xml?q[client_id_eq]=#{client_id}&" + + "q[key_eq]=sshrsakey") if !response.kind_of?(Net::HTTPSuccess) response.error! end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |