Fix updater test behavior with Ruby 1.9.x

The behavior of FileUtils.cp w.r.t. preserving the source file
mode changed between Ruby 1.8 and Ruby 1.9, in particular the execute
permission was not preserved for copied binaries so the test script
failed to launch them.

Set the :preserve attribute so that the source file's mode is
used.

MD-19678 #time 1h
This commit is contained in:
Robert Knight 2013-09-02 09:56:16 +01:00
parent b168ed69d7
commit 0472a4e991
1 changed files with 9 additions and 3 deletions

View File

@ -117,6 +117,12 @@ OptionParser.new do |parser|
end
end.parse!
# copy 'src' to 'dest', preserving the attributes
# of 'src'
def copy_file(src, dest)
FileUtils.cp src, dest, :preserve => true
end
# Remove the install and package dirs if they
# already exist
FileUtils.rm_rf(INSTALL_DIR)
@ -125,7 +131,7 @@ FileUtils.rm_rf(PACKAGE_SRC_DIR)
# Create the install directory with the old app
Dir.mkdir(INSTALL_DIR)
FileUtils.cp(OLDAPP_NAME,"#{INSTALL_DIR}/#{APP_NAME}")
copy_file OLDAPP_NAME, "#{INSTALL_DIR}/#{APP_NAME}"
# Create a dummy file to uninstall
uninstall_test_file = create_test_file("#{INSTALL_DIR}/file-to-uninstall.txt", "this file should be removed after the update")
@ -146,7 +152,7 @@ File.open(nested_dir_test_file,'w') do |file|
file.puts "this is a new file in a new nested dir"
end
FileUtils::chmod 0644, nested_dir_test_file
FileUtils.cp(NEWAPP_NAME,"#{PACKAGE_SRC_DIR}/#{APP_NAME}")
copy_file NEWAPP_NAME, "#{PACKAGE_SRC_DIR}/#{APP_NAME}"
FileUtils::chmod 0755, "#{PACKAGE_SRC_DIR}/#{APP_NAME}"
# Create .zip packages from source files
@ -160,7 +166,7 @@ end
# Copy the install script and updater to the target
# directory
replace_vars("file_list.xml","#{PACKAGE_DIR}/file_list.xml",file_list_vars)
FileUtils.cp("../#{UPDATER_NAME}","#{PACKAGE_DIR}/#{UPDATER_NAME}")
copy_file "../#{UPDATER_NAME}", "#{PACKAGE_DIR}/#{UPDATER_NAME}"
# Run the updater using the new syntax
#