示例#1
0
func TestVfArgs(t *testing.T) {
	fg := new(FrameGenerator)
	for i, tt := range vfArgsFixtures {
		a := util.NewArguments()
		a.SpeedSpec = tt.SpeedSpec
		a.NeedScaling = tt.NeedScaling
		a.ScaleFilter = tt.ScaleFilter
		b, s := fg.combineVf(a)
		if b != tt.vf || s != tt.out {
			t.Errorf("%d. Error out(%t), want %t // out(%q), want %q", i, b, tt.vf, s, tt.out)
		}
	}
}
示例#2
0
文件: main.go 项目: javouhey/seneca
func main() {

	if len(os.Args) == 1 {
		fmt.Printf("%s", util.HelpMessage)
		syscall.Exit(0)
	}

	args := util.NewArguments()
	if err := args.Parse(os.Args[1:]); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n\n%s\n", err, util.ShortHelp)
		syscall.Exit(1)
	}

	if args.Verbose {
		fmt.Printf("  %#v\n", args)
	}

	if args.Version {
		printVersion()
		syscall.Exit(0)
	}

	if args.Help {
		fmt.Printf("%s", util.HelpMessage)
		syscall.Exit(0)
	}

	if err := args.Validate(); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n\n%s\n", err, util.ShortHelp)
		syscall.Exit(1)
	}

	var vr *io.VideoReader
	var errVr error

	filename, _ := util.SanitizeFile(args.VideoIn)
	vr, errVr = io.NewVideoReader(filename, args.DryRun)
	if errVr != nil {
		fmt.Fprintf(os.Stderr, io.INVALID_VIDEO, filename, util.ShortHelp)
		syscall.Exit(1)
	}

	if args.Verbose {
		fmt.Printf("%s", vr)
	}

	// --- setup progress notification ---
	listener := NewTCPListener(args.Port)

	defer func() {
		cleanup(vr)

		listener.Close()
		if args.Verbose {
			fmt.Println("Closed TCP listener")
		}
		close(ipc)
		if args.Verbose {
			fmt.Println("Closed progress channel")
		}
	}()

	go progress.StatusLogger(ipc)
	go progress.Progress(listener, ipc, args.Port)

	// --- Pipeline ---
	reply := task1.Run(vr, args)
	if err := <-reply; err != nil {
		syscall.Exit(126)
	}

	wg := task2.Run(vr, args)
	wg.Wait()
	if err := task2.Error(); err != nil {
		syscall.Exit(126)
	}

	task3.Run(vr, args)
	/*
	   Sample code for cancelling a goroutine

	   time.Sleep(1 * time.Second)
	   log.Fatal(task3.Stop())
	*/
	if err := task3.Tombstone.Wait(); err != nil {
		syscall.Exit(126)
	}

	sayGoodbye(vr)
}