Skip to content

Commit f0fc8c5

Browse files
author
Keith Goldfeld
committed
Adding skip_on_cran() to all tests
1 parent c39275e commit f0fc8c5

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

tests/testthat/test-add_data.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# addCondition ----
22
test_that("addCondition throws errors.", {
3+
skip_on_cran()
34
expect_error(addCondition(), class = "simstudy::missingArgument")
45
expect_error(addCondition("a"), class = "simstudy::missingArgument")
56
expect_error(addCondition(data.frame(), data.frame(), "a"), class = "simstudy::wrongClass")
67
})
78

89
test_that("addCondition works.", {
10+
skip_on_cran()
911
def <- defData(varname = "x", formula = "1;10", dist = "uniformInt")
1012
defC <- defCondition(condition = "x >= 5", formula = "x + 5", dist = "nonrandom")
1113
defC <- defCondition(defC, condition = "x < 5", formula = "10", dist = "nonrandom")
@@ -20,12 +22,14 @@ test_that("addCondition works.", {
2022

2123
# addColumns ----
2224
test_that("addColumns throws errors.", {
25+
skip_on_cran()
2326
expect_error(addColumns(), class = "simstudy::missingArgument")
2427
expect_error(addColumns("a"), class = "simstudy::missingArgument")
2528
expect_error(addColumns(data.frame(), data.frame()), class = "simstudy::wrongClass")
2629
})
2730

2831
test_that("addColumns works.", {
32+
skip_on_cran()
2933
def <- defData(varname = "x", formula = "1;10", dist = "uniformInt")
3034
dt <- genData(100, def)
3135
def2 <- defDataAdd(varname = "y", formula = "2.3 * (1/x)", dist = "normal")
@@ -34,6 +38,7 @@ test_that("addColumns works.", {
3438
})
3539

3640
test_that("defRepeatAdd works", {
41+
skip_on_cran()
3742
expect_silent(
3843
defRepeatAdd(nVars = 4, prefix = "g", formula = "1/3;1/3;1/3", variance = 0, dist = "categorical")
3944
)
@@ -47,6 +52,7 @@ test_that("defRepeatAdd works", {
4752
})
4853

4954
test_that("defRepeatAdd throws errors correctly.", {
55+
skip_on_cran()
5056
expect_error(defRepeatAdd(prefix = "b", formula = 5, variance = 3, dist = "normal"),
5157
class = "simstudy::missingArgument"
5258
)
@@ -60,6 +66,7 @@ test_that("defRepeatAdd throws errors correctly.", {
6066

6167
# addMarkov ----
6268
test_that("addMarkov throws errors.", {
69+
skip_on_cran()
6370
d0 <- defData(varname = "xx", formula = 2)
6471
d0 <- defData(d0, varname = "xy", formula = 5)
6572
dd <- genData(n = 10, dt = d0)
@@ -94,6 +101,7 @@ test_that("addMarkov throws errors.", {
94101
# addSynthetic ----
95102

96103
test_that("addSynthetic throws errors.", {
104+
skip_on_cran()
97105

98106
### Create fake "real" data set
99107

@@ -125,6 +133,7 @@ test_that("addSynthetic throws errors.", {
125133
})
126134

127135
test_that("addSynthetic works.", {
136+
skip_on_cran()
128137

129138
### Create fake 'external' data set 'A'
130139

tests/testthat/test-conditions.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test_that("conditions have correct class.", {
2+
skip_on_cran()
23
expect_error(stop(condition(c("error", "custom_Error"), "This is a custom error")),
34
class = c("error", "custom_Error")
45
)
@@ -11,6 +12,7 @@ test_that("conditions have correct class.", {
1112
})
1213

1314
test_that("pluralization works.", {
15+
skip_on_cran()
1416
expect_error(argMissingError("arg1"), "argument is missing",
1517
class = "simstudy::missingArgument"
1618
)

tests/testthat/test-glue.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test_that("Blocks are collapsed as expected.", {
2+
skip_on_cran()
23
nums <- 1:3
34
num <- 23
45
expect_equal(
@@ -14,6 +15,7 @@ test_that("Blocks are collapsed as expected.", {
1415
})
1516

1617
test_that("numbers are formated as expected.", {
18+
skip_on_cran()
1719
nums <- c(1.23, 0.556, 1 / 3)
1820
ints <- c(1, 2, 3)
1921
expect_equal(glueFmt("{nums:.2f}"), as.character(round(nums, 2)))
@@ -22,6 +24,7 @@ test_that("numbers are formated as expected.", {
2224
})
2325

2426
test_that("numbers are collapsed and formated correctly.", {
27+
skip_on_cran()
2528
ints <- c(1, 2, 3)
2629
expect_equal(glueFmtC("{ints:02d}"), "01, 02 and 03")
2730
expect_equal(glueFmtC("{2:.1f}"), "2.0")

tests/testthat/test-group_data.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# .addStrataCode ----
22
test_that("strata codes are added as expected.", {
3+
skip_on_cran()
34
def <- defData(varname = "male", dist = "binary", formula = .5, id = "cid")
45
def <- defData(def, varname = "over65", dist = "binary", formula = "-1.7 + .8*male", link = "logit")
56
def <- defData(def, varname = "baseDBP", dist = "normal", formula = 70, variance = 40)
@@ -14,6 +15,7 @@ test_that("strata codes are added as expected.", {
1415

1516
# .stratSamp ----
1617
test_that("stratified samples are drawn correctly.", {
18+
skip_on_cran()
1719
expect_length(.stratSamp(1, 2), 1)
1820
expect_length(.stratSamp(2, 4), 2)
1921
expect_length(.stratSamp(50, 3), 50)

tests/testthat/test-internal_utility.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# .parseDotVars ----
22
test_that("dotVars are parsed correctly.", {
3+
skip_on_cran()
34
extVar1 <- 23
45
extVar2 <- 42
56
res <- list(..extVar1 = 23, ..extVar2 = 42)
@@ -12,6 +13,7 @@ test_that("dotVars are parsed correctly.", {
1213
})
1314

1415
test_that("variables from different environments are parsed correctly.", {
16+
skip_on_cran()
1517
extVar3 <- 7
1618
env1 <- new.env()
1719
env2 <- new.env(parent = env1)
@@ -27,6 +29,7 @@ test_that("variables from different environments are parsed correctly.", {
2729

2830
# .evalWith ----
2931
test_that("evalWith throws errors.", {
32+
skip_on_cran()
3033
df <- data.frame()
3134
ext <- list(formula2parse = 2)
3235

@@ -35,6 +38,7 @@ test_that("evalWith throws errors.", {
3538
})
3639

3740
test_that("evalWith output length is correct.", {
41+
skip_on_cran()
3842
df <- data.frame(a = rep.int(5, 5))
3943
ext <- list(..ev = 2)
4044

@@ -43,6 +47,7 @@ test_that("evalWith output length is correct.", {
4347
})
4448

4549
test_that("evalWith output is Matrix.", {
50+
skip_on_cran()
4651
df <- data.frame(a = rep.int(5, 5))
4752
ext <- list(..ev = 2)
4853

@@ -74,11 +79,13 @@ test_that("probabilities (matrix) are adjusted as documented.", {
7479

7580
# .getDists ----
7681
test_that("number of Dists is up to date.", {
82+
skip_on_cran()
7783
expect_length(.getDists(), 16)
7884
})
7985

8086
# .isFormulaScalar ----
8187
test_that("isFormularScalar works correctly.", {
88+
skip_on_cran()
8289
expect_true(.isFormulaScalar("5 + 3"))
8390
expect_true(.isFormulaScalar(5 + 3))
8491

@@ -89,6 +96,7 @@ test_that("isFormularScalar works correctly.", {
8996

9097
# .isValidVarName ----
9198
test_that("var names are validated correctly.", {
99+
skip_on_cran()
92100
validNames <- c("var1", "name", "name2", "var1")
93101
wrongNames <- c("...", "..1", "..5")
94102

@@ -103,6 +111,7 @@ test_that("var names are validated correctly.", {
103111

104112
# .isError ----
105113
test_that("errors are detected correctly.", {
114+
skip_on_cran()
106115
err <- try(nonVar + 4, silent = TRUE)
107116
noErr <- try(3 + 5, silent = TRUE)
108117

@@ -114,6 +123,7 @@ test_that("errors are detected correctly.", {
114123

115124
# .hasValue ----
116125
test_that("hasValue works.", {
126+
skip_on_cran()
117127
expect_true(.hasValue("value"))
118128
expect_true((function(x) .hasValue(x))(5))
119129
expect_true((function(x) .hasValue(x))(NA))
@@ -125,6 +135,7 @@ test_that("hasValue works.", {
125135

126136
# .log2Prob ----
127137
test_that("log odds are converted correctly.", {
138+
skip_on_cran()
128139
prob <- 0.2
129140
logOdds <- log(0.25)
130141

tests/testthat/test-survival.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
test_that("defSurv kicks out transition error", {
2+
skip_on_cran()
23
expect_error(defSurv(varname = "censor", formula = "-7", shape = 0.55, transition = 150))
34
})
45

56
test_that("genSurv runs OK", {
7+
skip_on_cran()
68
dS <- defSurv(varname = "event_1", formula = "-10", shape = 0.3)
79
dS <- defSurv(dS, "event_2", "-6.5", shape = 0.4)
810
dS <- defSurv(dS, "event_3", "-7", shape = 0.5)
@@ -28,6 +30,7 @@ test_that("genSurv runs OK", {
2830
})
2931

3032
test_that("genSurv throws errors", {
33+
skip_on_cran()
3134
dS <- defSurv(varname = "event_1", formula = "-10", shape = 0.3)
3235
dS <- defSurv(dS, "event_2", "-6.5", shape = 0.4)
3336
dS <- defSurv(dS, "event_3", "-7", shape = 0.5)
@@ -38,6 +41,7 @@ test_that("genSurv throws errors", {
3841
})
3942

4043
test_that("addCmpRisk works", {
44+
skip_on_cran()
4145
dS <- defSurv(varname = "event_1", formula = "-10", shape = 0.3)
4246
dS <- defSurv(dS, "event_2", "-6.5", shape = 0.4)
4347

tests/testthat/test-utility.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ test_that("probabilities (vector) are adjusted as documented.", {
4444
})
4545

4646
test_that("genCatFormula throws errors.", {
47+
skip_on_cran()
4748
expect_error(genCatFormula(), "Need to specify")
4849
expect_error(genCatFormula(1, 2, 3, n = 5), "or n, not both")
4950
expect_error(genCatFormula(1.1), "must be less than 1")
@@ -53,16 +54,19 @@ test_that("genCatFormula throws errors.", {
5354

5455
# betaGetShapes ----
5556
test_that("betaGetShapes throws errors.", {
57+
skip_on_cran()
5658
expect_error(betaGetShapes(1, 12), class = "simstudy::valueError")
5759
expect_error(betaGetShapes(.5, -5), class = "simstudy::valueError")
5860
})
5961

6062
test_that("betaGetShapes works.", {
63+
skip_on_cran()
6164
expect_equal(betaGetShapes(.4, 5), list(shape1 = .4 * 5, shape2 = (1 - .4) * 5))
6265
})
6366

6467
# genMixFormula ----
6568
test_that("genMixFormula throws errors.", {
69+
skip_on_cran()
6670
expect_error(genMixFormula(), class = "simstudy::missingArgument")
6771
expect_error(genMixFormula("a", varLength = 3), class = "simstudy::valueError")
6872
expect_error(genMixFormula("..a", varLength = "b"), class = "simstudy::wrongType")
@@ -72,6 +76,7 @@ test_that("genMixFormula throws errors.", {
7276
})
7377

7478
test_that("genMixFormula works.", {
79+
skip_on_cran()
7580
expect_equal(genMixFormula("a"), "a | 1")
7681
expect_equal(genMixFormula(c("a", "..b"), c(.3, .7)), "a | 0.3 + ..b | 0.7")
7782
expect_equal(
@@ -83,6 +88,7 @@ test_that("genMixFormula works.", {
8388
# survGetParams ----
8489

8590
test_that("survGetParams throws errors.", {
91+
skip_on_cran()
8692
expect_error(survGetParams(), class = "simstudy::missingArgument")
8793
expect_error(survGetParams(c(100, .5)), class = "simstudy::wrongClass")
8894
points <- list(c(280, 0.85), c(165, .45))
@@ -96,6 +102,7 @@ test_that("survGetParams throws errors.", {
96102
})
97103

98104
test_that("survGetParam works.", {
105+
skip_on_cran()
99106
points <- list(c(50, 0.90), c(100, 0.10))
100107
expect_equal(survGetParams(points), c(-19.658, 0.225), tolerance = .001)
101108
points <- list(c(60, 0.90), c(100, .75), c(200, .25), c(250, .10))
@@ -105,12 +112,14 @@ test_that("survGetParam works.", {
105112
# plotSurv ----
106113

107114
test_that("survParamPlot throws errors.", {
115+
skip_on_cran()
108116
expect_error(survParamPlot(), class = "simstudy::missingArgument")
109117
expect_error(survParamPlot(formula = -10), class = "simstudy::missingArgument")
110118
expect_error(survParamPlot(formula = 4, shape = -1), class = "simstudy::wrongSign")
111119
})
112120

113121
test_that("survParamPlot works.", {
122+
skip_on_cran()
114123
expect_is(survParamPlot(formula = -4, shape = 1), class = "ggplot")
115124

116125
points <- list(c(100, .8), c(200, .5))

0 commit comments

Comments
 (0)