Example #1
0
func TestTerminal_Record(t *testing.T) {
	command := `python -c "
import sys, time, os
sys.stdout.write('foo')
sys.stdout.flush()
time.sleep(0.01)
sys.stdout.write(os.environ['ASCIINEMA_REC'])
"`
	stdoutCopy := &testWriter{}

	err := terminal.NewTerminal().Record(command, stdoutCopy)

	if err != nil {
		t.Errorf("got error: %v", err)
		return
	}

	chunk := stdoutCopy.chunks[0]
	if chunk != "foo" {
		t.Errorf("expected \"foo\", got \"%v\"", chunk)
	}

	chunk = stdoutCopy.chunks[1]
	if chunk != "1" {
		t.Errorf("expected \"1\", got \"%v\"", chunk)
	}
}
Example #2
0
func NewPlayer() Player {
	return &AsciicastPlayer{Terminal: terminal.NewTerminal()}
}
Example #3
0
func NewRecorder() Recorder {
	return &AsciicastRecorder{Terminal: terminal.NewTerminal()}
}