Skip to content

doc(BUD-2,test,cli): topiary test subcommand#10

Open
mkatychev wants to merge 3 commits into
trunkfrom
mkatychev/bud-2-topiary-test
Open

doc(BUD-2,test,cli): topiary test subcommand#10
mkatychev wants to merge 3 commits into
trunkfrom
mkatychev/bud-2-topiary-test

Conversation

@mkatychev

Copy link
Copy Markdown
Member

Topiary BUD-2

Checklist

Description

This proposal proposes introducing a new topiary test subcommand for formatting query validation.


Comment thread buds/bud-2.md Outdated
Comment thread buds/bud-2.md
## Unresolved questions

* Do we want to apply a specific naming schema for our tests?
* How do we group multiple tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespaces, perhaps:

foo::bar::baz

Co-authored-by: Christopher Harrison <Xophmeister@users.noreply.github.com>
@mkatychev mkatychev changed the title doc(BUD-2,test,cli): doc(BUD-2,test,cli): topiary test subcommand Jul 13, 2026

@Xophmeister Xophmeister left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 I've added a few more suggestions to flesh it out a bit.

Comment thread buds/bud-2.md

## Motivation

* There's value to having test cases be in one huge file for side effects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't delimiting the tests is one huge file ostensibly remove side-effects (unless the test was specifically structured to have side-effects)?

Comment thread buds/bud-2.md
## Motivation

* There's value to having test cases be in one huge file for side effects.
* One should not have to recompile the `topiary` binary to test query changes for built-in languages

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already true, isn't it? You can just give Topiary the path to a query file to test any query changes.

Comment thread buds/bud-2.md

* There's value to having test cases be in one huge file for side effects.
* One should not have to recompile the `topiary` binary to test query changes for built-in languages
* external grammar repositories such as [topiary-nushell](https://github.com/blindFS/topiary-nushell) should have comparable DX to what is happening in topiary

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this point is probably the strongest, but it needs expanding on to understand the shortfalls and what/how topiary-nushell does to workaround them.

Comment thread buds/bud-2.md

## Alternatives considered

Instead of comments, one could use [`query_name!`](https://topiary.tweag.io/book/reference/capture-names/general.html#query_name) but DX may be different.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are plenty of times when multiple queries need to be used to adequately test something, so query_name! becomes too limiting.

Comment thread buds/bud-2.md
Comment on lines +81 to +82
`topiary test` is a new subcommand and adds no changes to existing
Topiary behaviour, so there are no backwards-compatibility concerns.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a backwards compatibility concern, but I could see this also superseding the current input/expected tests. It seems like a more disciplined approach, rather than dumping some random source file into the input and then shoehorning regression tests into it 👍

Comment thread buds/bud-2.md

Test report could look like this in stdout:
```sh-session
$ topiary test --dir ./my_lang/test --query ./my_lang/query.scm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't stated, but I suspect you imply this with your final unresolved questions, but you'd presumably expect something like:

topiary test [OPTIONS...] [TESTS...]

Where TESTS... is an optional list of tests, either fully qualified or partially by namespace, which the harness will then run explicitly.

I think this is worth writing down because I think that's pretty nice DX that we don't have right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants