pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/R2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Oct 19 17:30:10 UTC 2019

Modified Files:
        pkgsrc/pkgtools/R2pkg/files: R2pkg.R R2pkg_test.R

Log Message:
pkgtools/R2pkg: make USE_LANGUAGES code simpler


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 pkgsrc/pkgtools/R2pkg/files/R2pkg.R
cvs rdiff -u -r1.15 -r1.16 pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/R2pkg/files/R2pkg.R
diff -u pkgsrc/pkgtools/R2pkg/files/R2pkg.R:1.20 pkgsrc/pkgtools/R2pkg/files/R2pkg.R:1.21
--- pkgsrc/pkgtools/R2pkg/files/R2pkg.R:1.20    Sat Oct 19 15:47:03 2019
+++ pkgsrc/pkgtools/R2pkg/files/R2pkg.R Sat Oct 19 17:30:10 2019
@@ -1,4 +1,4 @@
-# $NetBSD: R2pkg.R,v 1.20 2019/10/19 15:47:03 rillig Exp $
+# $NetBSD: R2pkg.R,v 1.21 2019/10/19 17:30:10 rillig Exp $
 #
 # Copyright (c) 2014,2015,2016,2017,2018,2019
 #      Brook Milligan.  All rights reserved.
@@ -609,16 +609,8 @@ make.depends <- function(imps,deps)
   result
 }
 
-use.languages <- function(imps, deps)
-{
-  USE_LANGUAGES <- list()
-  if (find.Rcpp(imps, deps))
-    USE_LANGUAGES <- append(USE_LANGUAGES, list('c c++'))
-  if (length(USE_LANGUAGES) == 0)
-    USE_LANGUAGES <- '# none'
-  USE_LANGUAGES <- end.paragraph(USE_LANGUAGES)
-  USE_LANGUAGES
-}
+use_languages <- function(imps, deps)
+  if (find.Rcpp(imps, deps)) 'c c++' else '# none'
 
 copy.description <- function(connection)
 {
@@ -634,7 +626,7 @@ write.Makefile <- function(metadata)
   LICENSE       <- varassign('LICENSE', license(metadata$License))
   R_PKGNAME     <- varassign('R_PKGNAME', one.line(metadata$Package))
   R_PKGVER      <- varassign('R_PKGVER', one.line(metadata$Version))
-  USE_LANGUAGES <- varassigns('USE_LANGUAGES', use.languages(metadata$Imports, metadata$Depends))
+  USE_LANGUAGES <- varassign('USE_LANGUAGES', use_languages(metadata$Imports, metadata$Depends))
   dependencies  <- make.depends(metadata$Imports, metadata$Depends)
   depends       <- dependencies[1]
   buildlink3    <- dependencies[2]
@@ -652,6 +644,7 @@ write.Makefile <- function(metadata)
     '',
     depends,
     USE_LANGUAGES,
+    '',
     '.include "../../math/R/Makefile.extension"',
     buildlink3,
     '.include "../../mk/bsd.pkg.mk"',

Index: pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R
diff -u pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R:1.15 pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R:1.16
--- pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R:1.15       Sat Oct 19 15:47:03 2019
+++ pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R    Sat Oct 19 17:30:10 2019
@@ -1,4 +1,4 @@
-# $NetBSD: R2pkg_test.R,v 1.15 2019/10/19 15:47:03 rillig Exp $
+# $NetBSD: R2pkg_test.R,v 1.16 2019/10/19 17:30:10 rillig Exp $
 #
 # Copyright (c) 2019
 #      Roland Illig.  All rights reserved.
@@ -38,6 +38,7 @@ arg.update <- FALSE
 
 package_dir <- file.path(Sys.getenv('PKGSRCDIR'), 'pkgtools', 'R2pkg')
 
+# don't use tabs in the output; see https://stackoverflow.com/q/58465177
 expect_printed <- function(obj, ...) {
     out <- ''
     with_output_sink(textConnection('out', 'w', local = TRUE), print(obj))
@@ -536,17 +537,16 @@ test_that('update.dependency', {
 # test_that('make.depends', {
 # })
 
-test_that('use.languages', {
-    languages <- use.languages(list(), list())
+test_that('use_languages without Rcpp as dependency', {
+    languages <- use_languages(list(), list())
 
-    expect_equal(languages, c('# none', ''))
+    expect_equal(languages, '# none')
 })
 
-test_that('use.languages with Rcpp as dependency', {
-    languages <- use.languages(list('Rcpp(>=0)'), list())
-    expected <- list('c cpp', '')
+test_that('use_languages with Rcpp as dependency', {
+    languages <- use_languages(list('Rcpp(>=0)'), list())
 
-    #expect_equal(languages, expected)
+    expect_equal(languages, 'c c++')
 })
 
 # test_that('copy.description', {



Home | Main Index | Thread Index | Old Index