Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kasra Jamshidi
slapos
Commits
57d2e3ba
Commit
57d2e3ba
authored
Oct 26, 2016
by
Douglas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jstestnode: parsing test results with lxml for much better parsing performance
parent
efd39c9a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
software/jstestnode/runTestSuite.in
software/jstestnode/runTestSuite.in
+17
-11
software/jstestnode/software.cfg
software/jstestnode/software.cfg
+2
-1
No files found.
software/jstestnode/runTestSuite.in
View file @
57d2e3ba
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
import argparse, os, re, shutil, subprocess, sys, traceback
import argparse, os, re, shutil, subprocess, sys, traceback
from erp5.util import taskdistribution
from erp5.util import taskdistribution
from time import gmtime, strftime
from time import gmtime, strftime
from lxml import etree
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
...
@@ -62,29 +63,34 @@ def main():
...
@@ -62,29 +63,34 @@ def main():
By.XPATH, '//p[@id="qunit-testresult" and contains(text(), "completed")]')
By.XPATH, '//p[@id="qunit-testresult" and contains(text(), "completed")]')
))
))
html_parser = etree.HTMLParser(recover=True)
body = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser)
browser.title.encode('UTF-8')
browser.title.encode('UTF-8')
print browser.find_element_by_id("qunit-testresult").text
browser.quit()
print ' '.join(body.xpath('//*[@id="qunit-testresult"]//text()'))
for elt in b
rowser.find_elements_by_xpath('
//ol[@id="qunit-tests"]/li'):
for elt in b
ody.xpath('.
//ol[@id="qunit-tests"]/li'):
test_name = '%s: %s' % (
test_name = '%s: %s' % (
elt.
find_element_by_xpath('.//span[@class="module-name"]')
.text,
elt.
xpath('.//span[@class="module-name"]')[0]
.text,
elt.
find_element_by_xpath('.//span[@class="test-name"]')
.text
elt.
xpath('.//span[@class="test-name"]')[0]
.text
)
)
print elt.get
_attribute('class'), elt.find_element_by_tag_name('strong').text
print elt.get
('class'), ''.join(elt.xpath('.//strong')[0].itertext())
# print elt.find_element_by_tag_name('ol').get_attribute('innerHTML')
# print elt.find_element_by_tag_name('ol').get_attribute('innerHTML')
failure = int(elt.
find_element_by_xpath('.//b[@class="failed"]')
.text)
failure = int(elt.
xpath('.//b[@class="failed"]')[0]
.text)
success = int(elt.
find_element_by_xpath('.//b[@class="passed"]')
.text)
success = int(elt.
xpath('.//b[@class="passed"]')[0]
.text)
test_line_dict[test_name] = {
test_line_dict[test_name] = {
'test_count': success + failure,
'test_count': success + failure,
'error_count': 0,
'error_count': 0,
'failure_count': failure,
'failure_count': failure,
'skip_count': 0,
'skip_count': 0,
'duration': int(elt.
find_element_by_xpath('.//span[@class="runtime"]')
.text.split()[0]),
'duration': int(elt.
xpath('.//span[@class="runtime"]')[0]
.text.split()[0]),
'command': elt.
find_element_by_xpath('.//a[text()="Rerun"]').get_attribute
('href'),
'command': elt.
xpath('.//a[text()="Rerun"]')[0].get
('href'),
'stdout': agent,
'stdout': agent,
'stderr': '',
'stderr': '',
'html_test_result': e
lt.find_element_by_tag_name('ol').get_attribute('innerHTML'
)
'html_test_result': e
tree.tostring(elt.xpath('.//ol')[0]
)
}
}
tool = taskdistribution.TaskDistributionTool(portal_url=args.master_url)
tool = taskdistribution.TaskDistributionTool(portal_url=args.master_url)
...
...
software/jstestnode/software.cfg
View file @
57d2e3ba
...
@@ -35,6 +35,7 @@ recipe = zc.recipe.egg
...
@@ -35,6 +35,7 @@ recipe = zc.recipe.egg
eggs =
eggs =
erp5.util
erp5.util
selenium
selenium
lxml
interpreter = pythonwitheggs
interpreter = pythonwitheggs
[renderjs-repository.git]
[renderjs-repository.git]
...
@@ -106,7 +107,7 @@ mode = 0644
...
@@ -106,7 +107,7 @@ mode = 0644
[template-runTestSuite]
[template-runTestSuite]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/runTestSuite.in
url = ${:_profile_base_location_}/runTestSuite.in
md5sum =
13a56b1b6b2d54dc27ed6570e4b5f1d7
md5sum =
88e820d30b36ecca9b45242ce4a52039
output = ${buildout:directory}/runTestSuite.in
output = ${buildout:directory}/runTestSuite.in
mode = 0644
mode = 0644
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment