git @ Cat's Eye Technologies Falderal / 5d35500
Add some adapters that can be used in shell test implementations. Chris Pressey 7 years ago
5 changed file(s) with 90 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
55 * Removed the old, bitrotting Haskell implementation.
66 * Removed deprecated `%(test-text)` and `%(test-file)` variables
77 (`%(test-body-text)` and `%(test-body-file)` should be used now.)
8 * Added some adapters in the `script/` directory of the repo.
89
910 Version 0.9-2014.0525 "Municipal Pier #2, May 25th 2014" (current released
1011 version):
5353 POSSIBILITY OF SUCH DAMAGE.
5454
5555 -----------------------------------------------------------------------------
56
57 The adapters in the `script` subdirectory are in the public domain,
58 and covered under the following UNLICENSE:
59
60 -----------------------------------------------------------------------------
61
62 This is free and unencumbered software released into the public domain.
63
64 Anyone is free to copy, modify, publish, use, compile, sell, or
65 distribute this software, either in source code form or as a compiled
66 binary, for any purpose, commercial or non-commercial, and by any
67 means.
68
69 In jurisdictions that recognize copyright laws, the author or authors
70 of this software dedicate any and all copyright interest in the
71 software to the public domain. We make this dedication for the benefit
72 of the public at large and to the detriment of our heirs and
73 successors. We intend this dedication to be an overt act of
74 relinquishment in perpetuity of all present and future rights to this
75 software under copyright law.
76
77 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
78 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
80 IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
81 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
82 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
83 OTHER DEALINGS IN THE SOFTWARE.
84
85 For more information, please refer to <http://unlicense.org/>
86
87 -----------------------------------------------------------------------------
0 #!/usr/bin/env python
1
2 # converts raw bytes on input to hex couples on input.
3
4 import sys
5
6 while True:
7 byte = sys.stdin.read(1)
8 if len(byte) < 1:
9 sys.exit(0)
10 sys.stdout.write('%02x' % ord(byte))
0 #!/usr/bin/env python
1
2 # converts hex couples on input to raw bytes on output.
3
4 import sys
5
6 while True:
7 hex = sys.stdin.read(2)
8 if len(hex) < 2:
9 sys.exit(0)
10 sys.stdout.write(chr(int(hex, 16)))
0 #!/usr/bin/env python
1
2 import pty
3 import sys
4 import os
5
6
7 command = sys.argv[1]
8 args = sys.argv[2:]
9
10 (pid, fd) = pty.fork()
11 if pid == 0:
12 # I'm the child
13 os.execvp(command, [command] + args)
14 else:
15 # I'm the parent
16 accum = ''
17 SIZE = 1024
18 done = False
19 while not done:
20 s = os.read(fd, SIZE)
21 if len(s) < SIZE:
22 done = True
23 accum += s
24 (pid, exitcode) = os.waitpid(pid, 0)
25 core_dumped = (exitcode & 128) == 128
26 exitcode = exitcode >> 8
27 if core_dumped and exitcode == 0:
28 # force the exitcode to non-zero if we dumped core.
29 exitcode = 1
30 if exitcode == 0:
31 sys.stdout.write(s)
32 else:
33 sys.stderr.write(s)
34 sys.exit(exitcode)