File: source.md

package info (click to toggle)
r-cran-testthat 3.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,048 kB
  • sloc: cpp: 9,269; sh: 14; ansic: 14; makefile: 5
file content (58 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# source_file wraps error

    Code
      source_file(test_path("reporters/error-setup.R"), wrap = FALSE)
    Condition
      Error:
      ! Failed to evaluate 'reporters/error-setup.R'.
      Caused by error in `h()`:
      ! !

# checks its inputs

    Code
      source_file(1)
    Condition
      Error:
      ! `path` must be a single string, not the number 1.
    Code
      source_file("x")
    Condition
      Error:
      ! `path` does not exist.
    Code
      source_file(".", "x")
    Condition
      Error:
      ! `env` must be an environment, not the string "x".

# works on code like the describe() example

    Code
      filter_desc(code, c("math library", "division()", "can handle division by 0"))
    Condition
      Error:
      ! Failed to find test with description "can handle division by 0".

# preserve srcrefs

    Code
      filter_desc(code, "foo")
    Output
      expression(test_that("foo", {
            # this is a comment
          }))

# errors if zero or duplicate labels

    Code
      filter_desc(code, "baz")
    Condition
      Error:
      ! Found multiple tests with description "baz".
    Code
      filter_desc(code, "missing")
    Condition
      Error:
      ! Failed to find test with description "missing".