From 84497af6b62678bb8c1a14224fd58446a2785423 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Sun, 21 Mar 2021 15:35:18 +0900 Subject: [PATCH] Output info to stderr instead of StringIO --- ibus-anthy-HEAD.patch | 137 ++++++++++++++++++ ibus-anthy.spec | 6 +- .../ibus-desktop-testing-role/tasks/main.yml | 18 ++- 3 files changed, 154 insertions(+), 7 deletions(-) diff --git a/ibus-anthy-HEAD.patch b/ibus-anthy-HEAD.patch index e69de29..34b9127 100644 --- a/ibus-anthy-HEAD.patch +++ b/ibus-anthy-HEAD.patch @@ -0,0 +1,137 @@ +From 4d1f0b36c43780586f5d0c2622eb92d068ebe281 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Sun, 21 Mar 2021 15:25:41 +0900 +Subject: [PATCH] tests: Output info to stderr instead of StringIO + +--- + tests/anthytest.py | 51 ++++++++++++++++++++++++++++++---------------- + 1 file changed, 33 insertions(+), 18 deletions(-) + +diff --git a/tests/anthytest.py b/tests/anthytest.py +index bff3078..1d18d19 100755 +--- a/tests/anthytest.py ++++ b/tests/anthytest.py +@@ -28,17 +28,31 @@ TAP_MODULE_PYCOTAP = list(range(3)) + + tap_module = TAP_MODULE_NONE + ++# Need to flush the output against Gtk.main() ++def printflush(sentence): ++ try: ++ print(sentence, flush=True) ++ except IOError: ++ pass ++ ++def printerr(sentence): ++ try: ++ print(sentence, flush=True, file=sys.stderr) ++ except IOError: ++ pass ++ + try: + from tap import TAPTestRunner + tap_module = TAP_MODULE_TAPPY +- print('Load tappy') ++ printflush('## Load tappy') + except ModuleNotFoundError: + try: + from pycotap import TAPTestRunner ++ from pycotap import LogMode + tap_module = TAP_MODULE_PYCOTAP +- print('Load pycotap') ++ printflush('## Load pycotap') + except ModuleNotFoundError as err: +- print('Ignore tap module: %s' % str(err)) ++ printflush('## Ignore tap module: %s' % str(err)) + + PY3K = sys.version_info >= (3, 0) + DONE_EXIT = True +@@ -55,18 +69,6 @@ sys.path.append('/usr/share/ibus-anthy/engine') + + from anthycases import TestCases + +-# Need to flush the output against Gtk.main() +-def printflush(sentence): +- try: +- print(sentence, flush=True) +- except IOError: +- pass +- +-def printerr(sentence): +- try: +- print(sentence, flush=True, file=sys.stderr) +- except IOError: +- pass + + @unittest.skipIf(Gdk.Display.open('') == None, 'Display cannot be open.') + class AnthyTest(unittest.TestCase): +@@ -83,8 +85,10 @@ class AnthyTest(unittest.TestCase): + self.__test_index = 0 + self.__conversion_index = 0 + self.__commit_done = False ++ self.__engine = None + + def register_ibus_engine(self): ++ printflush('## Registering engine') + self.__bus = IBus.Bus() + if not self.__bus.is_connected(): + self.fail('ibus-daemon is not running') +@@ -144,6 +148,7 @@ class AnthyTest(unittest.TestCase): + + def __create_engine_cb(self, factory, engine_name): + if engine_name == 'testanthy': ++ printflush('## Creating engine') + try: + import engine + except ModuleNotFoundError as e: +@@ -176,14 +181,20 @@ class AnthyTest(unittest.TestCase): + window = Gtk.Window(type = Gtk.WindowType.TOPLEVEL) + self.__entry = entry = Gtk.Entry() + window.connect('destroy', Gtk.main_quit) ++ entry.connect('map', self.__entry_map_cb) + entry.connect('focus-in-event', self.__entry_focus_in_event_cb) + entry.connect('preedit-changed', self.__entry_preedit_changed_cb) + buffer = entry.get_buffer() + buffer.connect('inserted-text', self.__buffer_inserted_text_cb) + window.add(entry) + window.show_all() ++ printflush('## Build window') ++ ++ def __entry_map_cb(self, entry): ++ printflush('## Map window') + + def __entry_focus_in_event_cb(self, entry, event): ++ printflush('## Get focus') + if self.__test_index == len(TestCases['tests']): + if DONE_EXIT: + Gtk.main_quit() +@@ -231,11 +242,11 @@ class AnthyTest(unittest.TestCase): + schema = "org.freedesktop.ibus.engine.anthy.common"); + result = settings.get_int('input-mode') + if result != 0: +- printflush('Enable hiragana %d' % result) ++ printflush('## Enable hiragana %d' % result) + key = TestCases['init'] + self.__typing(key[0], key[1], key[2]) + else: +- printflush('Already hiragana') ++ printflush('## Already hiragana') + + def __main_test(self): + self.__conversion_index = 0 +@@ -371,7 +382,11 @@ def main(): + + if args.tap: + loader = unittest.TestLoader() +- runner = TAPTestRunner() ++ if tap_module == TAP_MODULE_PYCOTAP: ++ # Log should be in stderr instead of StringIO ++ runner = TAPTestRunner(test_output_log=LogMode.LogToError) ++ else: ++ runner = TAPTestRunner() + if tap_module == TAP_MODULE_TAPPY: + runner.set_stream(True) + unittest.main(testRunner=runner, testLoader=loader) +-- +2.28.0 + diff --git a/ibus-anthy.spec b/ibus-anthy.spec index b9aff94..d350e87 100644 --- a/ibus-anthy.spec +++ b/ibus-anthy.spec @@ -18,7 +18,7 @@ Name: ibus-anthy Version: 1.5.12 -Release: 2%{?dist} +Release: 3%{?dist} Summary: The Anthy engine for IBus input platform License: GPLv2+ URL: https://github.com/ibus/ibus/wiki @@ -76,6 +76,7 @@ for developers. %package tests Summary: Tests for the %{name} package +BuildRequires: python3-pycotap Requires: %{name}%{?_isa} = %{version}-%{release} Requires: python3-pycotap @@ -158,6 +159,9 @@ desktop-file-validate \ %{_datadir}/installed-tests/%{name} %changelog +* Sun Mar 21 2021 Takao Fujiwara - 1.5.12-3 +- Output info to stderr instead of StringIO + * Tue Mar 16 2021 Takao Fujiwara - 1.5.12-2 - Change default input mode to Hiragana diff --git a/tests/roles/ibus-desktop-testing-role/tasks/main.yml b/tests/roles/ibus-desktop-testing-role/tasks/main.yml index 5844d5a..44c70e2 100644 --- a/tests/roles/ibus-desktop-testing-role/tasks/main.yml +++ b/tests/roles/ibus-desktop-testing-role/tasks/main.yml @@ -80,7 +80,17 @@ if [ $? -eq 0 ]; then status="PASS: frame" fi - echo "${status} $TEST" >> {{ remote_artifacts }}/test.log + echo "${status}" >> {{ remote_artifacts }}/test.log + echo "#### {{ remote_artifacts }}/{{ installed_test_name }}.log" + if [ -f {{ remote_artifacts }}/{{ installed_test_name }}.log ] ; then + cat {{ remote_artifacts }}/{{ installed_test_name }}.log + fi + echo "#" + echo "#### {{ remote_artifacts }}/test.log" + if [ -f {{ remote_artifacts }}/test.log ] ; then + cat {{ remote_artifacts }}/test.log + fi + echo "#" - name: Check the results #shell: grep "^FAIL" {{ remote_artifacts }}/test.log @@ -88,18 +98,14 @@ log="{{ remote_artifacts }}/test.log" if [ ! -f $log ] ; then echo ERROR - exit 1 else FAIL=`grep "^FAIL: " {{ remote_artifacts }}/test.log | grep -v 'FAIL: 0$'` if [ x"$FAIL" != x ] ; then echo ERROR - exit 1 - else - echo PASS fi fi register: test_fails - #failed_when: False + failed_when: False - name: Set role result set_fact: