Skip to content

Commit

Permalink
Merge branch 'main' into dir
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored May 19, 2023
2 parents d385a9e + 34b8ba7 commit 51a2994
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
^LICENSE\.md$
^readme$
^README\.Rmd$
^README\.md$
^\.github$
^_pkgdown\.yml$
^docs$
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lazytest
Title: Runs Only Failed Tests
Version: 0.0.0.9026
Version: 0.0.0.9030
Authors@R: c(
person("Kirill", "Müller", , "kirill@cynkra.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-1416-3412")),
Expand Down
24 changes: 24 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->

# lazytest 0.0.0.9030 (2023-05-19)

- Internal changes only.


# lazytest 0.0.0.9029 (2023-05-18)

- Internal changes only.


# lazytest 0.0.0.9028 (2023-05-17)

- Internal changes only.


# lazytest 0.0.0.9027 (2023-05-16)

## Documentation

- Add .lazytest guidance (@maelle, #12, #23).

- Add workaround for not having to quote testthat (@maelle, #21).


# lazytest 0.0.0.9026 (2023-05-15)

- Internal changes only.
Expand Down
2 changes: 2 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ In the next call, if `.lazytest` exists, it is consulted, and a suitable `filter

When all tests have passed and not all tests were run, a second call to `testthat::test_local()` is initiated, to make sure that no failures have been introduced in the meantime.

The presence of a `.lazytest` file in the package source indicates that the last test run has failed somewhere.
You should not need to gitignore or Rbuildignore it: you should fix the reason behind the test failure, then run tests again, before committing to your repository's default branch for instance.

## Installation and optional setup

Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<pre class='chroma'>
<span><span class='kr'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='o'>(</span><span class='nv'><a href='https://github.com/cynkra/lazytest'>lazytest</a></span><span class='o'>)</span></span></pre>

The goal of lazytest is to save development time by helping you rerun only the tests that have failed during the last run. It integrates tightly with the testthat package and provides the [`lazytest_local()`](https://cynkra.github.io/lazytest/reference/lazytest_local.html) function, a drop-in replacement for [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html), that
The goal of lazytest is to save development time by helping you rerun only the tests that have failed during the last run. It integrates tightly with the testthat package and provides the [`lazytest_local()`](https://lazytest.cynkra.com/reference/lazytest_local.html) function, a drop-in replacement for [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html), that

- memoizes which tests have failed;
- runs only those tests in subsequent runs.
Expand All @@ -20,10 +20,10 @@ If all active tests have succeeded, the entire test suite is run in a second pas

## Usage

Call [`lazytest_local()`](https://cynkra.github.io/lazytest/reference/lazytest_local.html) instead of [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html) or [`devtools::test()`](https://devtools.r-lib.org/reference/test.html):
Call [`lazytest_local()`](https://lazytest.cynkra.com/reference/lazytest_local.html) instead of [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html) or [`devtools::test()`](https://devtools.r-lib.org/reference/test.html):

<pre class='chroma'>
<span><span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://cynkra.github.io/lazytest/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span></pre>
<span><span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://lazytest.cynkra.com/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span></pre>

The package also provides RStudio add-ins that run the tests in a new terminal. Unfortunately, the “Test package” command is hard-wired to [`devtools::test()`](https://devtools.r-lib.org/reference/test.html), and there seems to be no way to customize it or hook into it.

Expand All @@ -48,7 +48,7 @@ If we run the tests, they all pass.
<pre class='chroma'>
<span><span class='nf'>withr</span><span class='nf'>::</span><span class='nf'><a href='https://withr.r-lib.org/reference/with_dir.html'>with_dir</a></span><span class='o'>(</span></span>
<span> <span class='nv'>pkg_dir</span>,</span>
<span> <span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://cynkra.github.io/lazytest/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span>
<span> <span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://lazytest.cynkra.com/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span>
<span><span class='o'>)</span></span>
<span><span class='c'>#&gt; <span style='color: #00BBBB;'>ℹ</span> Testing all tests.</span></span>
<span><span class='c'>#&gt; <span style='color: #00BB00;'>✔</span> | <span style='color: #BBBB00;'>F</span> <span style='color: #BB00BB;'>W</span> <span style='color: #0000BB;'>S</span> <span style='color: #00BB00;'> OK</span> | Context</span></span>
Expand Down Expand Up @@ -76,7 +76,7 @@ and then run the tests,
<pre class='chroma'>
<span><span class='nf'>withr</span><span class='nf'>::</span><span class='nf'><a href='https://withr.r-lib.org/reference/with_dir.html'>with_dir</a></span><span class='o'>(</span></span>
<span> <span class='nv'>pkg_dir</span>,</span>
<span> <span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://cynkra.github.io/lazytest/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span>
<span> <span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://lazytest.cynkra.com/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span>
<span><span class='o'>)</span></span>
<span><span class='c'>#&gt; <span style='color: #00BBBB;'>ℹ</span> Testing all tests.</span></span>
<span><span class='c'>#&gt; <span style='color: #00BB00;'>✔</span> | <span style='color: #BBBB00;'>F</span> <span style='color: #BB00BB;'>W</span> <span style='color: #0000BB;'>S</span> <span style='color: #00BB00;'> OK</span> | Context</span></span>
Expand Down Expand Up @@ -109,7 +109,7 @@ Next time we run the tests, only this test will be run, until it is fixed at whi
<pre class='chroma'>
<span><span class='nf'>withr</span><span class='nf'>::</span><span class='nf'><a href='https://withr.r-lib.org/reference/with_dir.html'>with_dir</a></span><span class='o'>(</span></span>
<span> <span class='nv'>pkg_dir</span>,</span>
<span> <span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://cynkra.github.io/lazytest/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span>
<span> <span class='nf'>lazytest</span><span class='nf'>::</span><span class='nf'><a href='https://lazytest.cynkra.com/reference/lazytest_local.html'>lazytest_local</a></span><span class='o'>(</span><span class='o'>)</span></span>
<span><span class='o'>)</span></span>
<span><span class='c'>#&gt; <span style='color: #00BBBB;'>ℹ</span> Testing only tests that failed last time:</span></span>
<span><span class='c'>#&gt; <span style='color: #00BBBB;'>•</span> blop</span></span>
Expand All @@ -130,10 +130,12 @@ Next time we run the tests, only this test will be run, until it is fixed at whi

## How does it work?

[`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html) returns an object from which the tests that have failed can be retrieved. [`lazytest_local()`](https://cynkra.github.io/lazytest/reference/lazytest_local.html) wraps this function. If tests have failed, a file named `.lazytest` is written in the package directory. In the next call, if `.lazytest` exists, it is consulted, and a suitable `filter` argument is constructed and passed to [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html).
[`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html) returns an object from which the tests that have failed can be retrieved. [`lazytest_local()`](https://lazytest.cynkra.com/reference/lazytest_local.html) wraps this function. If tests have failed, a file named `.lazytest` is written in the package directory. In the next call, if `.lazytest` exists, it is consulted, and a suitable `filter` argument is constructed and passed to [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html).

When all tests have passed and not all tests were run, a second call to [`testthat::test_local()`](https://testthat.r-lib.org/reference/test_package.html) is initiated, to make sure that no failures have been introduced in the meantime.

The presence of a `.lazytest` file in the package source indicates that the last test run has failed somewhere. You should not need to gitignore or Rbuildignore it: you should fix the reason behind the test failure, then run tests again, before committing to your repository’s default branch for instance.

## Installation and optional setup

You can install the development version of lazytest from [cynkra R-universe](https://cynkra.r-universe.dev/):
Expand Down
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
url: https://lazytest.cynkra.com/

template:
package: cynkratemplate
12 changes: 4 additions & 8 deletions man/lazytest_local.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/rmd/lazytest_local.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Let's create a package with two boilerplate tests.

```{r}
withr::local_seed(42)
withr::local_options(usethis.quiet = TRUE)
pkg_parent_dir <- withr::local_tempdir()
Expand Down

0 comments on commit 51a2994

Please sign in to comment.