diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..466f5434a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,42 @@ +before_script: + - sudo apt-get update -qq && sudo apt-get install -y -qq libtool pkg-config $(apt-cache depends gajim-default-nightly | grep Depends | sed "s/.*ends:\ //" | tr '\n' ' ') + - sudo apt-get build-dep -y -qq gajim-default-nightly + +stages: + - test + - build + +run-test: + stage: test + script: + - ./autogen.sh + - make test_nogui + +run-build: + stage: build + script: + - ./autogen.sh + - make dist + - export FN="gajim-default-"$(date +%F)".tar" + - mv gajim-*.tar.gz $FN.gz + - mkdir tmp_add_plugins + - mv $FN.gz tmp_add_plugins/ + - cd tmp_add_plugins/ + - tar xzf $FN.gz + - rm $FN.gz + - export GF=$(find . -maxdepth 1 -type d -name 'gajim-*') + - cd $GF/plugins/ + - curl -O https://ftp.gajim.org/plugins_1/plugin_installer.zip + - unzip plugin_installer.zip + - rm plugin_installer.zip + - cd ../.. + - tar czf ../$FN.gz gajim-* + - cd .. + - rm -rf tmp_add_plugins + - scp $FN.gz panoramix:/var/www/gajim/downloads/snap/ci/gajim-default-$CI_COMMIT_SHA.tar.gz + + artifacts: + name: "gajim-default-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA" + expire_in: 1 week + paths: + - gajim-default-2???-??-??.tar.gz diff --git a/Makefile.am b/Makefile.am index 41ef7069d..a5beeff56 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,10 @@ test: ${PYTHON} test/runtests.py .PHONY: test +test_nogui: + ${PYTHON} test/runtests.py -n +.PHONY: test_nogui + doc: epydoc --config=doc/epydoc.conf .PHONY: doc diff --git a/gajim/gajim.py b/gajim/gajim.py index d34a528d8..57d3f04c5 100644 --- a/gajim/gajim.py +++ b/gajim/gajim.py @@ -105,7 +105,8 @@ class GajimApplication(Gtk.Application): self.rng_seed = None GLib.set_prgname('gajim') - GLib.set_application_name('Gajim') + if GLib.get_application_name() != 'Gajim': + GLib.set_application_name('Gajim') def do_startup(self): Gtk.Application.do_startup(self) @@ -400,5 +401,6 @@ class GajimApplication(Gtk.Application): self.lookup_action(account + action_name).set_enabled(True) -app = GajimApplication() -app.run(sys.argv) +if __name__ == '__main__': + app = GajimApplication() + app.run(sys.argv) diff --git a/test/integration/test_resolver.py b/test/integration/test_resolver.py index 2de36d8e8..e09d69956 100644 --- a/test/integration/test_resolver.py +++ b/test/integration/test_resolver.py @@ -5,6 +5,8 @@ import time import lib lib.setup_env() +from gi.repository import GLib + from common import resolver from mock import Mock, expectParams @@ -28,41 +30,38 @@ class TestResolver(unittest.TestCase): def setUp(self): self.idlequeue_thread = IdleQueueThread() self.idlequeue_thread.start() + self.main_context = GLib.MainContext() + self.main_context.push_thread_default() + self.main_loop = GLib.MainLoop(self.main_context) self.iq = self.idlequeue_thread.iq self._reset() self.resolver = None def tearDown(self): + self.main_context.pop_thread_default() self.idlequeue_thread.stop_thread() self.idlequeue_thread.join() def _reset(self): - self.flag = False self.expect_results = False - self.nslookup = False self.resolver = None - def testLibAsyncNSResolver(self): + def testGioResolver(self): self._reset() - if not resolver.USE_LIBASYNCNS: - print('testLibAsyncResolver: libasyncns-python not installed') - return - self.resolver = resolver.LibAsyncNSResolver() + self.resolver = resolver.GioResolver() - for name, type, expect_results in TEST_LIST: + for name, type_, expect_results in TEST_LIST: self.expect_results = expect_results - self._runLANSR(name, type) - self.flag = False + self._runGR(name, type_) - def _runLANSR(self, name, type): + def _runGR(self, name, type_): self.resolver.resolve( host = name, - type = type, + type_ = type_, on_ready = self._myonready) - while not self.flag: - time.sleep(1) - self.resolver.process() + + self.main_loop.run() def _myonready(self, name, result_set): if __name__ == '__main__': @@ -73,28 +72,11 @@ class TestResolver(unittest.TestCase): pprint('res.resolved_hosts: %s' % self.resolver.resolved_hosts) pprint('') if self.expect_results: - self.assert_(len(result_set) > 0) + self.assertTrue(len(result_set) > 0) else: - self.assert_(result_set == []) - self.flag = True - if self.nslookup: - self._testNSLR() + self.assertTrue(result_set == []) + self.main_loop.quit() - def testNSLookupResolver(self): - self._reset() - self.nslookup = True - self.resolver = resolver.NSLookupResolver(self.iq) - self.test_list = TEST_LIST - self._testNSLR() - - def _testNSLR(self): - if self.test_list == []: - return - name, type, self.expect_results = self.test_list.pop() - self.resolver.resolve( - host = name, - type = type, - on_ready = self._myonready) if __name__ == '__main__': unittest.main() diff --git a/test/integration/test_roster.py b/test/integration/test_roster.py index d81df5dd9..a45610dd6 100644 --- a/test/integration/test_roster.py +++ b/test/integration/test_roster.py @@ -20,16 +20,16 @@ class TestRosterWindow(unittest.TestCase): def setUp(self): gajim.interface = MockInterface() - self.C_NAME = roster_window.C_NAME - self.C_TYPE = roster_window.C_TYPE - self.C_JID = roster_window.C_JID - self.C_ACCOUNT = roster_window.C_ACCOUNT + self.C_NAME = roster_window.Column.NAME + self.C_TYPE = roster_window.Column.TYPE + self.C_JID = roster_window.Column.JID + self.C_ACCOUNT = roster_window.Column.ACCOUNT # Add after creating RosterWindow # We want to test the filling explicitly gajim.contacts = contacts_module.LegacyContactsAPI() gajim.connections = {} - self.roster = roster_window.RosterWindow() + self.roster = roster_window.RosterWindow(gajim.app) for acc in contacts: gajim.connections[acc] = MockConnection(acc) diff --git a/test/lib/__init__.py b/test/lib/__init__.py index 803472b12..afae96164 100644 --- a/test/lib/__init__.py +++ b/test/lib/__init__.py @@ -50,3 +50,5 @@ def setup_env(): if use_x: import gtkgui_helpers gtkgui_helpers.GUI_DIR = gajim_root + '/data/gui' + from gajim import GajimApplication + gajim.app = GajimApplication() diff --git a/test/lib/gajim_mocks.py b/test/lib/gajim_mocks.py index 1d1cb3bd6..d0a5d058c 100644 --- a/test/lib/gajim_mocks.py +++ b/test/lib/gajim_mocks.py @@ -107,6 +107,8 @@ class MockInterface(Mock): self.msg_win_mgr = Mock() self.roster = Mock() gajim.ged = ged.GlobalEventsDispatcher() + import plugins + gajim.plugin_manager = plugins.PluginManager() self.remote_ctrl = None self.instances = {} @@ -126,7 +128,8 @@ class MockInterface(Mock): class MockLogger(Mock): def __init__(self): - Mock.__init__(self, {'write': None, 'get_transports_type': {}}) + Mock.__init__(self, {'insert_into_logs': None, + 'get_transports_type': {}}) self.cur = Mock() diff --git a/test/runtests.py b/test/runtests.py index 0d67e2182..59d5e0a62 100755 --- a/test/runtests.py +++ b/test/runtests.py @@ -39,7 +39,6 @@ modules = ( 'unit.test_protocol_caps', 'unit.test_caps_cache', 'unit.test_contacts', 'unit.test_account', - 'unit.test_gui_interface', ) if use_x: @@ -47,6 +46,7 @@ if use_x: #'integration.test_gui_event_integration', 'integration.test_roster', 'integration.test_resolver', + 'unit.test_gui_interface', ) nb_errors = 0 diff --git a/test/unit/test_gui_interface.py b/test/unit/test_gui_interface.py index 565c38a59..734a4190c 100644 --- a/test/unit/test_gui_interface.py +++ b/test/unit/test_gui_interface.py @@ -20,8 +20,7 @@ class TestInterface(unittest.TestCase): def test_instantiation(self): ''' Test that we can proper initialize and do not fail on globals ''' - interface = Interface() - interface.run() + gajim.app.run() def test_links_regexp_entire(self): sut = Interface() diff --git a/test/unit/test_sessions.py b/test/unit/test_sessions.py index e2de62b83..f0d115461 100644 --- a/test/unit/test_sessions.py +++ b/test/unit/test_sessions.py @@ -153,7 +153,7 @@ class TestChatControlSession(unittest.TestCase): sess = self.conn.sessions[jid]['123'] # message was logged - calls = gajim.logger.mockGetNamedCalls('write') + calls = gajim.logger.mockGetNamedCalls('insert_into_logs') self.assertEqual(1, len(calls)) # no ChatControl was open and autopopup was off @@ -171,7 +171,7 @@ class TestChatControlSession(unittest.TestCase): jid = 'bct@necronomicorp.com' fjid = 'bct@necronomicorp.com/Gajim' msgtxt = 'testing two' - roster = RosterWindow() + roster = RosterWindow(gajim.app) sess = self.conn.sessions[jid]['123'] sess.control = MockChatControl(fjid, account_name) @@ -179,7 +179,7 @@ class TestChatControlSession(unittest.TestCase): self.receive_chat_msg(fjid, msgtxt) # message was logged - calls = gajim.logger.mockGetNamedCalls('write') + calls = gajim.logger.mockGetNamedCalls('insert_into_logs') self.assertEqual(2, len(calls)) # the message does not go into the event queue @@ -207,7 +207,7 @@ class TestChatControlSession(unittest.TestCase): #self.receive_chat_msg(fjid, msgtxt) ## message was logged - #calls = gajim.logger.mockGetNamedCalls('write') + #calls = gajim.logger.mockGetNamedCalls('insert_into_logs') #self.assertEqual(1, len(calls)) ## the message does not go into the event queue