[Sciviews-commits] r337 - pkg/svUnit/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Oct 31 11:58:57 CET 2010
Author: phgrosjean
Date: 2010-10-31 11:58:56 +0100 (Sun, 31 Oct 2010)
New Revision: 337
Modified:
pkg/svUnit/R/svSuiteData.R
pkg/svUnit/R/svTestData.R
Log:
Slight code presentation changes
Modified: pkg/svUnit/R/svSuiteData.R
===================================================================
--- pkg/svUnit/R/svSuiteData.R 2010-10-26 09:15:58 UTC (rev 336)
+++ pkg/svUnit/R/svSuiteData.R 2010-10-31 10:58:56 UTC (rev 337)
@@ -37,7 +37,7 @@
UseMethod("metadata")
metadata.svSuiteData <- function (object,
- fields = c("R.version", "sessionInfo", "time", "description"), ...)
+fields = c("R.version", "sessionInfo", "time", "description"), ...)
{
## Extract metadata information from a 'svSuiteData' object
if (!is.svSuiteData(object))
@@ -117,37 +117,34 @@
protocol_junit <- function (object, ...)
UseMethod("protocol_junit")
-protocol_junit.svSuiteData <- function (object, file="", append=FALSE, ...)
+protocol_junit.svSuiteData <- function (object, file = "", append = FALSE, ...)
{
- if (!is.svSuiteData(object))
- stop("'object' must inherit from 'svSuiteData'")
- if(!require(XML, quietly=TRUE))
- return(invisible(FALSE))
+ if (!is.svSuiteData(object))
+ stop("'object' must inherit from 'svSuiteData'")
+ if(!require(XML, quietly = TRUE))
+ return(invisible(FALSE))
- Tests <- sort(ls(object))
- if((length(Tests) > 0) && inherits(object[[Tests[1]]], "svSuiteData"))
- ## this is a set of suites (containing svSuiteData)
- root <- xmlNode('testsuites')
- else
- ## this is a single suite (containing svTestData)
- root <- xmlNode('testsuite')
+ Tests <- sort(ls(object))
+ if (length(Tests) > 0 && inherits(object[[Tests[1]]], "svSuiteData")) {
+ ## This is a set of suites (containing svSuiteData)
+ root <- xmlNode('testsuites')
+ } else {
+ ## This is a single suite (containing svTestData)
+ root <- xmlNode('testsuite')
+ }
- with(stats(object), addAttributes(root,
- name=NULL,
- tests=length(Tests),
- errors=sum(kind == '**ERROR**'),
- failures=sum(kind == '**FAILS**'),
- skip=sum(kind == 'DEACTIVATED')))
- if (length(Tests) > 0) {
- for (Test in Tests)
- root <- addChildren(root, kids=list(protocol_junit(object[[Test]], append=TRUE)))
- }
+ with(stats(object), addAttributes(root, name = NULL, tests = length(Tests),
+ errors = sum(kind == '**ERROR**'), failures = sum(kind == '**FAILS**'),
+ skip = sum(kind == 'DEACTIVATED')))
+ for (Test in Tests)
+ root <- addChildren(root,
+ kids = list(protocol_junit(object[[Test]], append = TRUE)))
- ## decide whether to return the xml node or write the xml file
- if(append)
- return(root)
- else {
- saveXML(root, file)
- return(invisible(TRUE))
- }
+ ## Decide whether to return the xml node or write the xml file
+ if (isTRUE(append)) {
+ return(root)
+ } else {
+ saveXML(root, file)
+ return(invisible(TRUE))
+ }
}
Modified: pkg/svUnit/R/svTestData.R
===================================================================
--- pkg/svUnit/R/svTestData.R 2010-10-26 09:15:58 UTC (rev 336)
+++ pkg/svUnit/R/svTestData.R 2010-10-31 10:58:56 UTC (rev 337)
@@ -86,39 +86,38 @@
}
-protocol_junit.svTestData <- function(object, ...) {
- if(!require(XML, quietly=TRUE))
- return(invisible(FALSE))
+protocol_junit.svTestData <- function (object, ...)
+{
+ if (!require(XML, quietly = TRUE))
+ return(invisible(FALSE))
- toValidXmlString <- function(s) {
- s <- gsub("&", "&", s)
- s <- gsub("<", "<", s)
- s <- gsub(">", ">", s)
- s <- gsub('"', """, s)
- s <- gsub("'", "'", s)
- s
- }
+ toValidXmlString <- function (s) {
+ s <- gsub("&", "&", s)
+ s <- gsub("<", "<", s)
+ s <- gsub(">", ">", s)
+ s <- gsub('"', """, s)
+ s <- gsub("'", "'", s)
+ return(s)
+ }
- basename <- function(s) sub(".*/", "", s)
+ basename <- function (s) sub(".*/", "", s)
- Context <- attr(object, "context")
- Stats <- attr(object, "stats")
- result <- xmlNode('testcase',
- attrs=c(
- 'classname'=basename(Context[['unit']]),
- 'name'=toValidXmlString(Context[['test']]),
- 'time'=object$timing))
- kind <- as.numeric(.kindMax(object$kind)) # TODO: use accessor
- elementName <- c(NA, 'failure', 'error', NA)[kind]
- if(!is.na(elementName)) {
- failureNode <- xmlNode(elementName,
- attrs=c(
- 'type'=elementName,
- 'message'=toValidXmlString(object$res))) # TODO: use accessor
- result <- addChildren(result, kids=list(failureNode))
- }
- if(kind == 4)
- result <- addChildren(result, kids=list(xmlNode('skipped')))
+ Context <- attr(object, "context")
+ Stats <- attr(object, "stats")
+ result <- xmlNode('testcase', attrs = c(
+ 'classname' = basename(Context[['unit']]),
+ 'name' = toValidXmlString(Context[['test']]),
+ 'time' = object$timing))
+ kind <- as.numeric(.kindMax(object$kind)) # TODO: use accessor
+ elementName <- c(NA, 'failure', 'error', NA)[kind]
+ if (!is.na(elementName)) {
+ failureNode <- xmlNode(elementName, attrs = c(
+ 'type' = elementName,
+ 'message' = toValidXmlString(object$res))) # TODO: use accessor
+ result <- addChildren(result, kids = list(failureNode))
+ }
+ if (kind == 4)
+ result <- addChildren(result, kids = list(xmlNode('skipped')))
- return(result)
+ return(result)
}
More information about the Sciviews-commits
mailing list