Commit 159d145f authored by Michael Terry's avatar Michael Terry

tests: add ability to check for initialization error; move version logic from...

tests: add ability to check for initialization error; move version logic from mock to runner; add old-version test; remove previous old-style old version test
parent 62d76672
......@@ -34,7 +34,6 @@ AUTO_TESTS = \
backup/quiescent \
backup/spaces \
backup/symlinks \
basic/badversion \
restore/cycle \
prefs/s3-folder \
prefs/ssh-to-file \
......@@ -113,7 +112,6 @@ XXXcheck: prep
EXTRA_DIST = \
backup \
basic \
prefs \
restore \
base.py \
......
#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# For copyright information, see AUTHORS.
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
import sys
scriptdir=sys.path[0]
sys.path.insert(0, scriptdir+'/..')
import base
import ldtp
import os
def test():
base.setup()
# Set up our duplicity wrapper to be called by deja-dup
os.environ['PATH'] = os.path.join(scriptdir, 'badversion-bin') + ":" + os.environ['PATH']
base.start_deja_dup(waitfor='dlgError')
assert ldtp.guiexist('dlgError', "lblDuplicity’sversionistooold")
ldtp.click('dlgError', 'btnOK')
base.run(test)
#!/bin/sh
# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# For copyright information, see AUTHORS.
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
# This file acts like a fake duplicity that always prints "duplicity 0.5.02"
echo "duplicity 0.5.02"
......@@ -46,10 +46,6 @@
import sys, os, shlex, getpass, time
if sys.argv[1] == '--version':
print 'duplicity 9.9.99'
sys.exit(0)
if not os.path.exists(os.environ['DEJA_DUP_TEST_MOCKSCRIPT']):
print >> logfd, "TESTFAIL: no mockscript"
sys.exit(-1)
......
......@@ -163,6 +163,7 @@ class BackupRunner : Object
{
public delegate void OpCallback (DejaDup.Operation op);
public DejaDup.Operation op = null;
public string? init_error = null;
public bool success = true;
public bool cancelled = false;
public string? detail = null;
......@@ -174,6 +175,15 @@ class BackupRunner : Object
public void run()
{
string header, msg;
if (!DejaDup.initialize(out header, out msg)) {
if (header + "\n" + msg != init_error)
warning("Init error didn't match; expected '%s', got '%s'", init_error, msg);
return;
}
if (init_error != null)
warning("Init error '%s' was expected", init_error);
var loop = new MainLoop(null);
op.done.connect((op, s, c, d) => {
Test.message("Done: %d, %d, %s", (int)s, (int)c, d);
......@@ -297,6 +307,8 @@ void process_operation_block(KeyFile keyfile, string group, BackupRunner br) thr
br.is_first = keyfile.get_boolean(group, "IsFirst");
if (keyfile.has_key(group, "Detail"))
br.detail = replace_keywords(keyfile.get_string(group, "Detail"));
if (keyfile.has_key(group, "InitError"))
br.init_error = keyfile.get_string(group, "InitError");
if (keyfile.has_key(group, "Error"))
br.error_str = keyfile.get_string(group, "Error");
if (keyfile.has_key(group, "ErrorDetail"))
......@@ -375,9 +387,16 @@ void process_duplicity_run_block(KeyFile keyfile, string run, BackupRunner br) t
void process_duplicity_block(KeyFile keyfile, string group, BackupRunner br) throws Error
{
var runs = keyfile.get_string_list(group, "Runs");
foreach (var run in runs)
process_duplicity_run_block(keyfile, run, br);
var version = "9.9.99";
if (keyfile.has_key(group, "Version"))
version = keyfile.get_string(group, "Version");
add_to_mockscript("ARGS: --version\n\nduplicity " + version + "\n");
if (keyfile.has_key(group, "Runs")) {
var runs = keyfile.get_string_list(group, "Runs");
foreach (var run in runs)
process_duplicity_run_block(keyfile, run, br);
}
}
void backup_run()
......@@ -400,6 +419,7 @@ void backup_run()
br.run();
}
catch (Error e) {
warning("%s\n", e.message);
assert_not_reached();
}
}
......
# Make sure we correctly reject an old version
[Operation]
Type=backup
Success=false
Error=Déjà Dup Backup Tool requires at least version 0.6.14 of duplicity, but only found version 0.6.13
[Duplicity]
Version=0.6.13
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment