|
1 | 1 | context('Utility functions') |
2 | 2 |
|
3 | 3 | test_that('stale_package_check works', { |
4 | | - script_dir = 'stale_package_test_scripts' |
| 4 | + stale_package_path <- function(path) test_path('stale_package_test_scripts', path) |
| 5 | + |
5 | 6 | expect_output( |
6 | | - stale_package_check(file.path(script_dir, 'simple.R')), |
| 7 | + stale_package_check(stale_package_path('simple.R')), |
7 | 8 | paste( |
8 | | - c("Functions matched from package stats:", "\tdensity, rnorm", |
9 | | - "Functions matched from package tools:", "\tfile_ext", |
| 9 | + c("Functions matched from package stats:", |
| 10 | + paste0("\t", toString(sort(c("density", "rnorm")))), |
| 11 | + "Functions matched from package tools:", |
| 12 | + "\tfile_ext", |
10 | 13 | "**No exported functions matched from tcltk**"), |
11 | 14 | collapse = '\n' |
12 | 15 | ), |
13 | 16 | fixed = TRUE |
14 | 17 | ) |
15 | 18 |
|
16 | 19 | expect_output( |
17 | | - stale_package_check(file.path(script_dir, 'use_namespace_call.R')), |
| 20 | + stale_package_check(stale_package_path('use_namespace_call.R')), |
18 | 21 | '**No exported functions matched from stats**', |
19 | 22 | fixed = TRUE |
20 | 23 | ) |
21 | 24 |
|
22 | 25 | expect_output( |
23 | | - stale_package_check(file.path(script_dir, 'wont-parse.R')), |
| 26 | + stale_package_check(stale_package_path('wont_parse.R')), |
24 | 27 | 'Failed to parse R script, please fix syntax errors first', |
25 | 28 | fixed = TRUE |
26 | 29 | ) |
27 | 30 |
|
28 | 31 | expect_output( |
29 | | - stale_package_check(file.path(script_dir, 'no_library.R')), |
| 32 | + stale_package_check(stale_package_path('no_library.R')), |
30 | 33 | 'No library() or require() calls found', |
31 | 34 | fixed = TRUE |
32 | 35 | ) |
|
0 commit comments