{"id":13792764,"url":"https://github.com/yawaramin/ggspec","last_synced_at":"2026-03-03T18:31:57.736Z","repository":{"id":13556829,"uuid":"16248995","full_name":"yawaramin/ggspec","owner":"yawaramin","description":"A lightweight, functional-style unit testing framework for Guile/Scheme","archived":false,"fork":false,"pushed_at":"2014-02-25T01:53:03.000Z","size":700,"stargazers_count":27,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-22T08:29:40.903Z","etag":null,"topics":["guile","lisp","scheme","testing"],"latest_commit_sha":null,"homepage":"","language":"Scheme","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yawaramin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-26T07:41:25.000Z","updated_at":"2025-05-11T22:39:20.000Z","dependencies_parsed_at":"2022-09-05T08:41:04.481Z","dependency_job_id":null,"html_url":"https://github.com/yawaramin/ggspec","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/yawaramin/ggspec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yawaramin%2Fggspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yawaramin%2Fggspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yawaramin%2Fggspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yawaramin%2Fggspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yawaramin","download_url":"https://codeload.github.com/yawaramin/ggspec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yawaramin%2Fggspec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30054585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["guile","lisp","scheme","testing"],"created_at":"2024-08-03T22:01:15.740Z","updated_at":"2026-03-03T18:31:57.713Z","avatar_url":"https://github.com/yawaramin.png","language":"Scheme","funding_links":[],"categories":["Scheme"],"sub_categories":["course"],"readme":"# ggspec - lightweight unit testing library for Guile\n\nCopyright (c) 2014 Yawar Amin\n\nGitHub, Reddit, Twitter: yawaramin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n## Introduction\n\nggspec is a _very_ lightweight unit testing framework for Guile.\nCurrently I am targeting Guile 1.8. I may port it to other Schemes in\nfuture; in principle it should be fairly simple because it doesn't use\nvery many Guile-specific features.\n\nggspec is self-testing. In fact, it was bootstrapped by the tests--the\ntests were written _first,_ before there was a unit testing framework to\nrun them; and _then_ the framework was written around the tests.\n\n## Installation\n\nAssuming you have cloned the `ggspec` repository to a directory also\nnamed `ggspec`, create a symbolic link to the `ggspec` directory inside\nany directory in your `$GUILE_LOAD_PATH` (Windows: `%GUILE_LOAD_PATH%`).\nThen, link or copy the `ggspec` script to any directory in your `$PATH`\n(Windows: `%PATH%`).\n\nE.g., if you have `~/guile` in your Guile load path, `~/bin` in your\npath, and have cloned the repo into `~/code/ggspec`, then run:\n\n```\ncd ~/guile\nln -s ~/code/ggspec\ncd ~/bin\nln -s ~/code/ggspec/ggspec\n```\n\n## Verifying the framework itself\n\nAs I described earlier, the `ggspec` framework is tested using itself.\nYou can run the tests:\n\n```\ncd ~/code/ggspec\n./ggspec # Or if you copied/linked the script to a dir in your path,\n         # just ggspec.\n```\n\n## Contributing\n\nSee the file `CONTRIBUTING.md`.\n\n## Minimal complete example\n\n```\n$ guile\nguile\u003e (use-modules (ggspec lib))\nguile\u003e (suite \"Hello ggspec\" end)\n  Suite: Hello ggspec\n\n(0 0 0)\n```\n\nThe last line above shows the number of passing tests, failing tests,\nand skipped tests. Since we didn't write _any_ tests here, all three are\nzero.\n\n## Introduction\n\nSee the `lib.scm` file for a detailed reference. A brief introduction to\nhow it works:\n\n  - The `suite` function is presented as the way to organise everything.\n    This includes tests, any options you want to pass in to those tests,\n    any setup variables you want to define before running each test in\n    the suite, and any teardowns you want to do after running each test.\n\n  - Inside the `suite` function, a group of tests is organised together\n    using the `tests` function. Each test is created using the `test`\n    macro.\n\n  - After the tests come the options, which are organised together using\n    the `options` function. Each option is created using the `option`\n    function.\n\n  - After the options come the setups, which are organised together\n    using the `setups` function. Each setup (which is a symbol name\n    'bound' to an expression) is created using the `setup` macro. Each\n    setup will be re-evaluated before each test is run. So generally you\n    don't want to put expensive computations in these.\n\n  - After the setups come the teardowns, which are organised together\n    using the `teardowns` function. Each teardown (which is just a set\n    of expressions) is created using the `teardown` macro. Each teardown\n    will be re-evaluated _after_ each test is run to ensure a clean\n    'environment' for the next test run.\n\nOptions and setups are not required, but since setups come after\noptions, you have to specify options if you want to specify setups. You\ncan specify empty (or missing) options, setups, and teardowns, in which\ncase the `suite` function doesn't try to do anything with them.\n\nNormally you will put all your test source code files in a subdirectory\nof your project directory called `spec`. This lets the `ggspec` test\nrunner find and run all of them.\n\n## Tutorial\n\nA short tutorial (in the context of Test-Driven Development):\n\nSuppose we want to develop a function `sqr` that should return the\nsquare of its argument (a number). In this example I will show the\nfunction and its test suite together, but usually you would have them in\nseparate files. For this example you can follow along by making the\nchanges in your editor and re-loading the source code file in your REPL:\n\n```\nguile\u003e (load \"test.scm\")\n```\n\nFirst you write a failing test:\n\n```scheme\n(use-modules (ggspec lib))\n\n(suite \"The sqr function\"\n  (tests\n    (test \"Should square 1 correctly\"\n      ;; The 'e' argument below represents (and contains) all the\n      ;; state that we're passing in to the test. All setups, options,\n      ;; etc.\n      e\n      (assert-equal 1 (sqr 1)))))\n```\n\nThis suite will fail because the `sqr` function does not exist:\n\n```\n  Suite: The sqr function\nERROR: Unbound variable: sqr\n```\n\nNow implement it to make the test pass:\n\n```scheme\n(define (sqr x) 1)\n```\n\nThe test will now pass because we have 'cheated' to make it so:\n\n```\n  Suite: The sqr function\n    [PASS]\n```\n\nNote that the output is minimal when a test passes. Now we extend the\nsuite to another 'example':\n\n```scheme\n(use-modules (ggspec lib))\n\n(suite \"The sqr function\"\n  (tests\n    (test \"Should square 1 correctly\"\n      e\n      (assert-equal 1 (sqr 1)))\n    (test \"Should square 2 correctly\"\n      e\n      (assert-equal 4 (sqr 2)))))\n```\n\nThis will now fail, again, because the `sqr` function is hard-coded to\nalways return `1`:\n\n```\n  Suite: The sqr function\n    [PASS]\n    [FAIL] Should square 2 correctly\n      Expected: 4\n           Got: 1\n```\n\nNow we fix that:\n\n```scheme\n(define (sqr x) (* x x))\n```\n\nThis time the test will pass because `sqr` handles the general case:\n\n```\n  Suite: The sqr function\n    [PASS]\n    [PASS]\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyawaramin%2Fggspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyawaramin%2Fggspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyawaramin%2Fggspec/lists"}