Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: samples/third_party/dromaeo/generate_dart2js_tests.py

Issue 178223008: Replace run_selenium.py with Dart script that uses the browser controller for performance tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 import glob
4 import os
5 import os.path
6 import platform
7 import re
8 import subprocess
9 import sys
10
11 SAMPLES_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(_ _file__))))
12 DART_PATH = os.path.dirname(SAMPLES_PATH)
13 TOOLS_PATH = os.path.join(DART_PATH, 'tools')
14
15 sys.path.append(TOOLS_PATH)
16 import utils
17
18 EXECUTABLE_MAP = {
19 'frog': 'frogc',
20 'dart2js': 'dart2js'
21 }
22
23 def Compile(source, target, compiler):
24 executable = EXECUTABLE_MAP[compiler]
25 binary = os.path.abspath(os.path.join(DART_PATH,
26 utils.GetBuildRoot(utils.GuessOS(),
27 'release', 'ia32'),
28 'dart-sdk', 'bin', executable))
29
30 cmd = [binary, '--out=' + target]
31 cmd.append(source)
32 print 'Executing: ' + ' '.join(cmd)
33 if platform.system() == "Windows":
34 subprocess.call(cmd, shell=True)
35 else:
36 subprocess.call(cmd)
37
38 def HtmlConvert(infile, compiler):
39 (head, tail) = os.path.split(infile)
40
41 if head == 'tests':
42 outdir = compiler
43 os.chdir('tests')
44 if not os.path.exists(outdir):
45 os.makedirs(outdir)
46 elif head == '':
47 outdir = '.'
48 else:
49 raise 'Illegal input: ' + infile
50
51 pattern = r'<script type="application/dart" src="([\w-]+).dart">'
52 infile = open(tail, 'r')
53 outfilename = os.path.join(outdir, tail.replace('.html', '-js.html'))
54 outfile = open(outfilename, 'w')
55
56 print 'Converting %s to %s' % (tail, outfilename)
57 for line in infile:
58 result = re.search(pattern, line)
59 if result:
60 testname = result.group(1)
61 dartname = testname + '.dart'
62 jsname = '%s.%s.js' % (testname, compiler)
63 outname = os.path.join(outdir, jsname)
64 Compile(dartname, outname, compiler)
65 script = '<script type="text/javascript" src="%s" defer>' % jsname
66 outfile.write(re.sub(pattern, script, line))
67 else:
68 outfile.write(line)
69
70 if head == 'tests':
71 os.chdir('..')
72
73 # Compile individual html tests.
74 tests = glob.glob('tests/dom-*-html.html')
75
76 for test in tests:
77 HtmlConvert(test, 'dart2js')
78
79 # Compile driver to index-js.html.
80 HtmlConvert('index.html', 'dart2js')
OLDNEW
« no previous file with comments | « samples/third_party/dromaeo/dromaeo_end_condition.js ('k') | samples/third_party/dromaeo/generate_perf_and_dart2js_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698