[rkward-cvs] SF.net SVN: rkward:[2543] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Jun 23 20:48:52 UTC 2009


Revision: 2543
          http://rkward.svn.sourceforge.net/rkward/?rev=2543&view=rev
Author:   tfry
Date:     2009-06-23 20:48:52 +0000 (Tue, 23 Jun 2009)

Log Message:
-----------
Add command-line option --evaluate, and mockup of integration into the build system

Modified Paths:
--------------
    trunk/rkward/CMakeLists.txt
    trunk/rkward/ChangeLog
    trunk/rkward/debian/rkward.1
    trunk/rkward/makedist.sh
    trunk/rkward/rkward/main.cpp
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/rkward.h
    trunk/rkward/rkward/rkward.sh.template
    trunk/rkward/tests/test.R

Added Paths:
-----------
    trunk/rkward/tests/CMakeLists.txt

Modified: trunk/rkward/CMakeLists.txt
===================================================================
--- trunk/rkward/CMakeLists.txt	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/CMakeLists.txt	2009-06-23 20:48:52 UTC (rev 2543)
@@ -22,5 +22,6 @@
 ADD_SUBDIRECTORY(rkward)
 ADD_SUBDIRECTORY(po)
 ADD_SUBDIRECTORY(doc)
+ADD_SUBDIRECTORY(tests)
 
 # TODO: figure out how to make source distributions (with REAMDE files, etc.)

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/ChangeLog	2009-06-23 20:48:52 UTC (rev 2543)
@@ -1,4 +1,5 @@
 TODO: add notice on differing licences/copyrights in subdirs
+- New command line option "--evaluate <Rcode>" mostly for the purpose of automated testing
 - Remove support for R 2.6.x and earlier		TODO: clean up more (RData?), adjust debian control
 - Add basic checks for a correct installation of the RKWard resource files
 - Remove "What to expect" dialog at startup

Modified: trunk/rkward/debian/rkward.1
===================================================================
--- trunk/rkward/debian/rkward.1	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/debian/rkward.1	2009-06-23 20:48:52 UTC (rev 2543)
@@ -35,6 +35,9 @@
 .B \-v, \-\-version
 Show version of program.
 .TP
+.B \-\-evaluate <Rcode>
+The given R code is evaluated after RKWard has started, and after any specified workspace is loaded. Mostly useful for automated testing.
+.TP
 .B \-\-debug-level <level>
 Verbosity of debug output. 0-5, where 0 is no output, 5 is all output including function trace information. Default it 2
 .TP

Modified: trunk/rkward/makedist.sh
===================================================================
--- trunk/rkward/makedist.sh	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/makedist.sh	2009-06-23 20:48:52 UTC (rev 2543)
@@ -14,10 +14,12 @@
 mkdir $DISTDIR/doc
 mkdir $DISTDIR/po
 mkdir $DISTDIR/rkward
+mkdir $DISTDIR/rkward
 
 rsync -a --exclude '*~' --exclude '*.svn*' $EXCLUDES $BASEDIR/doc/* $DISTDIR/doc
 rsync -a --exclude '*~' --exclude '*.svn*' $EXCLUDES $BASEDIR/po/* $DISTDIR/po
 rsync -a --exclude '*~' --exclude '*.svn*' --exclude 'templates' $EXCLUDES $BASEDIR/rkward/* $DISTDIR/rkward
+rsync -a --exclude '*~' --exclude '*.svn*' $EXCLUDES $BASEDIR/tests/* $DISTDIR/tests
 
 cd $DISTDIR/po
 ./Messages.sh

Modified: trunk/rkward/rkward/main.cpp
===================================================================
--- trunk/rkward/rkward/main.cpp	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/rkward/main.cpp	2009-06-23 20:48:52 UTC (rev 2543)
@@ -76,11 +76,12 @@
 static KCmdLineOptions options;
 
 int main(int argc, char *argv[]) {
-	options.add ("+[File]", ki18n ("file to open"), 0);
+	options.add ("evaluate <Rcode>", ki18n ("After starting (and after loading the specified workspace, if applicable), evaluate the given R code."), 0);
 	options.add ("debug-level <level>", ki18n ("Verbosity of debug messages (0-5)"), "2");
 	options.add ("debug-flags <flags>", ki18n ("Mask for components to debug (see debug.h)"), "8191");
 	options.add ("debugger <command>", ki18n ("Debugger (enclose any debugger arguments in single quotes ('') together with the command)"), "");
 	options.add ("disable-stack-check", ki18n ("Disable R C stack checking"), 0);
+	options.add ("+[File]", ki18n ("R workspace file to open"), 0);
 
 	KAboutData aboutData("rkward", QByteArray (), ki18n ("RKWard"), VERSION, ki18n ("Frontend to the R statistics language"), KAboutData::License_GPL, ki18n ("(c) 2002, 2004, 2005, 2006, 2007, 2008, 2009"), KLocalizedString (), "http://rkward.sf.net", "rkward-devel at lists.sourceforge.net");
 	aboutData.addAuthor (ki18n ("%1").subs ("Thomas Friedrichsmeier"), ki18n ("Project leader / main developer"));
@@ -126,6 +127,7 @@
 		stoptions->initial_url = KUrl (args->makeURL (args->arg (0).toLatin1()));
 	}
 	stoptions->no_stack_check = args->isSet ("disable-stack-check");
+	stoptions->evaluate = args->getOption ("evaluate");
 
 	RKWardApplication app;
 	if (app.isSessionRestored ()) {

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/rkward/rkward.cpp	2009-06-23 20:48:52 UTC (rev 2543)
@@ -203,6 +203,7 @@
 
 	// startup options will be deleted from the R thread (TODO correct this!), so we need to copy the initial_url here, or run into race conditions
 	KUrl open_url = startup_options->initial_url;
+	QString evaluate_code = startup_options->evaluate;
 	startR ();
 	
 	initPlugins ();
@@ -252,6 +253,8 @@
 		toplevel_actions->showRKWardHelp ();
 	}
 
+	if (!evaluate_code.isEmpty ()) RKConsole::pipeUserCommand (evaluate_code);
+
 	setCaption (QString ());	// our version of setCaption takes care of creating a correct caption, so we do not need to provide it here
 }
 

Modified: trunk/rkward/rkward/rkward.h
===================================================================
--- trunk/rkward/rkward/rkward.h	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/rkward/rkward.h	2009-06-23 20:48:52 UTC (rev 2543)
@@ -44,6 +44,7 @@
 struct RKWardStartupOptions {
 	KUrl initial_url;	/**< The workspace file to load on startup. If empty, show a dialog asking what to do. **/
 	bool no_stack_check;	/**< Disable R C stack checking */
+	QString evaluate;	/**< R code to run after startup */
 };
 
 /**

Modified: trunk/rkward/rkward/rkward.sh.template
===================================================================
--- trunk/rkward/rkward/rkward.sh.template	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/rkward/rkward.sh.template	2009-06-23 20:48:52 UTC (rev 2543)
@@ -1,24 +1,6 @@
 #!/bin/sh
 # Shell wrapper for rkward executable.
 
-## make sure, we always run in a tty. Otherwise R would go into non-interactive mode and behaves strangely.
-## this can be removed later. For R versions 2.3.0 and greater, we set R_Interactive from C
-if tty -s; then
-  :
-else
-  # not on a tty? Try to invoke a suitable xterm
-  if [ -z $RKWARD_NORECURSE ]; then
-    for xtrm in konsole x-terminal-emulator xterm
-    do
-      xtrmc=`which $xtrm`
-      if [ ! -z $xtrmc -a -x $xtrmc ]; then
-        RKWARD_NORECURSE=y $xtrmc -e $0 "$@"
-        exit
-      fi
-    done
-  fi
-fi
-
 export R_binary="@R_EXECUTABLE@"
 
 ## Location of R may have moved, so check
@@ -48,24 +30,19 @@
 }
 
 debugger=
-args=
-while test -n "${1}"; do
-  case ${1} in
-    --debugger)
-      if test -n "`echo ${2} | sed 's/^-.*//'`"; then
-        debugger="${2}"; shift
-      else
-        error "option '${1}' requires an argument"
-      fi
-      ;;
-    *)
-      args="${args} ${1}" ;;
-  esac
-  shift
+for i in `seq $#`
+do
+  arg=$(eval echo \$\{`echo ${i}`\})
+  if [ "${arg}" = "--debugger" ]; then
+    debugger=$(eval echo \$\{`echo $((i+1))`\})
+    if test -z "`echo ${debugger} | sed 's/^-.*//'`"; then
+      error "option '${arg}' requires an argument"
+    fi
+  fi
 done
 
 ## set LC_NUMERIC to "C"
 export LC_NUMERIC="C"
 
 ## Start rkward. Running through R CMD to set all the relevant R enviroment variables
-exec $R_binary CMD $debugger $0.bin ${args}
+exec $R_binary CMD $debugger $0.bin "$@"

Added: trunk/rkward/tests/CMakeLists.txt
===================================================================
--- trunk/rkward/tests/CMakeLists.txt	                        (rev 0)
+++ trunk/rkward/tests/CMakeLists.txt	2009-06-23 20:48:52 UTC (rev 2543)
@@ -0,0 +1,3 @@
+ADD_CUSTOM_TARGET (plugintests
+	COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../rkward/rkward --evaluate 'source (\"import_export_plugins.R\")'
+	WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
\ No newline at end of file

Modified: trunk/rkward/tests/test.R
===================================================================
--- trunk/rkward/tests/test.R	2009-06-23 10:40:50 UTC (rev 2542)
+++ trunk/rkward/tests/test.R	2009-06-23 20:48:52 UTC (rev 2543)
@@ -17,6 +17,14 @@
 		}
 	)
 
+setClass ("RKTestResult",
+		representation (id = "character", code_match = "logical", output_match = "logical", message_match = "logical", error="logical", passed="logical"),
+		prototype(character(0), id = character (0), code_match = NA, output_match = NA, message_match = NA, error = NA, passed=FALSE),
+		validity=function (object) {
+			return (all.equal (length (object at id), length (object at code_match), length (object at output_match), length (object at message_match), length (object at error), length (object at passed)))
+		}
+	)
+
 setMethod ("show", "RKTestResult", function (object) {
 	stopifnot (inherits (object, "RKTestResult"))
 
@@ -39,14 +47,6 @@
 	}
 })
 
-setClass ("RKTestResult",
-		representation (id = "character", code_match = "logical", output_match = "logical", message_match = "logical", error="logical", passed="logical"),
-		prototype(character(0), id = character (0), code_match = NA, output_match = NA, message_match = NA, error = NA, passed=FALSE),
-		validity=function (object) {
-			return (all.equal (length (object at id), length (object at code_match), length (object at output_match), length (object at message_match), length (object at error), length (object at passed)))
-		}
-	)
-
 rktest.appendTestResults <- function (objecta, objectb) {
 	stopifnot (inherits (objecta, "RKTestResult") && validObject (objecta))
 	stopifnot (inherits (objectb, "RKTestResult") && validObject (objectb))


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list