@@ -59,172 +59,6 @@ def bowerProperty(name):
59
59
if os .environ .get ("CI" ,False ):
60
60
nul = "/dev/null"
61
61
62
- def debugbrowser ():
63
- tmpl = """
64
- <!DOCTYPE HTML>
65
- <html>
66
- <head>
67
- <meta http-equiv="X-UA-Compatible" content="IE=edge" >
68
- <title>Skulpt test</title>
69
- <style>
70
- .type { font-size:14px; font-weight:bold; font-family:arial; background-color:#f7f7f7; text-align:center }
71
- </style>
72
- <script src="../../dist/skulpt.js" type="text/javascript"></script>
73
- <script src="../../dist/skulpt-stdlib.js" type="text/javascript"></script>
74
- <script src="vfs.js" type="text/javascript"></script>
75
- <script src="../../test/test.js" type="text/javascript"></script>
76
- </head>
77
-
78
- <body onload="testsMain()">
79
- <canvas id="__webglhelpercanvas" style="border: none;" width="500" height="500"></canvas>
80
- <table>
81
- <tr>
82
- <td>
83
- <div id="one-test" class="use-arrow"></div>
84
- </td>
85
- </tr>
86
- <tr>
87
- <td>
88
- <pre id="output"></pre>
89
- </td>
90
- <td>
91
- <span id="canv"></span>
92
- </td>
93
- </tr>
94
- </body>
95
- </html>
96
- """
97
- if not os .path .exists ("support/tmp" ):
98
- os .mkdir ("support/tmp" )
99
- buildVFS ()
100
-
101
- with open ("support/tmp/test.html" , "w" ) as f :
102
- print >> f , tmpl
103
-
104
- if sys .platform == "win32" :
105
- os .system ("start support/tmp/test.html" )
106
- elif sys .platform == "darwin" :
107
- os .system ("open support/tmp/test.html" )
108
- else :
109
- os .system ("xdg-open support/tmp/test.html" )
110
-
111
- def buildVFS ():
112
- """ build a silly virtual file system to support 'read'"""
113
- print ". Slurping test data"
114
- with open ("support/tmp/vfs.js" , "w" ) as out :
115
- print >> out , "VFSData = {"
116
- all = []
117
- for root in (TEST_DIR , "src/builtin" , "src/lib" ):
118
- for dirpath , dirnames , filenames in os .walk (root ):
119
- for filename in filenames :
120
- f = os .path .join (dirpath , filename )
121
- if ".svn" in f : continue
122
- if ".swp" in f : continue
123
- if ".pyc" in f : continue
124
- data = open (f , "rb" ).read ()
125
- data = data .replace ("\r \n " , "\n " )
126
- all .append ("'%s': '%s'" % (f .replace ("\\ " , "/" ), data .encode ("hex" )))
127
- print >> out , ",\n " .join (all )
128
- print >> out , "};"
129
- print >> out , """
130
-
131
- function readFromVFS(fn)
132
- {
133
- var hexToStr = function(str)
134
- {
135
- var ret = "";
136
- for (var i = 0; i < str.length; i += 2)
137
- ret += unescape("%" + str.substr(i, 2));
138
- return ret;
139
- }
140
- if (VFSData[fn] === undefined) throw "file not found: " + fn;
141
- return hexToStr(VFSData[fn]);
142
- }
143
- """
144
-
145
- def buildBrowserTests ():
146
- """combine all the tests data into something we can run from a browser
147
- page (so that it can be tested in the various crappy engines)
148
-
149
- we want to use the same code that the command line version of the tests
150
- uses so we stub the d8 functions to push to the browser."""
151
-
152
- outfn = "doc/static/browser-test.js"
153
- out = open (outfn , "w" )
154
-
155
- print >> out , """
156
- window.addevent('onload', function(){
157
- """
158
-
159
- # stub the d8 functions we use
160
- print >> out , """
161
- function read(fn)
162
- {
163
- var hexToStr = function(str)
164
- {
165
- var ret = "";
166
- for (var i = 0; i < str.length; i += 2)
167
- ret += unescape("%%" + str.substr(i, 2));
168
- return ret;
169
- }
170
- if (VFSData[fn] === undefined) throw "file not found: " + fn;
171
- return hexToStr(VFSData[fn]);
172
- }
173
- var SkulptTestRunOutput = '';
174
- function print()
175
- {
176
- var out = document.getElementById("output");
177
- for (var i = 0; i < arguments.length; ++i)
178
- {
179
- out.innerHTML += arguments[i];
180
- SkulptTestRunOutput += arguments[i];
181
- out.innerHTML += " ";
182
- SkulptTestRunOutput += " ";
183
- }
184
- out.innerHTML += "<br/>"
185
- SkulptTestRunOutput += "\\ n";
186
- }
187
-
188
- function quit(rc)
189
- {
190
- var out = document.getElementById("output");
191
- if (rc === 0)
192
- {
193
- out.innerHTML += "<font color='green'>OK</font>";
194
- }
195
- else
196
- {
197
- out.innerHTML += "<font color='red'>FAILED</font>";
198
- }
199
- out.innerHTML += "<br/>Saving results...";
200
- var sendData = JSON.encode({
201
- browsername: BrowserDetect.browser,
202
- browserversion: BrowserDetect.version,
203
- browseros: BrowserDetect.OS,
204
- version: '%s',
205
- rc: rc,
206
- results: SkulptTestRunOutput
207
- });
208
- var results = new Request.JSON({
209
- url: '/testresults',
210
- method: 'post',
211
- onSuccess: function() { out.innerHTML += "<br/>Results saved."; },
212
- onFailure: function() { out.innerHTML += "<br/>Couldn't save results."; }
213
- });
214
- results.send(sendData);
215
- }
216
- """ % getTip ()
217
-
218
- # for f in ["{0}/browser-detect.js".format(TEST_DIR)] + getFileList(FILE_TYPE_TEST) + TestFiles:
219
- # print >>out, open(f).read()
220
-
221
- print >> out , """
222
- });
223
- """
224
- out .close ()
225
- print ". Built %s" % outfn
226
-
227
-
228
62
def regenasttests (togen = "{0}/run/*.py" .format (TEST_DIR )):
229
63
"""regenerate the ast test files by running our helper script via real python"""
230
64
for f in glob .glob (togen ):
@@ -236,7 +70,6 @@ def regenasttests(togen="{0}/run/*.py".format(TEST_DIR)):
236
70
if crlfprog :
237
71
os .system ("python {0} {1}" .format (crlfprog , transname ))
238
72
239
-
240
73
def regenruntests (togen = "{0}/run/*.py" .format (TEST_DIR )):
241
74
"""regenerate the test data by running the tests on real python"""
242
75
for f in glob .glob (togen ):
@@ -343,35 +176,6 @@ def __init__(self, name, vmx, guestloc):
343
176
#"chromed-ubu": ubu,
344
177
]
345
178
346
- import SimpleHTTPServer
347
- import urlparse
348
- class HttpHandler (SimpleHTTPServer .SimpleHTTPRequestHandler ):
349
- """allow grabbing any file for testing, and support /import
350
- which grabs all builtin and lib modules in a json request.
351
-
352
- see notes on import for why we can't just grab one at a time.
353
-
354
- on real hosting, we'll just prebuild/gzip the stdlib into somewhere on
355
- upload. this is more convenient during dev on localhost though.
356
-
357
- """
358
- def do_GET (self ):
359
- prefix = "/import"
360
- if self .path == prefix :
361
- self .send_response (200 )
362
- self .send_header ("Content-type" , "application/json" )
363
- self .end_headers ()
364
- self .wfile .write (getBuiltinsAsJson (None ))
365
- else :
366
- SimpleHTTPServer .SimpleHTTPRequestHandler .do_GET (self )
367
-
368
- def host (PORT = 20710 ):
369
- """simple http host from root of dir for testing"""
370
- import SocketServer
371
- httpd = SocketServer .TCPServer (("" , PORT ), HttpHandler )
372
- print "serving at port" , PORT
373
- httpd .serve_forever ()
374
-
375
179
def usageString (program ):
376
180
return '''
377
181
@@ -385,11 +189,6 @@ def usageString(program):
385
189
regentests Regenerate all of the above
386
190
387
191
help Display help information about Skulpt
388
- host [PORT] Start a simple HTTP server for testing. Default port: 20710
389
- browser Run all tests in the browser
390
- vfs Build a virtual file system to support Skulpt read tests
391
-
392
- debugbrowser Debug in the browser -- open your javascript console
393
192
394
193
Options:
395
194
@@ -440,21 +239,6 @@ def main():
440
239
regenasttests ()
441
240
elif cmd == "regenruntests" :
442
241
regenruntests ()
443
- elif cmd == "browser" :
444
- buildBrowserTests ()
445
- elif cmd == "debugbrowser" :
446
- debugbrowser ()
447
- elif cmd == "vfs" :
448
- buildVFS ()
449
- elif cmd == "host" :
450
- if len (sys .argv ) < 3 :
451
- host ()
452
- else :
453
- try :
454
- host (int (sys .argv [2 ]))
455
- except ValueError :
456
- print "Port must be an integer"
457
- sys .exit (2 )
458
242
else :
459
243
print usageString (os .path .basename (sys .argv [0 ]))
460
244
sys .exit (2 )
0 commit comments