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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Jun 25 13:00:37 UTC 2009


Revision: 2551
          http://rkward.svn.sourceforge.net/rkward/?rev=2551&view=rev
Author:   tfry
Date:     2009-06-25 13:00:37 +0000 (Thu, 25 Jun 2009)

Log Message:
-----------
rename the test standards to sane file extensions, and fix assignment problem in load_data and import_csv-plugins

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/00saveload/import/import_csv.php
    trunk/rkward/rkward/plugins/00saveload/import/load_data.php
    trunk/rkward/tests/import_export_plugins.R
    trunk/rkward/tests/test_framework.R

Added Paths:
-----------
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.messages.txt
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkout
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv_overwrite.messages.txt
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv_overwrite.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.messages.txt
    trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkout

Removed Paths:
-------------
    trunk/rkward/tests/import_export_plugins/import_csv.rkcom.standard
    trunk/rkward/tests/import_export_plugins/import_csv.rkout.standard
    trunk/rkward/tests/import_export_plugins/import_csv.rkwarn.standard
    trunk/rkward/tests/import_export_plugins/import_csv_overwrite.rkcom.standard
    trunk/rkward/tests/import_export_plugins/import_csv_overwrite.rkwarn.standard
    trunk/rkward/tests/import_export_plugins/load_r_object.rkcom.standard
    trunk/rkward/tests/import_export_plugins/load_r_object.rkout.standard
    trunk/rkward/tests/import_export_plugins/load_r_object.rkwarn.standard

Modified: trunk/rkward/rkward/plugins/00saveload/import/import_csv.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_csv.php	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_csv.php	2009-06-25 13:00:37 UTC (rev 2551)
@@ -24,7 +24,7 @@
 		$tableOptions = "";
 	}
 // Other method is to use read.table and show all the options - more transparent
-getRK("name"); ?> <<- read.<? echo ($quick); ?> (file="<? getRK("file"); ?>"<? echo ($tableOptions); ?>, <? # doing row names (what a pity...) 
+?>imported <<- read.<? echo ($quick); ?> (file="<? getRK("file"); ?>"<? echo ($tableOptions); ?>, <? # doing row names (what a pity...) 
 	if (getRK_val("rowname")!="NULL") {
 		echo( "row.names = ");
 		if (getRK_val("rowname")=="rowcol") echo (getRK("nomrow") . ",");
@@ -36,6 +36,9 @@
 	if (getRK_val("colclass") == "custoClass") echo( "colClasses = " . getRK_val ("custoClasses") . ",");
 	#doing what is left
 ?> na.strings = "<? getRK("na")  ?>", nrows = <? getRK("nrows") ; ?>, skip = <? getRK("skip") ; ?>, check.names = <? getRK("checkname") ; ?>, strip.white = <? getRK("stripwhite") ; ?>, blank.lines.skip = <? getRK("blanklinesskip") ; ?><? getRK("allow_escapes"); ?><? getRK("flush"); ?><? getRK("strings_as_factors"); ?>)
+
+# copy from the local environment to globalenv()
+assign("<? getRK("name"); ?>", imported, envir=globalenv())
 <?	if (getRK_val ("doedit")) { ?>
 
 rk.edit (<? getRK ("name"); ?>)

Modified: trunk/rkward/rkward/plugins/00saveload/import/load_data.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/load_data.php	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/rkward/plugins/00saveload/import/load_data.php	2009-06-25 13:00:37 UTC (rev 2551)
@@ -13,7 +13,7 @@
 	}
 
 	if ($other_env) { ?>
-<? echo ($envir); ?> <<- new.env (parent=globalenv())
+assign ("<? echo ($envir); ?>, new.env (parent=globalenv()), envir=globalenv())
 <?	} ?>
 load (file="<? getRK("file"); ?>", envir=<? echo ($envir); ?>)
 <?

Copied: trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkcommands.R (from rev 2548, trunk/rkward/tests/import_export_plugins/import_csv.rkcom.standard)
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkcommands.R	2009-06-25 13:00:37 UTC (rev 2551)
@@ -0,0 +1,13 @@
+local({
+## Prepare
+## Compute
+imported <<- read.csv (file="women.csv", row.names = 1, na.strings = "NA", nrows = -1, skip = 0, check.names = TRUE, strip.white = FALSE, blank.lines.skip = TRUE)
+
+# copy from the local environment to globalenv()
+assign("women", imported, envir=globalenv())
+## Print result
+rk.header("Import text / csv data", parameters=list("File", "women.csv",
+	"Import as", "women"))
+})
+.rk.rerun.plugin.link(plugin="rkward::import_csv", settings="allow_escapes.state=\nblanklinesskip.state=TRUE\ncheckname.state=TRUE\ncolclass.string=\ncolname.string=\ndec.string='.'\ndoedit.state=0\nfile.selection=women.csv\nflush.state=\nisrow.state=true\nna.text=NA\nname.selection=women\nnomrow.text=1\nnrows.text=-1\nquick.string=csv\nquote.string='\\\\\\\"'\nrowname.string=rowcol\nsep.string=','\nskip.text=0\nstrings_as_factors.string=\nstripwhite.state=FALSE", label="Run again")
+.rk.make.hr()

Copied: trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkout (from rev 2548, trunk/rkward/tests/import_export_plugins/import_csv.rkout.standard)
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv.rkout	2009-06-25 13:00:37 UTC (rev 2551)
@@ -0,0 +1,7 @@
+<h1>Import text / csv data</h1>
+<h2>Parameters</h2>
+<ul><li>File: women.csv</li>
+<li>Import as: women</li>
+</ul>
+DATE<br>
+<a href="rkward://runplugin/rkward::import_csv/allow_escapes.state=%0ablanklinesskip.state=TRUE%0acheckname.state=TRUE%0acolclass.string=%0acolname.string=%0adec.string='.'%0adoedit.state=0%0afile.selection=women.csv%0aflush.state=%0aisrow.state=true%0ana.text=NA%0aname.selection=women%0anomrow.text=1%0anrows.text=-1%0aquick.string=csv%0aquote.string='%5c%5c%5c%22'%0arowname.string=rowcol%0asep.string=','%0askip.text=0%0astrings_as_factors.string=%0astripwhite.state=FALSE">Run again</a><hr>

Copied: trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv_overwrite.messages.txt (from rev 2548, trunk/rkward/tests/import_export_plugins/import_csv_overwrite.rkwarn.standard)
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv_overwrite.messages.txt	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.import_csv_overwrite.messages.txt	2009-06-25 13:00:37 UTC (rev 2551)
@@ -0,0 +1,3 @@
+Error in rk.call.plugin("rkward::import_csv", file.selection = "women.csv",  : 
+  
+The plugin could not be auto-submitted with these settings.

Copied: trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkcommands.R (from rev 2548, trunk/rkward/tests/import_export_plugins/load_r_object.rkcom.standard)
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkcommands.R	2009-06-25 13:00:37 UTC (rev 2551)
@@ -0,0 +1,10 @@
+local({
+## Prepare
+## Compute
+load (file="women.RData", envir=globalenv())
+## Print result
+rk.header("Load data", parameters=list("File", "women.RData",
+	"Import to environment", "globalenv()"))
+})
+.rk.rerun.plugin.link(plugin="rkward::load_r_object", settings="file.selection=women.RData\nother_env.state=0", label="Run again")
+.rk.make.hr()

Copied: trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkout (from rev 2548, trunk/rkward/tests/import_export_plugins/load_r_object.rkout.standard)
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.load_r_object.rkout	2009-06-25 13:00:37 UTC (rev 2551)
@@ -0,0 +1,7 @@
+<h1>Load data</h1>
+<h2>Parameters</h2>
+<ul><li>File: women.RData</li>
+<li>Import to environment: globalenv()</li>
+</ul>
+DATE<br>
+<a href="rkward://runplugin/rkward::load_r_object/file.selection=women.RData%0aother_env.state=0">Run again</a><hr>

Deleted: trunk/rkward/tests/import_export_plugins/import_csv.rkcom.standard
===================================================================
--- trunk/rkward/tests/import_export_plugins/import_csv.rkcom.standard	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins/import_csv.rkcom.standard	2009-06-25 13:00:37 UTC (rev 2551)
@@ -1,10 +0,0 @@
-local({
-## Prepare
-## Compute
-women <<- read.csv (file="women.csv",  na.strings = "NA", nrows = -1, skip = 0, check.names = TRUE, strip.white = FALSE, blank.lines.skip = TRUE)
-## Print result
-rk.header("Import text / csv data", parameters=list("File", "women.csv",
-	"Import as", "women"))
-})
-.rk.rerun.plugin.link(plugin="rkward::import_csv", settings="allow_escapes.state=\nblanklinesskip.state=TRUE\ncheckname.state=TRUE\ncolclass.string=\ncolname.string=\ndec.string='.'\ndoedit.state=0\nfile.selection=women.csv\nflush.state=\nisrow.state=false\nna.text=NA\nname.selection=women\nnrows.text=-1\nquick.string=csv\nquote.string='\\\\\\\"'\nsep.string=','\nskip.text=0\nstrings_as_factors.string=\nstripwhite.state=FALSE", label="Run again")
-.rk.make.hr()

Deleted: trunk/rkward/tests/import_export_plugins/import_csv.rkout.standard
===================================================================
--- trunk/rkward/tests/import_export_plugins/import_csv.rkout.standard	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins/import_csv.rkout.standard	2009-06-25 13:00:37 UTC (rev 2551)
@@ -1 +0,0 @@
-<a href="rkward://runplugin/rkward::import_csv/allow_escapes.state=%0ablanklinesskip.state=TRUE%0acheckname.state=TRUE%0acolclass.string=%0acolname.string=%0adec.string='.'%0adoedit.state=0%0afile.selection=women.csv%0aflush.state=%0aisrow.state=false%0ana.text=NA%0aname.selection=women%0anrows.text=-1%0aquick.string=csv%0aquote.string='%5c%5c%5c%22'%0asep.string=','%0askip.text=0%0astrings_as_factors.string=%0astripwhite.state=FALSE">Run again</a><hr>

Deleted: trunk/rkward/tests/import_export_plugins/import_csv.rkwarn.standard
===================================================================
--- trunk/rkward/tests/import_export_plugins/import_csv.rkwarn.standard	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins/import_csv.rkwarn.standard	2009-06-25 13:00:37 UTC (rev 2551)
@@ -1,2 +0,0 @@
-Error in eval(expr, envir, enclos) : 
-  no function to return from, jumping to top level

Deleted: trunk/rkward/tests/import_export_plugins/import_csv_overwrite.rkwarn.standard
===================================================================
--- trunk/rkward/tests/import_export_plugins/import_csv_overwrite.rkwarn.standard	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins/import_csv_overwrite.rkwarn.standard	2009-06-25 13:00:37 UTC (rev 2551)
@@ -1,3 +0,0 @@
-Error in rk.call.plugin("rkward::import_csv", file.selection = "women.csv",  : 
-  
-The plugin could not be auto-submitted with these settings.

Deleted: trunk/rkward/tests/import_export_plugins/load_r_object.rkcom.standard
===================================================================
--- trunk/rkward/tests/import_export_plugins/load_r_object.rkcom.standard	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins/load_r_object.rkcom.standard	2009-06-25 13:00:37 UTC (rev 2551)
@@ -1,10 +0,0 @@
-local({
-## Prepare
-## Compute
-load (file="women.RData", envir=globalenv())
-## Print result
-rk.header("Load data", parameters=list("File", "women.RData",
-	"Import to environment", "globalenv()"))
-})
-.rk.rerun.plugin.link(plugin="rkward::load_r_object", settings="file.selection=women.RData\nother_env.state=0", label="Run again")
-.rk.make.hr()

Deleted: trunk/rkward/tests/import_export_plugins/load_r_object.rkout.standard
===================================================================
--- trunk/rkward/tests/import_export_plugins/load_r_object.rkout.standard	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins/load_r_object.rkout.standard	2009-06-25 13:00:37 UTC (rev 2551)
@@ -1,7 +0,0 @@
-<h1>Load data</h1>
-<h2>Parameters</h2>
-<ul><li>File: women.RData</li>
-<li>Import to environment: globalenv()</li>
-</ul>
-DATE<br>
-<a href="rkward://runplugin/rkward::load_r_object/file.selection=women.RData%0aother_env.state=0">Run again</a><hr>

Modified: trunk/rkward/tests/import_export_plugins.R
===================================================================
--- trunk/rkward/tests/import_export_plugins.R	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/import_export_plugins.R	2009-06-25 13:00:37 UTC (rev 2551)
@@ -25,12 +25,12 @@
 		new ("RKTest", id="load_r_object", call=function () {
 			rk.call.plugin ("rkward::load_r_object", file.selection="women.RData", other_env.state="0", submit.mode="submit")
 
-			stopifnot (all.equal (women, datasets::women))
+			stopifnot (all.equal (.GlobalEnv$women, datasets::women))
 		}),
 		new ("RKTest", id="import_csv", call=function () {
-			rk.call.plugin ("rkward::import_csv", allow_escapes.state="", blanklinesskip.state="TRUE", checkname.state="TRUE", colclass.string="", colname.string="", dec.string="'.'", doedit.state="0", file.selection="women.csv", flush.state="", isrow.state="false", na.text="NA", name.selection="women", nrows.text="-1", quick.string="csv", quote.string="'\\\"'", sep.string="','", skip.text="0", strings_as_factors.string="", stripwhite.state="FALSE", submit.mode="submit")
+			rk.call.plugin ("rkward::import_csv", allow_escapes.state="", blanklinesskip.state="TRUE", checkname.state="TRUE", colclass.string="", colname.string="", dec.string="'.'", doedit.state="0", file.selection="women.csv", flush.state="", isrow.state="true", na.text="NA", name.selection="women", nrows.text="-1", quick.string="csv", quote.string="'\\\"'", sep.string="','", skip.text="0", strings_as_factors.string="", stripwhite.state="FALSE", rowname.string="rowcol", nomrow.text="1", submit.mode="submit")
 
-			stopifnot (all.equal (women, datasets::women))
+			stopifnot (all.equal (.GlobalEnv$women, datasets::women))
 		}),
 		new ("RKTest", id="import_csv_overwrite", call=function () {
 			assign ("women", datasets::women, envir=globalenv ())

Modified: trunk/rkward/tests/test_framework.R
===================================================================
--- trunk/rkward/tests/test_framework.R	2009-06-25 11:26:24 UTC (rev 2550)
+++ trunk/rkward/tests/test_framework.R	2009-06-25 13:00:37 UTC (rev 2551)
@@ -70,7 +70,7 @@
 
 # returns true, if file corresponds to standard.
 rktest.compare.against.standard <- function (file) {
-	standard_file <- paste (file, ".standard", sep="")
+	standard_file <- gsub ("^(.*\\/)([^\\/]*)$", "\\1RKTestStandard\\.\\2", file)
 	if (!file.exists (file)) {
 		# if neither exists, that means both files are empty
 		if (!file.exists (standard_file)) return (TRUE)
@@ -127,8 +127,8 @@
 	if (!validObject (test)) return (result)
 
 	output_file <- rktest.file (test at id, ".rkout")
-	code_file <- rktest.file (test at id, ".rkcom")
-	message_file <- rktest.file (test at id, ".rkwarn")
+	code_file <- rktest.file (test at id, ".rkcommands.R")
+	message_file <- rktest.file (test at id, ".messages.txt")
 
 	# the essence of the test:
 	result at error <- rktest.runRKTest.internal (test, output_file, code_file, message_file)
@@ -149,7 +149,7 @@
 
 	files <- list.files ()
 	# do not delete the standards!
-	files <- grep (".*\\.standard$", files, value=TRUE, invert=TRUE)
+	files <- grep ("^RKTestStandard\\..*\\.(messages.txt|rkcommands.R|rkout)$", files, value=TRUE, invert=TRUE)
 
 	file.remove (files)
 
@@ -197,8 +197,9 @@
 	setwd (paste (basedir, suite at id, sep="/"))
 
 	files <- list.files ()
-	files <- grep (".*\\.(rkwarn|rkcom|rkout)$", files, value=TRUE)
-	file.copy (files, paste (files, ".standard", sep=""), overwrite=TRUE)
+	files <- grep ("\\.(messages.txt|rkcommands.R|rkout)$", files, value=TRUE)
+	files <- grep ("^RKTestStandard", files, value=TRUE, invert=TRUE)
+	file.copy (files, paste ("RKTestStandard.", files, sep=""), overwrite=TRUE)
 
 	# clean anything that is *not* a standard file
 	rktest.cleanRKTestSuite (suite, basedir)


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