MCPcopy
hub / github.com/tdewolff/minify / TestHelperProcess

Function TestHelperProcess

minify_test.go:301–349  ·  view source on GitHub ↗
(*testing.T)

Source from the content-addressed store, hash-verified

299}
300
301func TestHelperProcess(*testing.T) {
302 if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
303 return
304 }
305 args := os.Args
306 for len(args) > 0 {
307 if args[0] == "--" {
308 args = args[1:]
309 break
310 }
311 args = args[1:]
312 }
313 if len(args) == 0 {
314 fmt.Fprintf(os.Stderr, "No command\n")
315 os.Exit(2)
316 }
317
318 switch args[0] {
319 case "dummy/copy":
320 _, _ = io.Copy(os.Stdout, os.Stdin)
321 case "dummy/file":
322 // extract filenames
323 in := args[1][5:]
324 in = in[:len(in)-1]
325 out := args[2][5:]
326
327 w, err := os.Create(out)
328 if err != nil {
329 os.Exit(1)
330 return
331 }
332
333 b, err := os.ReadFile(in)
334 if err != nil {
335 _, _ = w.WriteString(err.Error())
336 _ = w.Close()
337 os.Exit(1)
338 return
339 }
340 _, _ = w.Write(b)
341 _ = w.Close()
342 case "dummy/err":
343 fmt.Fprint(os.Stderr, "error")
344 os.Exit(1)
345 default:
346 os.Exit(2)
347 }
348 os.Exit(0)
349}
350
351////////////////////////////////////////////////////////////////
352

Callers

nothing calls this directly

Calls 3

lenFunction · 0.85
CloseMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…