pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/R2pkg/files pkgtools/R2pkg: make USE_LANGUAGE...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/638084d36898
branches:  trunk
changeset: 416150:638084d36898
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Oct 19 17:30:10 2019 +0000

description:
pkgtools/R2pkg: make USE_LANGUAGES code simpler

diffstat:

 pkgtools/R2pkg/files/R2pkg.R      |  17 +++++------------
 pkgtools/R2pkg/files/R2pkg_test.R |  16 ++++++++--------
 2 files changed, 13 insertions(+), 20 deletions(-)

diffs (86 lines):

diff -r 5d6ad1888b5a -r 638084d36898 pkgtools/R2pkg/files/R2pkg.R
--- a/pkgtools/R2pkg/files/R2pkg.R      Sat Oct 19 17:15:00 2019 +0000
+++ b/pkgtools/R2pkg/files/R2pkg.R      Sat Oct 19 17:30:10 2019 +0000
@@ -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 @@
   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 @@
   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 @@
     '',
     depends,
     USE_LANGUAGES,
+    '',
     '.include "../../math/R/Makefile.extension"',
     buildlink3,
     '.include "../../mk/bsd.pkg.mk"',
diff -r 5d6ad1888b5a -r 638084d36898 pkgtools/R2pkg/files/R2pkg_test.R
--- a/pkgtools/R2pkg/files/R2pkg_test.R Sat Oct 19 17:15:00 2019 +0000
+++ b/pkgtools/R2pkg/files/R2pkg_test.R Sat Oct 19 17:30:10 2019 +0000
@@ -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 @@
 
 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('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