Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created July 4, 2010 17:46
Show Gist options
  • Save 3rd-Eden/463613 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/463613 to your computer and use it in GitHub Desktop.
The testrunner I used for the YUI compressor port
#!/usr/bin/python2.4
import os, re
import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from cssmin import compressor
class test(webapp.RequestHandler):
def get(self):
self.response.headers['content-type'] = 'text/html'
dirList = os.listdir('tests')
for fname in dirList:
if re.match( r'^.DS', fname ) or not os.path.isfile( 'tests/' +fname + '.min' ):
continue
# read the files, minified and regular
concatenate = []
concatenate.extend( open( 'tests/' + fname,'r' ).readlines() )
result = []
result.extend( open( 'tests/' + fname + '.min','r' ).readlines() )
concatenate = ''.join( concatenate )
result = ''.join( result )
logging.error('Starting testcase: %s' % fname )
compressed = compressor().cssmin( concatenate, -1 )
if compressed == result:
self.response.out.write( "<p style='color:green'>Passed test %s</p>" % fname )
else:
self.response.out.write( "<p style='color:red;font-weight:bold'>Failed test %s</p>" % fname )
self.response.out.write( "<textarea style='border:1px solid red; width:300px; margin-right:5px'>%s</textarea>" % compressed )
self.response.out.write( "<textarea style='border:1px solid green; width:300px;'>%s</textarea>" % result )
def main():
interface = webapp.WSGIApplication(
[
('/', test)
], debug=True)
util.run_wsgi_app(interface)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment