{"id":3543416,"name":"github.com/rogpeppe/testscript","ecosystem":"go","description":"Package testscript provides support for defining filesystem-based tests by\ncreating scripts in a directory.\n\nTo invoke the tests, call testscript.Run. For example:\n\nA testscript directory holds test scripts *.txt run during 'go test'.\nEach script defines a subtest; the exact set of allowable commands in a\nscript are defined by the parameters passed to the Run function.\nTo run a specific script foo.txt\n\nwhere TestName is the name of the test that Run is called from.\n\nTo define an executable command (or several) that can be run as part of the script,\ncall RunMain with the functions that implement the command's functionality.\nThe command functions will be called in a separate process, so are\nfree to mutate global variables without polluting the top level test binary.\n\nIn general script files should have short names: a few words, not whole sentences.\nThe first word should be the general category of behavior being tested,\noften the name of a subcommand to be tested or a concept (vendor, pattern).\n\nEach script is a text archive (go doc github.com/rogpeppe/testscript//txtar).\nThe script begins with an actual command script to run\nfollowed by the content of zero or more supporting files to\ncreate in the script's temporary file system before it starts executing.\n\nAs an example:\n\nEach script runs in a fresh temporary work directory tree, available to scripts as $WORK.\nScripts also have access to these other environment variables:\n\nThe environment variable $exe (lowercase) is an empty string on most\nsystems, \".exe\" on Windows.\n\nThe script's supporting files are unpacked relative to $WORK\nand then the script begins execution in that\ndirectory as well. Thus the example above runs in $WORK\nwith $WORK/hello.txt containing the listed contents.\n\nThe lines at the top of the script are a sequence of commands to be\nexecuted by a small script engine in the testscript package (not the system\nshell).  The script stops and the overall test fails if any particular\ncommand fails.\n\nEach line is parsed into a sequence of space-separated command words,\nwith environment variable expansion and # marking an end-of-line comment.\nAdding single quotes around text keeps spaces in that text from being\ntreated as word separators and also disables environment variable\nexpansion.  Inside a single-quoted block of text, a repeated single\nquote indicates a literal single quote, as in:\n\nA line beginning with # is a comment and conventionally explains what is\nbeing done or tested at the start of a new phase in the script.\n\nA special form of environment variable syntax can be used to quote\nregexp metacharacters inside environment variables. The \"@R\" suffix\nis special, and indicates that the variable should be quoted.\n\nThe command prefix ! indicates that the command on the rest of the line\n(typically go or a matching predicate) must fail, not succeed. Only certain\ncommands support this prefix. They are indicated below by [!] in the synopsis.\n\nThe command prefix [cond] indicates that the command on the rest of the line\nshould only run when the condition is satisfied. The predefined conditions are:\n\nA condition can be negated: [!short] means to run the rest of the line\nwhen testing.Short() is false.\n\nAdditional conditions can be added by passing a function to Params.Condition.\n\nThe predefined commands are:\n\n- chmod mode file\n\n[!] exec program [args...] [\u0026]\nRun the given executable program with the arguments.\nIt must (or must not) succeed.\nNote that 'exec' does not terminate the script (unlike in Unix shells).\n\nIf the last token is '\u0026', the program executes in the background. The standard\noutput and standard error of the previous command is cleared, but the output\nof the background process is buffered — and checking of its exit status is\ndelayed — until the next call to 'wait', 'skip', or 'stop' or the end of the\ntest. At the end of the test, any remaining background processes are\nterminated using os.Interrupt (if supported) or os.Kill.\n\nStandard input can be provided using the stdin command; this will be\ncleared after exec has been called.\n\nWhen TestScript runs a script and the script fails, by default TestScript shows\nthe execution of the most recent phase of the script (since the last # comment)\nand only shows the # comments for earlier phases. For example, here is a\nmulti-phase script with a bug in it (TODO: make this example less go-command\nspecific):\n\nThe bug is that the final phase installs p11 instead of p1. The test failure looks like:\n\nNote that the commands in earlier phases have been hidden, so that the relevant\ncommands are more easily found, and the elapsed time for a completed phase\nis shown next to the phase heading. To see the entire execution, use \"go test -v\",\nwhich also adds an initial environment dump to the beginning of the log.\n\nNote also that in reported output, the actual name of the per-script temporary directory\nhas been consistently replaced with the literal string $WORK.\n\nIf Params.TestWork is true, it causes each test to log the name of its $WORK directory and other\nenvironment variable settings and also to leave that directory behind when it exits,\nfor manual debugging of failing tests:","homepage":"https://github.com/rogpeppe/testscript","licenses":"BSD-3-Clause","normalized_licenses":["BSD-3-Clause"],"repository_url":"https://github.com/rogpeppe/testscript","keywords_array":[],"namespace":"github.com/rogpeppe","versions_count":2,"first_release_published_at":"2019-09-29T16:56:35.000Z","latest_release_published_at":"2019-09-30T13:22:14.000Z","latest_release_number":"v1.1.0","last_synced_at":"2026-04-16T17:32:30.381Z","created_at":"2022-04-11T00:32:38.639Z","updated_at":"2026-04-16T17:32:30.382Z","registry_url":"https://pkg.go.dev/github.com/rogpeppe/testscript","install_command":"go get github.com/rogpeppe/testscript","documentation_url":"https://pkg.go.dev/github.com/rogpeppe/testscript#section-documentation","metadata":{},"repo_metadata":{"uuid":"211693163","full_name":"rogpeppe/testscript","owner":"rogpeppe","description":"A fork of rogpeppe/go-internal/testscript with less dependencies","archived":false,"fork":false,"pushed_at":"2020-05-21T06:23:48.000Z","size":240,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-17T12:32:10.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"logo_url":null,"metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-29T16:37:23.000Z","updated_at":"2022-11-24T12:09:52.000Z","dependencies_parsed_at":"2022-08-28T15:20:42.523Z","dependency_job_id":null,"html_url":"https://github.com/rogpeppe/testscript","commit_stats":null,"repository_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Ftestscript","tags_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Ftestscript/tags","manifests_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Ftestscript/manifests","owner_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogpeppe","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":108921946,"host_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names"},"owner_record":{"login":"rogpeppe","name":"Roger Peppe","uuid":"66491","kind":"user","description":"","email":"","website":null,"location":"Newcastle upon Tyne, UK","twitter":"rogpeppe","company":"InfluxData","avatar_url":"https://avatars.githubusercontent.com/u/66491?u=a6b25e118422d7a56d47151bafd2c57a7655302e\u0026v=4","repositories_count":36,"last_synced_at":"2023-02-17T08:25:10.312Z","metadata":{"has_sponsors_listing":false},"owner_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogpeppe"},"tags":[{"name":"v1.1.0","sha":"661ba0429a22b42340f1260b91521ed2c4478e0f","kind":"tag","published_at":"2019-09-30T13:22:43.000Z","download_url":"https://codeload.github.com/rogpeppe/testscript/tar.gz/v1.1.0","html_url":"https://github.com/rogpeppe/testscript/releases/tag/v1.1.0"},{"name":"v1.0.0","sha":"7f2ad3f15af8cff4b477f8b7230fe71c01434747","kind":"tag","published_at":"2019-09-29T16:56:54.000Z","download_url":"https://codeload.github.com/rogpeppe/testscript/tar.gz/v1.0.0","html_url":"https://github.com/rogpeppe/testscript/releases/tag/v1.0.0"}]},"repo_metadata_updated_at":"2023-03-21T18:44:41.333Z","dependent_packages_count":55,"downloads":null,"downloads_period":null,"dependent_repos_count":91,"rankings":{"downloads":null,"dependent_repos_count":0.6272802402692951,"dependent_packages_count":0.6434184972986708,"stargazers_count":9.604389886804325,"forks_count":11.071819661320475,"docker_downloads_count":1.999628932758179,"average":4.7893074436901895},"purl":"pkg:golang/github.com/rogpeppe/testscript","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/go/github.com/rogpeppe/testscript","docker_dependents_count":2,"docker_downloads_count":154,"usage_url":"https://repos.ecosyste.ms/usage/go/github.com/rogpeppe/testscript","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/go/github.com/rogpeppe/testscript/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":{"last_synced_at":"2023-08-11T21:17:19.951Z","issues_count":0,"pull_requests_count":3,"avg_time_to_close_issue":null,"avg_time_to_close_pull_request":6100299.0,"issues_closed_count":0,"pull_requests_closed_count":2,"pull_request_authors_count":2,"issue_authors_count":0,"avg_comments_per_issue":null,"avg_comments_per_pull_request":1.0,"merged_pull_requests_count":1,"bot_issues_count":0,"bot_pull_requests_count":0,"past_year_issues_count":0,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":0,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0},"versions_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Frogpeppe%2Ftestscript/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Frogpeppe%2Ftestscript/version_numbers","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Frogpeppe%2Ftestscript/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Frogpeppe%2Ftestscript/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Frogpeppe%2Ftestscript/codemeta","maintainers":[]}