Skip to content

Commit e5b14d1

Browse files
authored
When serve_localhost.py of base dir, also print link to CTS Test Runner. (#3723)
Example output: ``` k@pakhet webgl % ./serve_localhost.py Serving /Users/k/dev/moz/webgl: http://localhost:8000/ CTS Test Runner: http://localhost:8000/sdk/tests/webgl-conformance-tests.html ```
1 parent 1b0c44d commit e5b14d1

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

serve_localhost.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import http.server
88
import os
9+
from pathlib import *
910

1011
from functools import partial
1112

@@ -25,7 +26,10 @@ def end_headers(self):
2526
parser.add_argument('--bind', '-b', default='localhost', metavar='ADDRESS',
2627
help='Specify alternate bind address '
2728
'[default: localhost - pass \'\' if you want to serve remote clients]')
28-
parser.add_argument('--directory', '-d', default=os.getcwd(),
29+
parser.add_argument('--port', action='store',
30+
default=8000, type=int,
31+
help='Specify alternate port [default: 8000]')
32+
parser.add_argument('--directory', '-d',
2933
help='Specify alternative directory '
3034
'[default:current directory]')
3135
parser.add_argument('port', action='store',
@@ -34,9 +38,18 @@ def end_headers(self):
3438
help='Specify alternate port [default: 8000]')
3539
args = parser.parse_args()
3640

37-
handler_class = partial(NoCacheRequestHandler, directory=args.directory)
41+
serve_dir = Path(os.getcwd())
42+
if args.directory:
43+
serve_dir = Path(args.directory)
44+
45+
handler_class = partial(NoCacheRequestHandler, directory=serve_dir)
3846

47+
checkout_dir = Path(__file__).parent
48+
url = f'http://{args.bind}:{args.port}'
3949
server = http.server.ThreadingHTTPServer((args.bind, args.port), handler_class)
40-
print('Serving ThreadingHTTPServer for', args, 'at:')
41-
print(f'\thttp://{args.bind}:{args.port}/')
50+
print(f'Serving {serve_dir}:')
51+
print(f'\t{url}/')
52+
if serve_dir == checkout_dir:
53+
print(f'CTS Test Runner:')
54+
print(f'\t{url}/sdk/tests/webgl-conformance-tests.html')
4255
server.serve_forever()

0 commit comments

Comments
 (0)