| 150 | }); |
| 151 | |
| 152 | function parseArgs(argv) { |
| 153 | const [command, value, extra] = argv; |
| 154 | const json = argv.includes("--json"); |
| 155 | |
| 156 | if (command === "summary") { |
| 157 | const unexpected = argv.slice(1).filter((arg) => arg !== "--json"); |
| 158 | if (unexpected.length > 0) { |
| 159 | throw new Error(`testing-slices: unexpected extra argument: ${unexpected[0]}`); |
| 160 | } |
| 161 | return { command, json }; |
| 162 | } |
| 163 | |
| 164 | if (command === "run") { |
| 165 | if (typeof value !== "string" || value.length === 0) { |
| 166 | throw new Error("testing-slices: run requires a slice name"); |
| 167 | } |
| 168 | if (typeof extra === "string") { |
| 169 | throw new Error(`testing-slices: unexpected extra argument: ${extra}`); |
| 170 | } |
| 171 | return { command, slice: value, json }; |
| 172 | } |
| 173 | |
| 174 | throw new Error("testing-slices: expected `summary` or `run <slice>`"); |
| 175 | } |
| 176 | |
| 177 | function collectReferenceScenarios() { |
| 178 | const dir = join(root, "packages", "core", "src", "testing", "referenceScenarios"); |