{"id":19614639,"url":"https://github.com/activestate/termtest","last_synced_at":"2025-04-06T14:11:54.109Z","repository":{"id":37047389,"uuid":"256597264","full_name":"ActiveState/termtest","owner":"ActiveState","description":"Cross-platform (Windows, Mac, Linux) integration testing for your terminals","archived":false,"fork":false,"pushed_at":"2024-05-22T15:34:11.000Z","size":2693,"stargazers_count":52,"open_issues_count":3,"forks_count":4,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-05-22T16:47:18.409Z","etag":null,"topics":["cross-platform","emulation","expect","golang","linux","macos","terminal","testing","windows"],"latest_commit_sha":null,"homepage":"","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,"icon_url":"https://github.com/ActiveState.png","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-17T19:57:39.000Z","updated_at":"2024-06-18T16:53:36.773Z","dependencies_parsed_at":"2024-05-22T16:46:13.242Z","dependency_job_id":"8cbe65ab-3eef-468f-9527-99d5217eb421","html_url":"https://github.com/ActiveState/termtest","commit_stats":{"total_commits":82,"total_committers":4,"mean_commits":20.5,"dds":0.04878048780487809,"last_synced_commit":"1650c4d27d780c8f1bd359ff3fa12f38efc3ce3d"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Ftermtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Ftermtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Ftermtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Ftermtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ActiveState","download_url":"https://codeload.github.com/ActiveState/termtest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492557,"owners_count":20947545,"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":["cross-platform","emulation","expect","golang","linux","macos","terminal","testing","windows"],"created_at":"2024-11-11T10:53:12.679Z","updated_at":"2025-04-06T14:11:54.092Z","avatar_url":"https://github.com/ActiveState.png","language":"Go","readme":"# termtest\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/ActiveState/termtest/actions?query=workflow%3Aunit-tests\"\u003e\u003cimg alt=\"GitHub Actions status\" src=\"https://github.com/ActiveState/termtest/workflows/unit-tests/badge.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nAn automatable terminal session with send/expect controls.\n\nThis package leverages the\n[go-expect](https://github.com/ActiveState/termtest/expect) package to test\nterminal applications on Linux, MacOS and Windows, which has been forked from\n[Netflix/go-expect](https://github.com/Netflix/go-expect)\n\nIt has been developed for CI testing of the [ActiveState state\ntool](https://www.activestate.com/products/platform/state-tool/)\n\n## Example usage\n\n```go\n\nimport (\n    \"testing\"\n\n    \"github.com/ActiveState/termtest\"\n    \"github.com/stretchr/testify/suite\"\n)\n\nfunc TestBash(t *testing.T) {\n    opts := termtest.Options{\n        CmdName: \"/bin/bash\",\n    }\n    cp, err := termtest.NewTest(t, opts)\n    require.NoError(t, err, \"create console process\")\n    defer cp.Close()\n\n    cp.SendLine(\"echo hello world\")\n    cp.Expect(\"hello world\")\n    cp.SendLine(\"exit\")\n    cp.ExpectExitCode(0)\n}\n\n```\n\n## Multi-line matching\n\nAfter each bytes `termtest` receives from the pseudo-terminal output, it updates the state of the virtual terminal like a terminal user would see it (including a scroll back buffer if necessary).  The `Expect()` look for matches in this processed output. Of course, the terminal wraps its output after text gets longer than 80 columns (or whatever width you have configured for your terminal). As this makes it more difficult to match long string, the default `Expect()` removes all these automatic wraps.\n\nConsider the following examples, that all assume a terminal width of 10 columns.\n\n### Programme sends a line with more than 10 characters\n\n- Programme sends string \"0123456789012345\".\n- Terminal output is \"0123456789\\n012345     \\n\".\n\n```\ncp.Expect(\"0123456789012345\")  // this matches\n```\n\n### Programme sends several lines separated by `\\n`\n\n- Programme sends string \"line 1\\nline 2\\n\".\n- Terminal output is \"line 1    \\nline 2    \\n\".\n- The following does NOT match:\n  ```\n  cp.Expect(\"line 1\\nline 2\\n\")  // this does NOT match\n  ```\n- The following does MATCH:\n  ```\n  cp.Expect(\"line 1\")\n  cp.Expect(\"line 2\")\n  ```\n- The following does MATCH:\n  ```\n  cp.Expect(\"line 1    line 2    \")\n  ```\n\n### Custom matchers\n\nCustom matchers that match against either the raw / or processed pseudo-terminal output can be specified in the `go-expect` package.  See `expect_opt.go` for examples.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivestate%2Ftermtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factivestate%2Ftermtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivestate%2Ftermtest/lists"}