[PATCH 1/2] visualgst: Ask the TestCase for all test selectors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] visualgst: Ask the TestCase for all test selectors

Holger Freyther
With Phexample testcases are called should* and they do not show
up in GtkSUnit. Change the finding of testcases to query TestCase
for all test selectors.

2014-01-24  Holger Hans Peter Freyther  <[hidden email]>

        * SUnit/GtkSUnit.st: Ask TestCase for testcases.
---
 packages/visualgst/ChangeLog         |  4 ++++
 packages/visualgst/SUnit/GtkSUnit.st | 10 ++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog
index 3c8f680..4c4dd56 100644
--- a/packages/visualgst/ChangeLog
+++ b/packages/visualgst/ChangeLog
@@ -1,3 +1,7 @@
+2014-01-24  Holger Hans Peter Freyther  <[hidden email]>
+
+ * SUnit/GtkSUnit.st: Ask TestCase for testcases.
+
 2014-01-20  Holger Hans Peter Freyther  <[hidden email]>
 
  * SUnit/GtkSUnit.st: Change parameter from Symbol to String.
diff --git a/packages/visualgst/SUnit/GtkSUnit.st b/packages/visualgst/SUnit/GtkSUnit.st
index 9c7c5c6..012fe95 100644
--- a/packages/visualgst/SUnit/GtkSUnit.st
+++ b/packages/visualgst/SUnit/GtkSUnit.st
@@ -307,9 +307,8 @@ GtkBrowsingTool subclass: GtkSUnit [
  classWidget hasSelectedClass ifFalse: [ ^ self ].
  suite := TestSuite named: classWidget allClassNames.
  classWidget selectedClasses do: [ :elem |
-    elem selectors do: [ :each |
- (each matchRegex: 'test' from: 1 to: 4)
-    ifTrue: [ suite addTest: (elem selector: each) ] ] ].
+    elem allTestSelectors do: [:each |
+ suite addTest: (elem selector: each)]].
  suite logPolicy: TestBacktraceLog new.
  results := suite run.
 
@@ -326,9 +325,8 @@ GtkBrowsingTool subclass: GtkSUnit [
  classWidget hasSelectedClass ifFalse: [ ^ self ].
  classWidget selectedClasses do: [ :elem | | test |
     test := elem new.
-    elem selectors do: [ :each |
- (each matchRegex: 'test' from: 1 to: 4)
-    ifTrue: [ test setTestSelector: each. test debug ] ] ].
+    elem allTestSelectors do: [:each |
+ test setTestSelector: each. test debug ] ].
     ]
 
     compileError: aString line: line [
--
1.8.5.2


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] scripts: Add -d/--debug handling to gst-sunit

Holger Freyther
In case a test is failing due an unhandled exception or a test
failure occurs VisualGST will be loaded and the situation can
be analyzed. This should help during development/porting the
only downside is the load time of the VisualGST package.

2014-01-24  Holger Hans Peter Freyther <[hidden email]>

        * scripts/Test.st: Add -d/--debug option parsing.
---
 ChangeLog       |  4 ++++
 NEWS            |  3 +++
 scripts/Test.st | 55 +++++++++++++++++++++++++++++++++++++------------------
 3 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eac1c84..44ec2cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-01-24  Holger Hans Peter Freyther <[hidden email]>
+
+ * scripts/Test.st: Add -d/--debug option parsing.
+
 2014-01-24  Paolo Bonzini  <[hidden email]>
 
  * kernel/Delay.st: Check the Semaphore before queuing the
diff --git a/NEWS b/NEWS
index d77aecf..bb33a80 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ o   VisualGST now understands the CTRL + . shortcut. This will flush the
     internal TaskQueue. This might be handy when the debugger is getting
     stuck.
 
+o   gst-sunit now understands the -d/--debug parameter. In case of an
+    unhandled exception or a test failure VisualGST will be spawned.
+
 -----------------------------------------------------------------------------
 
 NEWS FROM 3.2.4 to 3.2.5
diff --git a/scripts/Test.st b/scripts/Test.st
index 4980bb6..770ca62 100644
--- a/scripts/Test.st
+++ b/scripts/Test.st
@@ -37,16 +37,9 @@ Object subclass: SUnitUnhandledDebugger [
     LoadedDebugger := nil.
 
     SUnitUnhandledDebugger class >> open: aString [
-        LoadedDebugger ifNil: [
-            LoadedDebugger := true.
-            PackageLoader fileInPackage: 'VisualGST'.
-
-            [
-                ((Smalltalk at: #VisualGST) at: #TaskQueue) uniqueInstance run.
-                ((Smalltalk at: #GTK) at: #Gtk) main] fork.
-              
-            ((Smalltalk at: #VisualGST) at: #GtkDebugger) open: aString.
-        ].
+        Transcript nextPutAll: 'Unhandled exception. Loading debugger.'; nl.
+        self loadVisualGST.
+        ((Smalltalk at: #VisualGST) at: #GtkDebugger) open: aString.
     ]
 
     SUnitUnhandledDebugger class >> debuggerClass [
@@ -57,17 +50,37 @@ Object subclass: SUnitUnhandledDebugger [
         ^0
     ]
 
-    SUnitUnhandledDebugger class >> checkKeepRunning [
-        LoadedDebugger ifNotNil: [Semaphore new wait]
+    SUnitUnhandledDebugger class >> loadVisualGST [
+        LoadedDebugger ifNotNil: [^self].
+
+        LoadedDebugger := true.
+        PackageLoader fileInPackage: 'VisualGST'.
+
+        "Start the event-loop and avoid scope look-ups. This is why
+        we look-up the class by hand."
+        [
+            ((Smalltalk at: #VisualGST) at: #TaskQueue) uniqueInstance run.
+            ((Smalltalk at: #GTK) at: #Gtk) main
+        ] fork.
+    ]
+
+    SUnitUnhandledDebugger class >> keepRunningOnFailure [
+        "Check if we have loaded the debugger and then just keep running."
+        LoadedDebugger ifNotNil: [self keepRunning]
+    ]
+
+    SUnitUnhandledDebugger class >> keepRunning [
+        Semaphore new wait
     ]
 ]
 
 
 PackageLoader fileInPackage: 'SUnit'!
 
-| helpString verbose script suite result quiet |
+| helpString verbose script suite result quiet debug |
 quiet := false.
 verbose := false.
+debug := false.
 FileStream verbose: false.
 script := ''.
 
@@ -116,6 +129,7 @@ Smalltalk
  FileStream verbose: false ].
 
     opt = 'debug' ifTrue: [
+        debug := true.
         Behavior compile: 'debuggerClass [ ^SUnitUnhandledDebugger]'
     ].
 
@@ -154,8 +168,13 @@ FileStream verbose: false.
  ObjectMemory quit: 1 ].
 
 result := TestSuitesScripter run: script quiet: quiet verbose: verbose.
-
-SUnitUnhandledDebugger checkKeepRunning.
-
-result runCount = result passedCount
-    ifFalse: [ ObjectMemory quit: 1 ]!
+SUnitUnhandledDebugger keepRunningOnFailure.
+
+result runCount = result passedCount ifFalse: [
+    debug ifTrue: [
+        Transcript nextPutAll: 'Tests failed. Loading graphicsl environment.'; nl.
+        SUnitUnhandledDebugger loadVisualGST.
+        result gtkInspect.
+        script gtkInspect.
+        SUnitUnhandledDebugger keepRunning].
+    ObjectMemory quit: 1 ]!
--
1.8.5.2


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] scripts: Add -d/--debug handling to gst-sunit

Holger Freyther
On Fri, Jan 24, 2014 at 08:25:30PM +0100, Holger Hans Peter Freyther wrote:
> In case a test is failing due an unhandled exception or a test
> failure occurs VisualGST will be loaded and the situation can
> be analyzed. This should help during development/porting the
> only downside is the load time of the VisualGST package.

The most expensive operation (according to gst-profile) is the
re-writing of the cCall calls. I wondered if we could make this
on the first call. Or we just finish the GIR support.


holger


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk