Skip to content

testscript: add dynamic command capability - #306

Merged
rogpeppe merged 1 commit into
masterfrom
053-dynamic-commands
Jun 10, 2026
Merged

rogpeppe merged 1 commit into
masterfrom
053-dynamic-commands

Conversation

@rogpeppe

@rogpeppe rogpeppe commented Jun 9, 2026

Copy link
Copy Markdown
Owner

This allows a command to be able to add more commands, which is useful for the up-coming plugin functionality.

"register": func(ts *TestScript, neg bool, args []string) {
// register <name> <text> dynamically defines a command
// that writes <text> to stdout, for the rest of the test.
if len(args) != 2 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

also fail if negated? ! register ... doesn't seem to make sense

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This is only for tests; I don't think it matters that much tbh.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

(note: we already ignore neg for all the other commands in this set - I don't think this is any different)


register greet 'hi again'
greet
stdout '^hi again$'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: perhaps verify that if you do register most_definitely_not_in_path 'whatever', then exec most_definitely_not_in_path fails

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

@rogpeppe
rogpeppe force-pushed the 053-dynamic-commands branch from 09f3842 to d721b23 Compare June 10, 2026 09:18
This allows a command to be able to add more commands, which is useful
for the up-coming plugin functionality.
@rogpeppe
rogpeppe force-pushed the 053-dynamic-commands branch from d721b23 to c1eb882 Compare June 10, 2026 09:21
@rogpeppe
rogpeppe merged commit b82995b into master Jun 10, 2026
6 checks passed
@rogpeppe
rogpeppe deleted the 053-dynamic-commands branch August 4, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants