Skip to content

Commit f852d7f

Browse files
committed
Add target rule in root Makefile to check reverse dependencies
Signed-off-by: Stefan Widgren <[email protected]>
1 parent 7db9f28 commit f852d7f

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

Makefile

+54-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,56 @@ check:
2929
R CMD check --as-cran --no-manual --no-vignettes \
3030
--no-build-vignettes $(PKG_TAR)
3131

32+
# Check reverse dependencies
33+
#
34+
# 1) Install packages (in ./revdep/lib) to check reverse dependencies.
35+
# 2) Check reverse dependencies using 'R CMD check'.
36+
# 3) Collect results from '00check.log' files.
37+
revdep: revdep_install revdep_check revdep_results
38+
39+
# Install packages to check reverse dependencies
40+
revdep_install: clean
41+
mkdir -p revdep/lib
42+
cd .. && R CMD INSTALL --library=$(PKG_NAME)/revdep/lib $(PKG_NAME)
43+
Rscript --vanilla \
44+
-e "options(repos = c(CRAN='https://cran.r-project.org'))" \
45+
-e "lib <- 'revdep/lib'" \
46+
-e "pkg <- tools::package_dependencies('$(PKG_NAME)', which = 'all', reverse = TRUE)" \
47+
-e "pkg <- as.character(unlist(pkg))" \
48+
-e "dep <- sapply(pkg, tools::package_dependencies, which = 'all')" \
49+
-e "dep <- as.character(unlist(dep))" \
50+
-e "if ('BiocInstaller' %in% dep) {" \
51+
-e " source('https://bioconductor.org/biocLite.R')" \
52+
-e " biocLite('BiocInstaller', lib = lib)" \
53+
-e "}" \
54+
-e "install.packages(pkg, lib = lib, dependencies = TRUE)" \
55+
-e "download.packages(pkg, destdir = 'revdep')"
56+
57+
# Check reverse dependencies with 'R CMD check'
58+
revdep_check:
59+
$(foreach var,$(wildcard revdep/*.tar.gz),R_LIBS=revdep/lib \
60+
_R_CHECK_CRAN_INCOMING_=FALSE R --vanilla CMD check --as-cran \
61+
--no-stop-on-test-error --output=revdep $(var) \
62+
| tee --append revdep/00revdep.log;)
63+
64+
# Collect results from checking reverse dependencies
65+
revdep_results:
66+
Rscript --vanilla \
67+
-e "options(repos = c(CRAN='https://cran.r-project.org'))" \
68+
-e "pkg <- tools::package_dependencies('$(PKG_NAME)', which = 'all', reverse = TRUE)" \
69+
-e "pkg <- as.character(unlist(pkg))" \
70+
-e "results <- do.call('rbind', lapply(pkg, function(x) {" \
71+
-e " filename <- paste0('revdep/', x, '.Rcheck/00check.log')" \
72+
-e " lines <- readLines(filename)" \
73+
-e " status <- sub('^Status: ', '', lines[grep('^Status: ', lines)])" \
74+
-e " data.frame(Package = x, Status = status)" \
75+
-e "}))" \
76+
-e "results <- results[order(results[, 'Status']), ]" \
77+
-e "rownames(results) <- NULL" \
78+
-e "cat('\n\n*** Results ***\n\n')" \
79+
-e "results" \
80+
-e "cat('\n\n')"
81+
3282
# Build and check package with gctorture
3383
check_gctorture:
3484
cd .. && R CMD build --no-build-vignettes $(PKG_NAME)
@@ -115,5 +165,8 @@ configure: configure.ac
115165

116166
clean:
117167
./cleanup
168+
-rm -rf revdep
118169

119-
.PHONY: all readme install roxygen sync_libgit2 Makevars check check_gctorture check_valgrind valgrind clean
170+
.PHONY: all readme install roxygen sync_libgit2 Makevars check check_gctorture \
171+
check_valgrind revdep revdep_install revdep_check revdep_results valgrind \
172+
clean

0 commit comments

Comments
 (0)