{"id":19610109,"url":"https://github.com/nfultz/chad","last_synced_at":"2025-04-27T21:31:26.109Z","repository":{"id":28118421,"uuid":"31617355","full_name":"nfultz/chad","owner":"nfultz","description":"An R package for lightweight acceptance testing","archived":false,"fork":false,"pushed_at":"2015-12-23T17:18:45.000Z","size":30,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T13:50:49.822Z","etag":null,"topics":["acceptance-testing","r"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"reshape/include","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nfultz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-03T19:39:20.000Z","updated_at":"2021-03-16T15:26:40.000Z","dependencies_parsed_at":"2022-08-02T10:59:15.377Z","dependency_job_id":null,"html_url":"https://github.com/nfultz/chad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfultz%2Fchad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfultz%2Fchad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfultz%2Fchad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfultz%2Fchad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfultz","download_url":"https://codeload.github.com/nfultz/chad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224085922,"owners_count":17253301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acceptance-testing","r"],"created_at":"2024-11-11T10:26:51.970Z","updated_at":"2024-11-11T10:26:52.876Z","avatar_url":"https://github.com/nfultz.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chad - A lightweight acceptance test framework\n\nThis provides a way to run acceptance tests for/from R, along with some scripting glue for updating them.\n\n*Goal*: Never waste time writing `assert()`s again.\n\nUnit tests are great for developers, but a time sink for data scientists.\n\n## How it works\n\nThe `chad` function tests itself for idempotency:\n\n    f(f(x)) = f(x)\n    \nwhere f is chad and x is your R code. By substitution, we also have\n\n    f(u) = u \n    \nwhere `u` is a chad script: a combination of code and output. \n\nAny chad script where that does not hold is automatically \nconsidered a test failure.\n\nSide note: When `f` is a computer and `u` a program and the above holds, `u` is a *quine*. \nSee _Godel, Escher, Bach_ for a deep dive on quines.\n \n## Requirements\n\nIn addition to R, this package needs a `diff` program on the search path. On Windows, you may need to install Rtools.\nFor a nicer experience, you can use `git` and `colordiff` instead.\n \n\n## Example\n\nChad scripts are basically R output from the console. Here is `anova.chad`:\n\n    \u003e anova(lm(extra~., sleep))\n    Analysis of Variance Table\n    \n    Response: extra\n              Df Sum Sq    Mean Sq  F value    Pr(\u003eF)   \n    group      1 10.482 12.4820000 16.50088 0.0028329 **\n    ID         9 58.078  6.4531111  8.53085 0.0019014 **\n    Residuals  9  6.808  0.7564444                      \n    ---\n    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nWhen we run it with `chad('anova.chad')`, ir reruns the code and generates any output. If any of\nit had changed, it would display it in standard diff notation:\n\n    \u003e chad('inst/tests/chad/sleep.chad')\n    Chadding\tsleep.chad\t...\t\n    --- sleep.chad\t2015-12-22 16:08:50.886015712 -0800\n    +++ sleep.chad.out\t2015-12-22 16:09:13.942504368 -0800\n    @@ -6,7 +6,7 @@\n     \n     Response: extra\n               Df Sum Sq    Mean Sq  F value    Pr(\u003eF)   \n    -group      1 10.482 12.4820000 16.50088 0.0028329 **\n    +group      1 12.482 12.4820000 16.50088 0.0028329 **\n     ID         9 58.078  6.4531111  8.53085 0.0019014 **\n     Residuals  9  6.808  0.7564444                      \n     ---\n    \nThe + and minus signs indicated the lines that have changed. Here, a 10.482 has\nchanged to a 12.482. If this was an expected change (perhaps the data set was updated or\na bug was fixed), we could update the test at the AAG prompt:\n\n    Difference in output; accept as golden? [y/n/git]\n\nChoosing y will update the test to the newer output. The git option will \nadditionally commit the change. Because chad scripts are \nhuman readable text, they play nicely with VCSs.\n\nAdditionally, you can chad an entire directory with `chadRecur()`:\n    \n    \u003e chadRecur('.')\n    Chadding  error.chad\t...\tFAIL\n    Chadding\texample.chad\t...\tSUCCESS\n              file status  time\n    1   error.chad      1 0.017\n    2 example.chad      0 0.026\n\nFollowing UNIX tradition status 0 is a pass, anything else is a failure.\n    \n## Package Development\n\nTo use chad scripts for package testing, run\n\n    useChad()\n    \nfrom the package root. A test stub and example test will be copied to the 'tests/' folder.    \n\n\n## Chad Notebooks\n\nValid chad scripts are by definition reproducible research and are easy to share. \n\nBy setting the MIME type of `.chad` files to `text/html` , we can have a web browser render any html content a chad script contains.\n\nIt looks better if you start the file with a code tag to style the rest of the document and break lines correctly:\n\n    \u003e# Example Notebook \u003cpre\u003e\u003ccode\u003e\n\nYou can use the `chadPlot()` to inline images:\n\n    \u003epng(); barplot(1:10); chadPlot()\n    \u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAAN...uQmCC\"/\u003e\n\n\n## Differences from R CMD check\n\nR has related testing mechanism based around `R CMD check` output. \n\n  * check requires two files: .R (code) and  .Rout.save (output); they can easily get out of sync while developing.\n  * Each check test runs in it's own Rsession. This is 'safer' but slower, and no setup/teardown can be shared between tests.\n  * check has to hack around the MOTD headers R emits when it is started.\n  * check runs R, chad runs inside R\n  * check is part of base,  chad is an add-on package.\n  \n\n###Dedicated to Chad Whipkey.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfultz%2Fchad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfultz%2Fchad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfultz%2Fchad/lists"}