greenletters 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,266 @@
1
+ D, [2010-07-31T07:37:35.732465 #16613] DEBUG -- : added trigger on output matching /Would\s+you\s+like\s+instructions\?/
2
+ D, [2010-07-31T07:37:35.732612 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against ""
3
+ D, [2010-07-31T07:37:35.732694 #16613] DEBUG -- : no match
4
+ D, [2010-07-31T07:37:35.734485 #16613] DEBUG -- : added trigger on output matching /Do\s+you\s+really\s+want\s+to\s+quit/
5
+ D, [2010-07-31T07:37:35.734645 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against ""
6
+ D, [2010-07-31T07:37:35.734770 #16613] DEBUG -- : no match
7
+ D, [2010-07-31T07:37:35.737143 #16613] DEBUG -- : installing end marker handler for __GREENLETTERS_PROCESS_ENDED__
8
+ D, [2010-07-31T07:37:35.737434 #16613] DEBUG -- : prepended trigger on output matching /__GREENLETTERS_PROCESS_ENDED__/
9
+ D, [2010-07-31T07:37:35.737642 #16613] DEBUG -- : executing /usr/bin/ruby1.8 -C /home/avdi/dev/greenletters/examples -e system(*["adventure"]) -e puts("__GREENLETTERS_PROCESS_ENDED__") -e gets -e exit $?.exitstatus
10
+ D, [2010-07-31T07:37:35.738178 #16613] DEBUG -- : command environment:
11
+ {"LIBGL_DRIVERS_PATH"=>"/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri", "GDM_LANG"=>"en_US.utf8", "LANGUAGE"=>"", "KONSOLE_DBUS_SERVICE"=>":1.25", "LOGNAME"=>"avdi", "GTK_MODULES"=>"canberra-gtk-module", "DBUS_SESSION_BUS_ADDRESS"=>"unix:abstract=/tmp/dbus-yzwJzQz2K2,guid=6bd7f6db661aa3d4c38b7d944c53873f", "SPEECHD_PORT"=>"7560", "PATH"=>"/home/avdi/bin:/home/avdi/share/bin:/home/avdi/.gem/ruby/1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games", "USER"=>"avdi", "GNOME_KEYRING_PID"=>"2057", "LANG"=>"en_US.utf8", "DEFAULTS_PATH"=>"/usr/share/gconf/gnome.default.path", "WINDOWID"=>"46137398", "XDG_CONFIG_DIRS"=>"/etc/xdg/xdg-gnome:/etc/xdg", "ORBIT_SOCKETDIR"=>"/tmp/orbit-avdi", "XDG_DATA_DIRS"=>"/usr/share/gnome:/usr/local/share/:/usr/share/", "GNOME_DESKTOP_SESSION_ID"=>"this-is-deprecated", "DISPLAY"=>":0.0", "PWD"=>"/home/avdi/dev/greenletters/examples", "GDMSESSION"=>"gnome", "GDM_KEYBOARD_LAYOUT"=>"us", "COLORFGBG"=>"15;0", "XAUTHORITY"=>"/var/run/gdm/auth-for-avdi-pwU0Bi/database", "SSH_AGENT_PID"=>"2116", "XDG_SESSION_COOKIE"=>"95da948d870c084a39cf95e74bcf1d12-1280542527.346178-1033032164", "TERM"=>"xterm", "PROFILEHOME"=>"", "SESSION_MANAGER"=>"local/petronius:@/tmp/.ICE-unix/2075,unix/petronius:/tmp/.ICE-unix/2075", "DESKTOP_AUTOSTART_ID"=>"109b01964624068715128054252796155900000020750004", "SSH_AUTH_SOCK"=>"/tmp/keyring-eGT6zq/ssh", "KONSOLE_DBUS_SESSION"=>"/Sessions/2", "GNOME_KEYRING_CONTROL"=>"/tmp/keyring-eGT6zq", "DESKTOP_SESSION"=>"gnome", "USERNAME"=>"avdi", "MANDATORY_PATH"=>"/usr/share/gconf/gnome.mandatory.path", "HOME"=>"/home/avdi", "GPG_AGENT_INFO"=>"/tmp/gpg-AW2u0g/S.gpg-agent:2117:1", "SHELL"=>"/bin/zsh", "SHLVL"=>"1", "OLDPWD"=>"/home/avdi/dev/greenletters", "EDITOR"=>"/home/avdi/share/bin/emacs-newwindow", "GEM_EDITOR"=>"/home/avdi/share/bin/emacs-newwindow", "ZSH"=>"/home/avdi/.oh-my-zsh", "ZSH_THEME"=>"robbyrussell", "LSCOLORS"=>"Gxfxcxdxbxegedabagacad", "GREP_OPTIONS"=>"--color=auto", "GREP_COLOR"=>"1;32", "PAGER"=>"less", "LC_CTYPE"=>"en_US.UTF-8", "rvm_path"=>"/home/avdi/.rvm", "rvm_rubies_path"=>"/home/avdi/.rvm/rubies", "rvm_scripts_path"=>"/home/avdi/.rvm/scripts", "rvm_archives_path"=>"/home/avdi/.rvm/archives", "rvm_src_path"=>"/home/avdi/.rvm/src", "rvm_log_path"=>"/home/avdi/.rvm/log", "rvm_bin_path"=>"/home/avdi/.rvm/bin", "rvm_gems_path"=>"/home/avdi/.rvm/gems", "rvm_config_path"=>"/home/avdi/.rvm/config", "rvm_tmp_path"=>"/home/avdi/.rvm/tmp", "rvm_hooks_path"=>"/home/avdi/.rvm/hooks", "rvm_gems_cache_path"=>"/home/avdi/.rvm/gems/cache", "rvm_gemset_separator"=>"@", "rvm_version"=>"0.1.28", "_"=>"/home/avdi/.gem/ruby/1.8/bin/cucumber"}
12
+ D, [2010-07-31T07:37:35.753426 #16613] DEBUG -- : spawned pid 16618
13
+ D, [2010-07-31T07:37:35.756271 #16613] DEBUG -- : added trigger on output matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./
14
+ D, [2010-07-31T07:37:35.756524 #16613] DEBUG -- : waiting for output matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./
15
+ D, [2010-07-31T07:37:35.756700 #16613] DEBUG -- : matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./ against ""
16
+ D, [2010-07-31T07:37:35.756833 #16613] DEBUG -- : no match
17
+ D, [2010-07-31T07:37:35.756988 #16613] DEBUG -- : select()
18
+ D, [2010-07-31T07:37:35.757249 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
19
+ D, [2010-07-31T07:37:35.757442 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
20
+ D, [2010-07-31T07:37:35.757708 #16613] DEBUG -- :
21
+ <<
22
+ << Welcome to Adventure!! Would you like instructions?
23
+ D, [2010-07-31T07:37:35.757859 #16613] DEBUG -- : read 56 bytes
24
+ D, [2010-07-31T07:37:35.758074 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
25
+ D, [2010-07-31T07:37:35.758246 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against "\r\nWelcome to Adventure!! Would you like instructions?\r\n"
26
+ D, [2010-07-31T07:37:35.758396 #16613] DEBUG -- : no match
27
+ D, [2010-07-31T07:37:35.758531 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
28
+ D, [2010-07-31T07:37:35.758685 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against "\r\nWelcome to Adventure!! Would you like instructions?\r\n"
29
+ D, [2010-07-31T07:37:35.758838 #16613] DEBUG -- : matched /Would\s+you\s+like\s+instructions\?/
30
+ D, [2010-07-31T07:37:35.759027 #16613] DEBUG -- : match trigger output matching /Would\s+you\s+like\s+instructions\?/
31
+ D, [2010-07-31T07:37:35.759189 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
32
+ D, [2010-07-31T07:37:35.759330 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against "\r\n"
33
+ D, [2010-07-31T07:37:35.759459 #16613] DEBUG -- : no match
34
+ D, [2010-07-31T07:37:35.759614 #16613] DEBUG -- : checking output against output matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./
35
+ D, [2010-07-31T07:37:35.759762 #16613] DEBUG -- : matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./ against "\r\n"
36
+ D, [2010-07-31T07:37:35.759890 #16613] DEBUG -- : no match
37
+ D, [2010-07-31T07:37:35.760033 #16613] DEBUG -- : select()
38
+ D, [2010-07-31T07:37:35.760244 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
39
+ D, [2010-07-31T07:37:35.760485 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
40
+ D, [2010-07-31T07:37:35.760685 #16613] DEBUG -- :
41
+ >> no
42
+ D, [2010-07-31T07:37:35.760825 #16613] DEBUG -- : wrote 3 bytes
43
+ D, [2010-07-31T07:37:35.760958 #16613] DEBUG -- : select()
44
+ D, [2010-07-31T07:37:35.761134 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
45
+ D, [2010-07-31T07:37:35.780392 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
46
+ D, [2010-07-31T07:37:35.780589 #16613] DEBUG -- :
47
+ << no
48
+ <<
49
+ << You are standing at the end of a road before a small brick building.
50
+ << Around you is a forest. A small stream flows out of the building and
51
+ << down a gully.
52
+ D, [2010-07-31T07:37:35.780668 #16613] DEBUG -- : read 162 bytes
53
+ D, [2010-07-31T07:37:35.780785 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
54
+ D, [2010-07-31T07:37:35.780890 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against "\r\nno\r\n\r\nYou are standing at the end of a road before a small brick building.\r\nAround you is a forest. A small stream flows out of the building and\r\ndown a gully.\r\n"
55
+ D, [2010-07-31T07:37:35.781057 #16613] DEBUG -- : no match
56
+ D, [2010-07-31T07:37:35.781203 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
57
+ D, [2010-07-31T07:37:35.781356 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against "\r\nno\r\n\r\nYou are standing at the end of a road before a small brick building.\r\nAround you is a forest. A small stream flows out of the building and\r\ndown a gully.\r\n"
58
+ D, [2010-07-31T07:37:35.781478 #16613] DEBUG -- : no match
59
+ D, [2010-07-31T07:37:35.781590 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
60
+ D, [2010-07-31T07:37:35.781747 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against "\r\nno\r\n\r\nYou are standing at the end of a road before a small brick building.\r\nAround you is a forest. A small stream flows out of the building and\r\ndown a gully.\r\n"
61
+ D, [2010-07-31T07:37:35.781878 #16613] DEBUG -- : no match
62
+ D, [2010-07-31T07:37:35.782025 #16613] DEBUG -- : checking output against output matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./
63
+ D, [2010-07-31T07:37:35.782197 #16613] DEBUG -- : matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./ against "\r\nno\r\n\r\nYou are standing at the end of a road before a small brick building.\r\nAround you is a forest. A small stream flows out of the building and\r\ndown a gully.\r\n"
64
+ D, [2010-07-31T07:37:35.782368 #16613] DEBUG -- : matched /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./
65
+ D, [2010-07-31T07:37:35.782489 #16613] DEBUG -- : match trigger output matching /You\s+are\s+standing\s+at\s+the\s+end\s+of\s+a\s+road\s+before\s+a\s+small\s+brick\s+building\.\s+Around\s+you\s+is\s+a\s+forest\.\s+A\s+small\s+stream\s+flows\s+out\s+of\s+the\s+building\s+and\s+down\s+a\s+gully\./
66
+ D, [2010-07-31T07:37:35.782572 #16613] DEBUG -- : unblocked
67
+ D, [2010-07-31T07:37:35.782654 #16613] DEBUG -- : trigger removed
68
+ D, [2010-07-31T07:37:35.785517 #16613] DEBUG -- : added trigger on output matching /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./
69
+ D, [2010-07-31T07:37:35.785600 #16613] DEBUG -- : waiting for output matching /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./
70
+ D, [2010-07-31T07:37:35.785667 #16613] DEBUG -- : matching /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./ against "\r\n"
71
+ D, [2010-07-31T07:37:35.785719 #16613] DEBUG -- : no match
72
+ D, [2010-07-31T07:37:35.785776 #16613] DEBUG -- : select()
73
+ D, [2010-07-31T07:37:35.785875 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
74
+ D, [2010-07-31T07:37:35.785960 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
75
+ D, [2010-07-31T07:37:35.786052 #16613] DEBUG -- :
76
+ >> east
77
+ D, [2010-07-31T07:37:35.786108 #16613] DEBUG -- : wrote 5 bytes
78
+ D, [2010-07-31T07:37:35.786157 #16613] DEBUG -- : select()
79
+ D, [2010-07-31T07:37:35.786234 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
80
+ D, [2010-07-31T07:37:35.800435 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
81
+ D, [2010-07-31T07:37:35.800788 #16613] DEBUG -- :
82
+ << east
83
+ <<
84
+ << You are inside a building, a well house for a large spring.
85
+ <<
86
+ << There are some keys on the ground here.
87
+ <<
88
+ << There is a shiny brass lamp nearby.
89
+ <<
90
+ << There is food here.
91
+ <<
92
+ << There is a bottle of water here.
93
+ D, [2010-07-31T07:37:35.800945 #16613] DEBUG -- : read 210 bytes
94
+ D, [2010-07-31T07:37:35.801086 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
95
+ D, [2010-07-31T07:37:35.801204 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against "\r\neast\r\n\r\nYou are inside a building, a well house for a large spring.\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\n"
96
+ D, [2010-07-31T07:37:35.801285 #16613] DEBUG -- : no match
97
+ D, [2010-07-31T07:37:35.801373 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
98
+ D, [2010-07-31T07:37:35.801484 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against "\r\neast\r\n\r\nYou are inside a building, a well house for a large spring.\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\n"
99
+ D, [2010-07-31T07:37:35.801563 #16613] DEBUG -- : no match
100
+ D, [2010-07-31T07:37:35.801645 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
101
+ D, [2010-07-31T07:37:35.801756 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against "\r\neast\r\n\r\nYou are inside a building, a well house for a large spring.\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\n"
102
+ D, [2010-07-31T07:37:35.801835 #16613] DEBUG -- : no match
103
+ D, [2010-07-31T07:37:35.801917 #16613] DEBUG -- : checking output against output matching /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./
104
+ D, [2010-07-31T07:37:35.802020 #16613] DEBUG -- : matching /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./ against "\r\neast\r\n\r\nYou are inside a building, a well house for a large spring.\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\n"
105
+ D, [2010-07-31T07:37:35.802119 #16613] DEBUG -- : matched /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./
106
+ D, [2010-07-31T07:37:35.802212 #16613] DEBUG -- : match trigger output matching /You\s+are\s+inside\s+a\s+building,\s+a\s+well\s+house\s+for\s+a\s+large\s+spring\./
107
+ D, [2010-07-31T07:37:35.802288 #16613] DEBUG -- : unblocked
108
+ D, [2010-07-31T07:37:35.802369 #16613] DEBUG -- : trigger removed
109
+ D, [2010-07-31T07:37:35.805831 #16613] DEBUG -- : added trigger on output matching /You're\s+at\s+end\s+of\s+road\s+again\./
110
+ D, [2010-07-31T07:37:35.805956 #16613] DEBUG -- : waiting for output matching /You're\s+at\s+end\s+of\s+road\s+again\./
111
+ D, [2010-07-31T07:37:35.806066 #16613] DEBUG -- : matching /You're\s+at\s+end\s+of\s+road\s+again\./ against "\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\n"
112
+ D, [2010-07-31T07:37:35.806152 #16613] DEBUG -- : no match
113
+ D, [2010-07-31T07:37:35.806244 #16613] DEBUG -- : select()
114
+ D, [2010-07-31T07:37:35.806388 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
115
+ D, [2010-07-31T07:37:35.806504 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
116
+ D, [2010-07-31T07:37:35.806638 #16613] DEBUG -- :
117
+ >> west
118
+ D, [2010-07-31T07:37:35.806723 #16613] DEBUG -- : wrote 5 bytes
119
+ D, [2010-07-31T07:37:35.806805 #16613] DEBUG -- : select()
120
+ D, [2010-07-31T07:37:35.806935 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
121
+ D, [2010-07-31T07:37:35.813204 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
122
+ D, [2010-07-31T07:37:35.813825 #16613] DEBUG -- :
123
+ << west
124
+ <<
125
+ << You're at end of road again.
126
+ D, [2010-07-31T07:37:35.813915 #16613] DEBUG -- : read 38 bytes
127
+ D, [2010-07-31T07:37:35.813997 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
128
+ D, [2010-07-31T07:37:35.814065 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against "\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\nwest\r\n\r\nYou're at end of road again.\r\n"
129
+ D, [2010-07-31T07:37:35.814111 #16613] DEBUG -- : no match
130
+ D, [2010-07-31T07:37:35.814158 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
131
+ D, [2010-07-31T07:37:35.814217 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against "\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\nwest\r\n\r\nYou're at end of road again.\r\n"
132
+ D, [2010-07-31T07:37:35.814260 #16613] DEBUG -- : no match
133
+ D, [2010-07-31T07:37:35.814306 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
134
+ D, [2010-07-31T07:37:35.814361 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against "\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\nwest\r\n\r\nYou're at end of road again.\r\n"
135
+ D, [2010-07-31T07:37:35.814410 #16613] DEBUG -- : no match
136
+ D, [2010-07-31T07:37:35.814455 #16613] DEBUG -- : checking output against output matching /You're\s+at\s+end\s+of\s+road\s+again\./
137
+ D, [2010-07-31T07:37:35.814511 #16613] DEBUG -- : matching /You're\s+at\s+end\s+of\s+road\s+again\./ against "\r\n\r\nThere are some keys on the ground here.\r\n\r\nThere is a shiny brass lamp nearby.\r\n\r\nThere is food here.\r\n\r\nThere is a bottle of water here.\r\nwest\r\n\r\nYou're at end of road again.\r\n"
138
+ D, [2010-07-31T07:37:35.814564 #16613] DEBUG -- : matched /You're\s+at\s+end\s+of\s+road\s+again\./
139
+ D, [2010-07-31T07:37:35.814613 #16613] DEBUG -- : match trigger output matching /You're\s+at\s+end\s+of\s+road\s+again\./
140
+ D, [2010-07-31T07:37:35.814660 #16613] DEBUG -- : unblocked
141
+ D, [2010-07-31T07:37:35.814705 #16613] DEBUG -- : trigger removed
142
+ D, [2010-07-31T07:37:35.817046 #16613] DEBUG -- : added trigger on output matching /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./
143
+ D, [2010-07-31T07:37:35.817133 #16613] DEBUG -- : waiting for output matching /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./
144
+ D, [2010-07-31T07:37:35.817212 #16613] DEBUG -- : matching /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./ against "\r\n"
145
+ D, [2010-07-31T07:37:35.817261 #16613] DEBUG -- : no match
146
+ D, [2010-07-31T07:37:35.817310 #16613] DEBUG -- : select()
147
+ D, [2010-07-31T07:37:35.817393 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
148
+ D, [2010-07-31T07:37:35.817464 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
149
+ D, [2010-07-31T07:37:35.817542 #16613] DEBUG -- :
150
+ >> south
151
+ D, [2010-07-31T07:37:35.817597 #16613] DEBUG -- : wrote 6 bytes
152
+ D, [2010-07-31T07:37:35.817640 #16613] DEBUG -- : select()
153
+ D, [2010-07-31T07:37:35.817705 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
154
+ D, [2010-07-31T07:37:35.830371 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
155
+ D, [2010-07-31T07:37:35.830569 #16613] DEBUG -- :
156
+ << south
157
+ <<
158
+ << You are in a valley in the forest beside a stream tumbling along a
159
+ << rocky bed.
160
+ D, [2010-07-31T07:37:35.830649 #16613] DEBUG -- : read 89 bytes
161
+ D, [2010-07-31T07:37:35.830766 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
162
+ D, [2010-07-31T07:37:35.830866 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against "\r\nsouth\r\n\r\nYou are in a valley in the forest beside a stream tumbling along a\r\nrocky bed.\r\n"
163
+ D, [2010-07-31T07:37:35.831004 #16613] DEBUG -- : no match
164
+ D, [2010-07-31T07:37:35.831152 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
165
+ D, [2010-07-31T07:37:35.831317 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against "\r\nsouth\r\n\r\nYou are in a valley in the forest beside a stream tumbling along a\r\nrocky bed.\r\n"
166
+ D, [2010-07-31T07:37:35.831452 #16613] DEBUG -- : no match
167
+ D, [2010-07-31T07:37:35.831592 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
168
+ D, [2010-07-31T07:37:35.831763 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against "\r\nsouth\r\n\r\nYou are in a valley in the forest beside a stream tumbling along a\r\nrocky bed.\r\n"
169
+ D, [2010-07-31T07:37:35.831903 #16613] DEBUG -- : no match
170
+ D, [2010-07-31T07:37:35.832047 #16613] DEBUG -- : checking output against output matching /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./
171
+ D, [2010-07-31T07:37:35.832212 #16613] DEBUG -- : matching /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./ against "\r\nsouth\r\n\r\nYou are in a valley in the forest beside a stream tumbling along a\r\nrocky bed.\r\n"
172
+ D, [2010-07-31T07:37:35.832388 #16613] DEBUG -- : matched /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./
173
+ D, [2010-07-31T07:37:35.832528 #16613] DEBUG -- : match trigger output matching /You\s+are\s+in\s+a\s+valley\s+in\s+the\s+forest\s+beside\s+a\s+stream\s+tumbling\s+along\s+a\s+rocky\s+bed\./
174
+ D, [2010-07-31T07:37:35.832667 #16613] DEBUG -- : unblocked
175
+ D, [2010-07-31T07:37:35.832802 #16613] DEBUG -- : trigger removed
176
+ D, [2010-07-31T07:37:35.838590 #16613] DEBUG -- : added trigger on exit with status 0
177
+ D, [2010-07-31T07:37:35.838770 #16613] DEBUG -- : waiting for exit with status 0
178
+ D, [2010-07-31T07:37:35.838907 #16613] DEBUG -- : no match
179
+ D, [2010-07-31T07:37:35.839082 #16613] DEBUG -- : select()
180
+ D, [2010-07-31T07:37:35.839303 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
181
+ D, [2010-07-31T07:37:35.839493 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
182
+ D, [2010-07-31T07:37:35.839721 #16613] DEBUG -- :
183
+ >> quit
184
+ D, [2010-07-31T07:37:35.839865 #16613] DEBUG -- : wrote 5 bytes
185
+ D, [2010-07-31T07:37:35.839991 #16613] DEBUG -- : select()
186
+ D, [2010-07-31T07:37:35.840194 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
187
+ D, [2010-07-31T07:37:35.870399 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
188
+ D, [2010-07-31T07:37:35.870536 #16613] DEBUG -- :
189
+ << quit
190
+ <<
191
+ << Do you really want to quit now?
192
+ D, [2010-07-31T07:37:35.870575 #16613] DEBUG -- : read 41 bytes
193
+ D, [2010-07-31T07:37:35.870635 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
194
+ D, [2010-07-31T07:37:35.870681 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against "\r\nquit\r\n\r\nDo you really want to quit now?\r\n"
195
+ D, [2010-07-31T07:37:35.870716 #16613] DEBUG -- : no match
196
+ D, [2010-07-31T07:37:35.870752 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
197
+ D, [2010-07-31T07:37:35.870788 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against "\r\nquit\r\n\r\nDo you really want to quit now?\r\n"
198
+ D, [2010-07-31T07:37:35.870819 #16613] DEBUG -- : no match
199
+ D, [2010-07-31T07:37:35.870852 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
200
+ D, [2010-07-31T07:37:35.870886 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against "\r\nquit\r\n\r\nDo you really want to quit now?\r\n"
201
+ D, [2010-07-31T07:37:35.870931 #16613] DEBUG -- : matched /Do\s+you\s+really\s+want\s+to\s+quit/
202
+ D, [2010-07-31T07:37:35.871096 #16613] DEBUG -- : match trigger output matching /Do\s+you\s+really\s+want\s+to\s+quit/
203
+ D, [2010-07-31T07:37:35.871211 #16613] DEBUG -- : select()
204
+ D, [2010-07-31T07:37:35.871352 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
205
+ D, [2010-07-31T07:37:35.871463 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
206
+ D, [2010-07-31T07:37:35.871595 #16613] DEBUG -- :
207
+ >> yes
208
+ D, [2010-07-31T07:37:35.871680 #16613] DEBUG -- : wrote 4 bytes
209
+ D, [2010-07-31T07:37:35.871756 #16613] DEBUG -- : select()
210
+ D, [2010-07-31T07:37:35.871871 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
211
+ D, [2010-07-31T07:37:35.890580 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
212
+ D, [2010-07-31T07:37:35.890819 #16613] DEBUG -- :
213
+ << yes
214
+ <<
215
+ << OK
216
+ <<
217
+ <<
218
+ <<
219
+ << You scored 32 out of a possible 350 using 4 turns.
220
+ <<
221
+ << You are obviously a rank amateur. Better luck next time.
222
+ << To achieve the next higher rating, you need 4 more points.
223
+ << __GREENLETTERS_PROCESS_ENDED__
224
+ D, [2010-07-31T07:37:35.890915 #16613] DEBUG -- : read 222 bytes
225
+ D, [2010-07-31T07:37:35.891038 #16613] DEBUG -- : checking output against output matching /__GREENLETTERS_PROCESS_ENDED__/
226
+ D, [2010-07-31T07:37:35.891156 #16613] DEBUG -- : matching /__GREENLETTERS_PROCESS_ENDED__/ against " now?\r\nyes\r\n\r\nOK\r\n\r\n\r\n\r\nYou scored 32 out of a possible 350 using 4 turns.\r\n\r\nYou are obviously a rank amateur. Better luck next time.\r\nTo achieve the next higher rating, you need 4 more points.\r\n__GREENLETTERS_PROCESS_ENDED__\r\n"
227
+ D, [2010-07-31T07:37:35.891252 #16613] DEBUG -- : matched /__GREENLETTERS_PROCESS_ENDED__/
228
+ D, [2010-07-31T07:37:35.891340 #16613] DEBUG -- : end marker found
229
+ D, [2010-07-31T07:37:35.891468 #16613] DEBUG -- : end marker expunged from output buffer
230
+ D, [2010-07-31T07:37:35.891551 #16613] DEBUG -- : acknowledging end marker
231
+ D, [2010-07-31T07:37:35.891650 #16613] DEBUG -- : match trigger output matching /__GREENLETTERS_PROCESS_ENDED__/
232
+ D, [2010-07-31T07:37:35.891740 #16613] DEBUG -- : checking output against output matching /Would\s+you\s+like\s+instructions\?/
233
+ D, [2010-07-31T07:37:35.891846 #16613] DEBUG -- : matching /Would\s+you\s+like\s+instructions\?/ against " now?\r\nyes\r\n\r\nOK\r\n\r\n\r\n\r\nYou scored 32 out of a possible 350 using 4 turns.\r\n\r\nYou are obviously a rank amateur. Better luck next time.\r\nTo achieve the next higher rating, you need 4 more points.\r\n"
234
+ D, [2010-07-31T07:37:35.891925 #16613] DEBUG -- : no match
235
+ D, [2010-07-31T07:37:35.892007 #16613] DEBUG -- : checking output against output matching /Do\s+you\s+really\s+want\s+to\s+quit/
236
+ D, [2010-07-31T07:37:35.892107 #16613] DEBUG -- : matching /Do\s+you\s+really\s+want\s+to\s+quit/ against " now?\r\nyes\r\n\r\nOK\r\n\r\n\r\n\r\nYou scored 32 out of a possible 350 using 4 turns.\r\n\r\nYou are obviously a rank amateur. Better luck next time.\r\nTo achieve the next higher rating, you need 4 more points.\r\n"
237
+ D, [2010-07-31T07:37:35.892184 #16613] DEBUG -- : no match
238
+ D, [2010-07-31T07:37:35.892267 #16613] DEBUG -- : flushing triggers matching Greenletters::OutputTrigger
239
+ D, [2010-07-31T07:37:35.892365 #16613] DEBUG -- : flushing triggers matching Greenletters::BytesTrigger
240
+ D, [2010-07-31T07:37:35.892447 #16613] DEBUG -- : select()
241
+ D, [2010-07-31T07:37:35.892581 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [#<File:/dev/pts/3>], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
242
+ D, [2010-07-31T07:37:35.892692 #16613] DEBUG -- : input ready #<File:/dev/pts/3>
243
+ D, [2010-07-31T07:37:35.892827 #16613] DEBUG -- :
244
+
245
+ D, [2010-07-31T07:37:35.892911 #16613] DEBUG -- : wrote 1 bytes
246
+ D, [2010-07-31T07:37:35.892988 #16613] DEBUG -- : select()
247
+ D, [2010-07-31T07:37:35.893100 #16613] DEBUG -- : select() on [[#<File:/dev/pts/3>], [], [#<File:/dev/pts/3>, #<File:/dev/pts/3>], 1.0]
248
+ D, [2010-07-31T07:37:35.900995 #16613] DEBUG -- : output ready #<File:/dev/pts/3>
249
+ D, [2010-07-31T07:37:35.670905 #16613] DEBUG -- :
250
+ <<
251
+ D, [2010-07-31T07:37:35.671079 #16613] DEBUG -- : read 2 bytes
252
+ D, [2010-07-31T07:37:35.671244 #16613] DEBUG -- : flushing triggers matching Greenletters::OutputTrigger
253
+ D, [2010-07-31T07:37:35.671384 #16613] DEBUG -- : flushing triggers matching Greenletters::BytesTrigger
254
+ D, [2010-07-31T07:37:35.671509 #16613] DEBUG -- : select()
255
+ D, [2010-07-31T07:37:35.671681 #16613] DEBUG -- : select() on [[#<File:/dev/pts/2>], [], [#<File:/dev/pts/2>, #<File:/dev/pts/2>], 1.0]
256
+ D, [2010-07-31T07:37:35.671835 #16613] DEBUG -- : output ready #<File:/dev/pts/2>
257
+ D, [2010-07-31T07:37:35.672236 #16613] DEBUG -- : Errno::EIO caught
258
+ D, [2010-07-31T07:37:35.672378 #16613] DEBUG -- : waiting for child 16615 to die
259
+ D, [2010-07-31T07:37:35.723882 #16613] DEBUG -- : caught PTY::ChildExited
260
+ D, [2010-07-31T07:37:35.724461 #16613] DEBUG -- : collecting remaining output
261
+ D, [2010-07-31T07:37:35.724849 #16613] DEBUG -- : Input/output error - /dev/pts/2
262
+ D, [2010-07-31T07:37:35.724989 #16613] DEBUG -- : handling exit of process 16615
263
+ D, [2010-07-31T07:37:35.725153 #16613] DEBUG -- : checking exit against exit with status 0
264
+ D, [2010-07-31T07:37:35.725323 #16613] DEBUG -- : match trigger exit with status 0
265
+ D, [2010-07-31T07:37:35.725445 #16613] DEBUG -- : unblocked
266
+ D, [2010-07-31T07:37:35.725571 #16613] DEBUG -- : trigger removed
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "greenletters"
5
+ s.version = "0.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Avdi Grimm"]
9
+ s.date = "2012-07-31"
10
+ s.description = " Greenletterrs is a console automation framework, similar to the classic\n utility Expect. You give it a command to execute, and tell it which outputs\n or events to expect and how to respond to them.\n\n Greenletters also includes a set of Cucumber steps which simplify the task\n of spcifying interactive command-line applications.\n"
11
+ s.email = "avdi@avdi.org"
12
+ s.executables = ["greenletters"]
13
+ s.extra_rdoc_files = ["History.txt", "bin/greenletters"]
14
+ s.files = [".gitignore", "Gemfile", "Gemfile.lock", "History.txt", "README.org", "Rakefile", "bin/greenletters", "examples/adventure.rb", "examples/cucumber/adventure.feature", "examples/cucumber/greenletters.log", "examples/cucumber/support/env.rb", "examples/greenletters.log", "greenletters.gemspec", "lib/greenletters.rb", "lib/greenletters/cucumber_steps.rb", "script/console", "spec/greenletters_spec.rb", "spec/spec_helper.rb", "version.txt"]
15
+ s.homepage = "http://github.com/avdi/greenletters"
16
+ s.rdoc_options = ["--main", "README.org"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = "greenletters"
19
+ s.rubygems_version = "1.8.10"
20
+ s.summary = "A Ruby console automation framework a la Expect"
21
+
22
+ if s.respond_to? :specification_version then
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<bones>, [">= 3.8.0"])
27
+ else
28
+ s.add_dependency(%q<bones>, [">= 3.8.0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<bones>, [">= 3.8.0"])
32
+ end
33
+ end
@@ -1,13 +1,24 @@
1
1
  require 'cucumber'
2
+ require 'shellwords'
2
3
 
3
4
  module Greenletters
4
5
  module CucumberHelpers
5
6
  def greenletters_prepare_entry(text)
6
7
  text.chomp + "\n"
7
8
  end
9
+
8
10
  def greenletters_massage_pattern(text)
9
11
  Regexp.new(Regexp.escape(text.strip.tr_s(" \r\n\t", " ")).gsub('\ ', '\s+'))
10
12
  end
13
+
14
+ # Override this in your Cucumber setup to customize how processes are
15
+ # constructed.
16
+ def make_greenletters_process(command_line, options = {})
17
+ command = Shellwords.shellwords(command_line)
18
+ options[:logger] = @greenletters_process_log if @greenletters_process_log
19
+ process_args = command + [options]
20
+ Greenletters::Process.new(*process_args)
21
+ end
11
22
  end
12
23
  end
13
24
 
@@ -20,7 +31,7 @@ Before do
20
31
  end
21
32
 
22
33
  Given /^process activity is logged to "([^\"]*)"$/ do |filename|
23
- logger = ::Logger.new(open(filename, 'w+'))
34
+ logger = ::Logger.new(open(filename, 'a+'))
24
35
  #logger.level = ::Logger::INFO
25
36
  logger.level = ::Logger::DEBUG
26
37
  @greenletters_process_log = logger
@@ -28,10 +39,13 @@ end
28
39
 
29
40
  Given /^a process (?:"([^\"]*)" )?from command "([^\"]*)"$/ do |name, command|
30
41
  name ||= "default"
31
- options = {
32
- }
33
- options[:logger] = @greenletters_process_log if @greenletters_process_log
34
- @greenletters_process_table[name] = Greenletters::Process.new(command, options)
42
+ @greenletters_process_table[name] = make_greenletters_process(command)
43
+ end
44
+
45
+ Given /^the process(?: "([^\"]*)")? has a timeout of ([0-9.]+) seconds$/ do
46
+ |name, length|
47
+ name ||= :"default"
48
+ @greenletters_process_table[name].timeout = length.to_f
35
49
  end
36
50
 
37
51
  Given /^I reply "([^\"]*)" to output "([^\"]*)"(?: from process "([^\"]*)")?$/ do
@@ -71,8 +85,9 @@ end
71
85
  Then /^I should see the following output(?: from process "([^\"]*)")?:$/ do
72
86
  |name, pattern|
73
87
  name ||= "default"
88
+ process = @greenletters_process_table[name]
74
89
  pattern = greenletters_massage_pattern(pattern)
75
- @greenletters_process_table[name].wait_for(:output, pattern)
90
+ process.wait_for(:output, pattern)
76
91
  end
77
92
 
78
93
  Then /^I should see all the following outputs(?: from process "([^\"]*)")?:$/ do
data/lib/greenletters.rb CHANGED
@@ -103,7 +103,7 @@ module Greenletters
103
103
  def <<(output)
104
104
  @buffer << output
105
105
  @transcript << output
106
- length = [@buffer.length, 256].min
106
+ length = [@buffer.length, 512].min
107
107
  @buffer = @buffer[-length, length]
108
108
  self
109
109
  end
@@ -128,7 +128,7 @@ module Greenletters
128
128
  alias_method :exclusive?, :exclusive
129
129
 
130
130
  def initialize(options={}, &block)
131
- @block = block || lambda{}
131
+ @block = block || lambda{|*|}
132
132
  @exclusive = options.fetch(:exclusive) { false }
133
133
  @logger = ::Logger.new($stdout)
134
134
  @interruption = :none
@@ -242,7 +242,7 @@ module Greenletters
242
242
  end
243
243
 
244
244
  def call(process)
245
- if pattern === process.status.exitstatus
245
+ if process.status && pattern === process.status.exitstatus
246
246
  @block.call(process, process.status)
247
247
  true
248
248
  else
@@ -267,17 +267,18 @@ module Greenletters
267
267
  end
268
268
 
269
269
  class Process
270
- END_MARKER = '__GREENLETTERS_PROCESS_ENDED__'
271
- DEFAULT_LOG_LEVEL = ::Logger::WARN
270
+ END_MARKER = '__GREENLETTERS_PROCESS_ENDED__'
271
+ DEFAULT_LOG_LEVEL = ::Logger::WARN
272
+ DEFAULT_TIMEOUT = 1.0
272
273
 
273
274
  # Shamelessly stolen from Rake
274
275
  RUBY_EXT =
275
- ((Config::CONFIG['ruby_install_name'] =~ /\.(com|cmd|exe|bat|rb|sh)$/) ?
276
+ ((RbConfig::CONFIG['ruby_install_name'] =~ /\.(com|cmd|exe|bat|rb|sh)$/) ?
276
277
  "" :
277
- Config::CONFIG['EXEEXT'])
278
+ RbConfig::CONFIG['EXEEXT'])
278
279
  RUBY = File.join(
279
- Config::CONFIG['bindir'],
280
- Config::CONFIG['ruby_install_name'] + RUBY_EXT).
280
+ RbConfig::CONFIG['bindir'],
281
+ RbConfig::CONFIG['ruby_install_name'] + RUBY_EXT).
281
282
  sub(/.*\s.*/m, '"\&"')
282
283
 
283
284
  extend Forwardable
@@ -289,6 +290,10 @@ module Greenletters
289
290
  attr_reader :output_buffer # Output ready to be read from process
290
291
  attr_reader :status # :not_started -> :running -> :ended -> :exited
291
292
  attr_reader :cwd # Working directory for the command
293
+ attr_reader :input
294
+ attr_reader :output
295
+ attr_reader :pid
296
+ attr_accessor :timeout
292
297
 
293
298
  def_delegators :input_buffer, :puts, :write, :print, :printf, :<<
294
299
  def_delegators :output_buffer, :rest, :rest_size, :check_until
@@ -318,6 +323,7 @@ module Greenletters
318
323
  t
319
324
  }
320
325
  @history = TranscriptHistoryBuffer.new(@transcript)
326
+ @timeout = options.fetch(:timeout) { DEFAULT_TIMEOUT }
321
327
  end
322
328
 
323
329
  def on(event, *args, &block)
@@ -327,6 +333,7 @@ module Greenletters
327
333
  def wait_for(event, *args, &block)
328
334
  raise "Already waiting for #{blocker}" if blocker
329
335
  t = add_blocking_trigger(event, *args, &block)
336
+ @logger.debug "Entering wait cycle for #{event}"
330
337
  process_events
331
338
  rescue
332
339
  unblock!
@@ -376,11 +383,10 @@ module Greenletters
376
383
  cmd = wrapped_command
377
384
  @logger.debug "executing #{cmd.join(' ')}"
378
385
  merge_environment(@env) do
379
- @logger.debug "command environment:\n#{ENV.inspect}"
380
386
  @output, @input, @pid = PTY.spawn(*cmd)
381
387
  end
382
388
  @state = :running
383
- @logger.debug "spawned pid #{@pid}"
389
+ @logger.debug "spawned pid #{@pid}; in: #{@input.inspect}; out: #{@output.inspect}"
384
390
  end
385
391
  end
386
392
 
@@ -389,6 +395,12 @@ module Greenletters
389
395
  @output_buffer.terminate
390
396
  end
391
397
 
398
+ def kill!(signal="TERM")
399
+ handle_child_exit do
400
+ ::Process.kill(signal, @pid)
401
+ end
402
+ end
403
+
392
404
  def alive?
393
405
  ::Process.kill(0, @pid)
394
406
  true
@@ -421,6 +433,10 @@ module Greenletters
421
433
  Time.now
422
434
  end
423
435
 
436
+ def to_s
437
+ "Process<pid: #{pid}; in: #{input.inspect}; out: #{output.inspect}>"
438
+ end
439
+
424
440
  private
425
441
 
426
442
  attr_reader :triggers
@@ -439,14 +455,15 @@ module Greenletters
439
455
  raise StateError, "Process not started!" if not_started?
440
456
  handle_child_exit do
441
457
  while blocked?
442
- @logger.debug "select()"
443
458
  input_handles = input_buffer.string.empty? ? [] : [@input]
444
459
  output_handles = [@output]
445
- error_handles = [@input, @output]
460
+ error_handles = [@input, @output].uniq
446
461
  timeout = shortest_timeout
447
462
  @logger.debug "select() on #{[output_handles, input_handles, error_handles, timeout].inspect}"
463
+
448
464
  ready_handles = IO.select(
449
465
  output_handles, input_handles, error_handles, timeout)
466
+
450
467
  if ready_handles.nil?
451
468
  process_timeout
452
469
  else
@@ -625,13 +642,14 @@ module Greenletters
625
642
  raise SystemError,
626
643
  "Interrupted (#{reason}) while waiting for #{blocker}.\n" \
627
644
  "Recent activity:\n" +
628
- @history.buffer
645
+ @history.buffer + "\n" + ("-" * 60) + "\n"
629
646
  end
630
647
  unblock!
631
648
  end
632
649
  end
633
650
 
634
651
  def catchup_trigger!(trigger)
652
+ @logger.debug "Catching up trigger #{trigger}"
635
653
  check_trigger(trigger)
636
654
  end
637
655
 
@@ -647,7 +665,7 @@ module Greenletters
647
665
  result = triggers.grep(TimeoutTrigger).map{|t|
648
666
  t.expiration_time - Time.now
649
667
  }.min
650
- if result.nil? then result = 1.0 end
668
+ if result.nil? then result = @timeout end
651
669
  if result < 0 then result = 0 end
652
670
  result
653
671
  end
@@ -655,4 +673,3 @@ module Greenletters
655
673
  end
656
674
 
657
675
  Greenletters.require_all_libs_relative_to(__FILE__)
658
-
@@ -1,4 +1,3 @@
1
-
2
1
  require File.join(File.dirname(__FILE__), %w[spec_helper])
3
2
 
4
3
  describe Greenletters do
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,4 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib greenletters]))
1
2
 
2
- require File.expand_path(
3
- File.join(File.dirname(__FILE__), %w[.. lib greenletters]))
4
-
5
- Spec::Runner.configure do |config|
6
- # == Mock Framework
7
- #
8
- # RSpec uses it's own mocking framework by default. If you prefer to
9
- # use mocha, flexmock or RR, uncomment the appropriate line:
10
- #
11
- # config.mock_with :mocha
12
- # config.mock_with :flexmock
13
- # config.mock_with :rr
3
+ RSpec.configure do |config|
14
4
  end
15
-
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0