Skip to content

Commit d2339ad

Browse files
skip 8 tests about roots on CRAN since using something else than current working directory is rare and change in R or dependencies that would break the functionality very unlikely
1 parent 4ae940a commit d2339ad

File tree

4 files changed

+114
-107
lines changed

4 files changed

+114
-107
lines changed

tests/testthat/test-hook-codemeta-description-updated.R

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,44 @@ run_test("codemeta-description-update",
4545
}
4646
)
4747

48-
# succeed in correct root
49-
run_test("codemeta-description-update",
50-
file_name = c(
51-
"rpkg/DESCRIPTION" = "DESCRIPTION",
52-
"rpkg/codemeta.json" = "codemeta.json"
53-
),
54-
cmd_args = "--root=rpkg",
55-
suffix = "",
56-
file_transformer = function(files) {
57-
if (length(files) > 1) {
58-
# transformer is called once on all files and once per file
59-
content_2 <- readLines(files[2])
60-
Sys.sleep(2)
61-
writeLines(content_2, files[2])
48+
if (!on_cran()) {
49+
# succeed in correct root
50+
run_test("codemeta-description-update",
51+
file_name = c(
52+
"rpkg/DESCRIPTION" = "DESCRIPTION",
53+
"rpkg/codemeta.json" = "codemeta.json"
54+
),
55+
cmd_args = "--root=rpkg",
56+
suffix = "",
57+
file_transformer = function(files) {
58+
if (length(files) > 1) {
59+
# transformer is called once on all files and once per file
60+
content_2 <- readLines(files[2])
61+
Sys.sleep(2)
62+
writeLines(content_2, files[2])
63+
}
64+
files
6265
}
63-
files
64-
}
65-
)
66+
)
6667

67-
# # fail in wrong root
68-
run_test("codemeta-description-update",
69-
file_name = c(
70-
"rpkg/DESCRIPTION" = "DESCRIPTION",
71-
"rpkg/codemeta.json" = "codemeta.json",
72-
"rpkg2/codemeta.json" = "README.md"
73-
),
74-
cmd_args = "--root=rpkg2",
75-
std_err = "No `DESCRIPTION` found in repository.",
76-
suffix = "",
77-
file_transformer = function(files) {
78-
if (length(files) > 1) {
79-
# transformer is called once on all files and once per file
80-
content_2 <- readLines(files[2])
81-
Sys.sleep(2)
82-
writeLines(content_2, files[2])
68+
# # fail in wrong root
69+
run_test("codemeta-description-update",
70+
file_name = c(
71+
"rpkg/DESCRIPTION" = "DESCRIPTION",
72+
"rpkg/codemeta.json" = "codemeta.json",
73+
"rpkg2/codemeta.json" = "README.md"
74+
),
75+
cmd_args = "--root=rpkg2",
76+
std_err = "No `DESCRIPTION` found in repository.",
77+
suffix = "",
78+
file_transformer = function(files) {
79+
if (length(files) > 1) {
80+
# transformer is called once on all files and once per file
81+
content_2 <- readLines(files[2])
82+
Sys.sleep(2)
83+
writeLines(content_2, files[2])
84+
}
85+
files
8386
}
84-
files
85-
}
86-
)
87+
)
88+
}

tests/testthat/test-hook-deps-in-desc-R.R

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,26 @@ run_test("deps-in-desc",
2020
)
2121

2222
# in sub directory with correct root
23-
run_test("deps-in-desc",
24-
cmd_args = "--root=rpkg",
25-
suffix = "-fail.R", std_err = "Dependency check failed",
26-
file_transformer = function(files) {
27-
fs::path_abs(fs::file_move(files, "rpkg"))
28-
},
29-
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
30-
)
23+
if (!on_cran()) {
24+
run_test("deps-in-desc",
25+
cmd_args = "--root=rpkg",
26+
suffix = "-fail.R", std_err = "Dependency check failed",
27+
file_transformer = function(files) {
28+
fs::path_abs(fs::file_move(files, "rpkg"))
29+
},
30+
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
31+
)
32+
# in sub directory with correct root
33+
run_test("deps-in-desc",
34+
cmd_args = "--root=rpkg",
35+
suffix = "-success.R", std_err = NULL,
36+
file_transformer = function(files) {
37+
fs::path_abs(fs::file_move(files, "rpkg"))
38+
},
39+
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
40+
)
41+
}
3142

32-
# in sub directory with correct root
33-
run_test("deps-in-desc",
34-
cmd_args = "--root=rpkg",
35-
suffix = "-success.R", std_err = NULL,
36-
file_transformer = function(files) {
37-
fs::path_abs(fs::file_move(files, "rpkg"))
38-
},
39-
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
40-
)
4143

4244
# with :::
4345
run_test("deps-in-desc",

tests/testthat/test-hook-roxygenize.R

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,47 @@ run_test("roxygenize",
1717
}
1818
)
1919

20-
# with outdated Rd present in correct root
21-
run_test("roxygenize",
22-
file_name = c("rpkg/man/flie.Rd" = "flie.Rd"),
23-
suffix = "",
24-
std_err = NA,
25-
cmd_args = "--root=rpkg",
26-
std_out = "Writing NAMESPACE",
27-
artifacts = c(
28-
"rpkg/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
29-
"rpkg/R/roxygenize.R" = test_path("in/roxygenize.R")
30-
),
31-
file_transformer = function(files) {
32-
withr::local_dir("rpkg")
33-
git_init()
34-
git2r::add(path = files)
35-
# hack to add artifact to trigger diff_requires_roxygenize()
36-
git2r::add(path = fs::path(fs::path_dir(fs::path_dir(files[1])), "R"))
37-
files
38-
}
39-
)
20+
if (!on_cran()) {
21+
# with outdated Rd present in correct root
22+
run_test("roxygenize",
23+
file_name = c("rpkg/man/flie.Rd" = "flie.Rd"),
24+
suffix = "",
25+
std_err = NA,
26+
cmd_args = "--root=rpkg",
27+
std_out = "Writing NAMESPACE",
28+
artifacts = c(
29+
"rpkg/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
30+
"rpkg/R/roxygenize.R" = test_path("in/roxygenize.R")
31+
),
32+
file_transformer = function(files) {
33+
withr::local_dir("rpkg")
34+
git_init()
35+
git2r::add(path = files)
36+
# hack to add artifact to trigger diff_requires_roxygenize()
37+
git2r::add(path = fs::path(fs::path_dir(fs::path_dir(files[1])), "R"))
38+
files
39+
}
40+
)
41+
# without Rd present
42+
run_test("roxygenize",
43+
file_name = c("rpkg1/R/roxygenize.R" = "roxygenize.R"),
44+
suffix = "",
45+
cmd_args = "--root=rpkg1",
46+
std_err = "Please commit the new `.Rd` files",
47+
artifacts = c(
48+
"rpkg1/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
49+
"rpkg2/R/roxygenize.R" = test_path("in/roxygenize.R")
50+
),
51+
file_transformer = function(files) {
52+
withr::local_dir("rpkg1")
53+
git_init()
54+
git2r::add(path = files)
55+
files
56+
}
57+
)
58+
}
4059

4160

42-
# without Rd present
43-
run_test("roxygenize",
44-
file_name = c("rpkg1/R/roxygenize.R" = "roxygenize.R"),
45-
suffix = "",
46-
cmd_args = "--root=rpkg1",
47-
std_err = "Please commit the new `.Rd` files",
48-
artifacts = c(
49-
"rpkg1/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
50-
"rpkg2/R/roxygenize.R" = test_path("in/roxygenize.R")
51-
),
52-
file_transformer = function(files) {
53-
withr::local_dir("rpkg1")
54-
git_init()
55-
git2r::add(path = files)
56-
files
57-
}
58-
)
5961

6062
# with Rd present in wrong root
6163
run_test("roxygenize",
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# success
22
run_test("use-tidy-description", "DESCRIPTION", suffix = "")
33

4-
# in sub directory with correct root
5-
run_test("use-tidy-description",
6-
"DESCRIPTION",
7-
suffix = "",
8-
cmd_args = "--root=rpkg",
9-
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
10-
)
114

125

13-
14-
# in sub directory with incorrect root
15-
# Need to generate the directoy `rpkg` but without DESCRIPTION file.
16-
run_test("use-tidy-description",
17-
"DESCRIPTION",
18-
suffix = "",
19-
cmd_args = "--root=rpkg",
20-
std_err = "No `DESCRIPTION` found in repository.",
21-
artifacts = c("rpkg/README.md" = test_path("in/README.md"))
22-
)
6+
if (!on_cran()) {
7+
# in sub directory with correct root
8+
run_test("use-tidy-description",
9+
"DESCRIPTION",
10+
suffix = "",
11+
cmd_args = "--root=rpkg",
12+
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
13+
)
14+
# in sub directory with incorrect root
15+
# Need to generate the directoy `rpkg` but without DESCRIPTION file.
16+
run_test("use-tidy-description",
17+
"DESCRIPTION",
18+
suffix = "",
19+
cmd_args = "--root=rpkg",
20+
std_err = "No `DESCRIPTION` found in repository.",
21+
artifacts = c("rpkg/README.md" = test_path("in/README.md"))
22+
)
23+
}

0 commit comments

Comments
 (0)