[gnome-logs/wip/test] Add behave tests to Makefile.am and configure.ac. Clean after-scenario in environment.py



commit 029af14d4582cf7d40b24b7d8854eb2fab15edee
Author: Rashi Aswani <aswanirashi19 gmail com>
Date:   Thu Aug 20 20:43:18 2015 +0530

    Add behave tests to Makefile.am and configure.ac. Clean after-scenario in environment.py

 Makefile.am                  |    4 +++-
 configure.ac                 |    5 +++++
 m4/behave-installed-tests.m4 |    8 ++++----
 tests/common_steps.py        |    9 +++++++++
 tests/environment.py         |   22 +++-------------------
 5 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7f8ac50..b048902 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -265,7 +265,9 @@ TESTS = \
 endif
 
 @BEHAVE_INSTALLED_TESTS_RULE@
-INSTALLED_TESTS=general.feature
+INSTALLED_TESTS=       \
+               general.feature \
+               $(NULL)
 INSTALLED_TESTS_TYPE=session-exclusive
 
 iconthemedir = $(datadir)/icons/hicolor
diff --git a/configure.ac b/configure.ac
index 533e776..e536dfd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ AS_IF([test "x$enable_man" != "xno"],
 
 AM_CONDITIONAL([ENABLE_MAN], [test "x$have_manutils" = "xyes"])
 
+dnl Installed tests
 BEHAVE_INSTALLED_TESTS
 
 dnl AppData XML
@@ -115,3 +116,7 @@ Makefile
 po/Makefile.in
 ])
 AC_OUTPUT
+
+AC_MSG_NOTICE([
+       Installed tests:          $enable_installed_tests
+])
diff --git a/m4/behave-installed-tests.m4 b/m4/behave-installed-tests.m4
index 4feb82d..170a8fe 100644
--- a/m4/behave-installed-tests.m4
+++ b/m4/behave-installed-tests.m4
@@ -90,14 +90,14 @@ endif
 installed-tests-exec-hook:
        @$(MKDIR_P) $(EXEC_DIRECTORY);
        @for feature in $(BEHAVE_FEATURES); do                                                                
                  \
-           $(LIBTOOL) --mode=install $(INSTALL) --mode=644 $$feature $(EXEC_DIRECTORY);\
+           $(LIBTOOL) --mode=install $(INSTALL) --mode=777 $$feature $(EXEC_DIRECTORY);\
        done
        @for common_file in $(BEHAVE_COMMON_FILES); do                                                        
                  \
-           $(LIBTOOL) --mode=install $(INSTALL) --mode=644 $$common_file $(EXEC_DIRECTORY);\
+           $(LIBTOOL) --mode=install $(INSTALL) --mode=777 $$common_file $(EXEC_DIRECTORY);\
        done
        @$(MKDIR_P) $(EXEC_DIRECTORY)/steps;
        @for step_definition in $(BEHAVE_STEP_DEFINITION); do                                                 
                  \
-           $(LIBTOOL) --mode=install $(INSTALL) --mode=644 $$step_definition $(EXEC_DIRECTORY)/steps;\
+           $(LIBTOOL) --mode=install $(INSTALL) --mode=777 $$step_definition $(EXEC_DIRECTORY)/steps;\
        done
 
 
@@ -106,7 +106,7 @@ installed-tests-data-hook:
        @for test in $(INSTALLED_TESTS); do                                                     \
            echo "Installing $$test.test to $(META_DIRECTORY)";                                 \
            echo m4_escape([[Test]]) > $(META_DIRECTORY)/$$test.test;                           \
-           echo "Exec=behave $(pkglibexecdir)/installed-tests -t $$test -k -f html -o $$test.html -f plain"  
  \
+           echo "Exec=behave $(pkglibexecdir)/installed-tests -i $$test -k -f html -o $$test.html -f plain"  
  \
                                                   >> $(META_DIRECTORY)/$$test.test;            \
            echo "Type=$(INSTALLED_TESTS_TYPE)" >> $(META_DIRECTORY)/$$test.test;               \
        done
diff --git a/tests/common_steps.py b/tests/common_steps.py
index 6d7f372..d2e943e 100644
--- a/tests/common_steps.py
+++ b/tests/common_steps.py
@@ -133,3 +133,12 @@ def cleanup():
     schemas = [x for x in Gio.Settings.list_schemas() if 'gnome-logs-test' in x.lower()]
     for schema in schemas:
         system("gsettings reset-recursively %s" % schema)
+
+def non_block_read(output):
+    fd = output.fileno()
+    fl = fcntl.fcntl(fd, fcntl.F_GETFL)
+    fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
+    try:
+        return output.read()
+    except:
+        return ""
diff --git a/tests/environment.py b/tests/environment.py
index e7e48ba..e53266d 100644
--- a/tests/environment.py
+++ b/tests/environment.py
@@ -5,7 +5,7 @@ from dogtail.utils import isA11yEnabled, enableA11y
 if not isA11yEnabled():
     enableA11y(True)
 
-from common_steps import App, dummy, cleanup
+from common_steps import App, dummy, cleanup, non_block_read
 from dogtail.config import config
 import os
 
@@ -31,7 +31,7 @@ def before_all(context):
         # Store scenario start time for session logs
         context.log_start_time = strftime("%Y-%m-%d %H:%M:%S", localtime())
 
-        context.app_class = App('./gnome-logs-behave-test')
+        context.app_class = App('/home/rashi/checkout/gnome/gnome-logs/tests/gnome-logs-behave-test')
 
     except Exception as e:
         print("Error in before_all: %s" % e.message)
@@ -57,23 +57,7 @@ def after_scenario(context, scenario):
     """
 
     try:
-        # Attach journalctl logs
-        if hasattr(context, "embed"):
-            os.system("journalctl /usr/bin/gnome-session --no-pager -o cat --since='%s'> 
/tmp/journal-session.log" % context.log_start_time)
-            data = open("/tmp/journal-session.log", 'r').read()
-            if data:
-                context.embed('text/plain', data)
-
-            context.app_class.kill()
-
-            stdout = non_block_read(context.app_class.process.stdout)
-            stderr = non_block_read(context.app_class.process.stderr)
-
-            if stdout:
-                context.embed('text/plain', stdout)
-
-            if stderr:
-                context.embed('text/plain', stderr)
+        context.app_class.kill()
 
         # Make some pause after scenario
         sleep(1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]