Run the update installation test as part of the 'make test' target

* Add a test which runs the test-update.rb script
 * Add a --auto-close option to the updater which auto-dismisses the
   update dialog once installation is complete. This is used in
   test-update.rb to make the script run without user interaction
   being required.

MD-19678 #time 1h
This commit is contained in:
Robert Knight 2013-08-30 11:44:39 +01:00
parent c09e5d2290
commit cbda873a70
10 changed files with 40 additions and 13 deletions

View File

@ -28,6 +28,7 @@ set (SOURCES
Log.cpp
ProcessUtils.cpp
StandardDirs.cpp
UpdateDialog.cpp
UpdateInstaller.cpp
UpdateScript.cpp
UpdaterOptions.cpp

View File

@ -2,13 +2,28 @@
#include "UpdateObserver.h"
/** Base class for the updater's UI, sub-classed
* by the different platform implementations.
*/
class UpdateDialog : public UpdateObserver
{
public:
UpdateDialog();
virtual ~UpdateDialog() {};
/** Sets whether the updater should automatically
* exit once the update has been installed.
*/
void setAutoClose(bool autoClose);
bool autoClose() const;
virtual void init(int argc, char** argv) = 0;
virtual void exec() = 0;
virtual void quit() = 0;
virtual void updateFinished();
private:
bool m_autoClose;
};

View File

@ -56,6 +56,8 @@ void UpdateDialogAscii::updateFinished()
m_mutex.lock();
m_output << "\nUpdate Finished. You can now restart " << AppInfo::appName() << "." << std::endl;
m_mutex.unlock();
UpdateDialog::updateFinished();
}
void UpdateDialogAscii::quit()

View File

@ -173,6 +173,7 @@ void UpdateDialogCocoa::updateFinished()
[d->delegate performSelectorOnMainThread:@selector(reportUpdateFinished:)
withObject:nil
waitUntilDone:false];
UpdateDialog::updateFinished();
}
void* UpdateDialogCocoa::createAutoreleasePool()

View File

@ -149,6 +149,7 @@ void UpdateDialogGtk::updateFinished()
{
UpdateMessage* message = new UpdateMessage(this,UpdateMessage::UpdateFinished);
g_idle_add(&UpdateDialogGtk::notify,message);
UpdateDialog::updateFinished();
}

View File

@ -141,6 +141,7 @@ void UpdateDialogWin32::updateFinished()
{
UpdateMessage* message = new UpdateMessage(UpdateMessage::UpdateFinished);
SendNotifyMessage(m_window.GetHwnd(),WM_USER,reinterpret_cast<WPARAM>(message),0);
UpdateDialog::updateFinished();
}
void UpdateDialogWin32::quit()

View File

@ -60,6 +60,10 @@ std::list<std::string> UpdateInstaller::updaterArgs() const
args.push_back(m_packageDir);
args.push_back("--script");
args.push_back(m_script->path());
if (m_autoClose)
{
args.push_back("--auto-close");
}
return args;
}

View File

@ -28,7 +28,7 @@
#define UPDATER_VERSION "0.16"
void runWithUi(int argc, char** argv, UpdateInstaller* installer);
UpdateDialog* createUpdateDialog();
void runUpdaterThread(void* arg)
{
@ -149,7 +149,14 @@ int main(int argc, char** argv)
if (options.mode == UpdateInstaller::Main)
{
runWithUi(argc,argv,&installer);
LOG(Info, "Showing updater UI - auto close? " + intToStr(options.autoClose));
std::auto_ptr<UpdateDialog> dialog(createUpdateDialog());
dialog->setAutoClose(options.autoClose);
dialog->init(argc, argv);
installer.setObserver(dialog.get());
tthread::thread updaterThread(runUpdaterThread, &installer);
dialog->exec();
updaterThread.join();
}
else
{
@ -179,16 +186,6 @@ UpdateDialog* createUpdateDialog()
#endif
}
void runWithUi(int argc, char** argv, UpdateInstaller* installer)
{
std::auto_ptr<UpdateDialog> dialog(createUpdateDialog());
dialog->init(argc, argv);
installer->setObserver(dialog.get());
tthread::thread updaterThread(runUpdaterThread, installer);
dialog->exec();
updaterThread.join();
}
#ifdef PLATFORM_WINDOWS
// application entry point under Windows
int CALLBACK WinMain(HINSTANCE hInstance,

View File

@ -43,4 +43,9 @@ endmacro()
add_updater_test(TestUpdateScript)
add_updater_test(TestUpdaterOptions)
add_updater_test(TestFileUtils)
# Add updater that that performs a complete update install
# and checks the result
find_program(RUBY_BIN ruby)
add_test(TestUpdateInstall ${RUBY_BIN} test-update.rb)

View File

@ -192,7 +192,7 @@ install_path = File.expand_path(INSTALL_DIR)
Dir.chdir(INSTALL_DIR) do
flags = "--force-elevated" if force_elevation
debug_flags = "gdb --args" if run_in_debugger
cmd = "#{debug_flags} #{PACKAGE_DIR}/#{UPDATER_NAME} #{flags} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml"
cmd = "#{debug_flags} #{PACKAGE_DIR}/#{UPDATER_NAME} #{flags} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml --auto-close"
puts "Running '#{cmd}'"
system(cmd)
end