Skip to content

Commit 7f10ac2

Browse files
committed
Added test to target specific libraries and their examples.
Target libraries can be passed as comma seperated command line arguments. e.g. ./seleniumbender target aJSON,AFMotor
1 parent 17b1725 commit 7f10ac2

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

bin/seleniumbender

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ sketches=0
1919
staging=0
2020
noplugin=0
2121
walkthrough=0
22+
target=0
2223

2324
while true; do
2425
case "$1" in
@@ -37,6 +38,12 @@ while true; do
3738
;;
3839
examples) examples=1
3940
;;
41+
target) compile=1
42+
shift
43+
target=1
44+
TARGETS=$@
45+
break
46+
;;
4047
sketches) sketches=1
4148
;;
4249
staging) staging=1
@@ -118,6 +125,9 @@ elif [ "${walkthrough}" -eq 1 ]; then
118125
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" ${EMAIL} <<< 'Something went wrong with noplugin tests. Please check the logs.'
119126
fi
120127
exit ${RETVAL}
128+
elif [ "${target}" -eq 1 ]; then
129+
IDENTIFIER="test_target_libraries"
130+
tox tests/target_libraries -- --url=${URL} --source=${SOURCE} -F --plugin --libraries=${TARGETS}
121131
fi
122132

123133
DATE=$(date +"%Y-%m-%d") # Get the current date

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def pytest_addoption(parser):
3737
default=False,
3838
help="Install plugin in Firefox profile")
3939

40+
parser.addoption("-L", "--libraries", action="store",
41+
default='',
42+
help="Target libraries to test")
43+
4044

4145
def pytest_generate_tests(metafunc):
4246
"""Special function used by pytest to configure test generation."""

tests/target_libraries/__init__.py

Whitespace-only changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from codebender_testing.config import LIBRARIES_TEST_LOGFILE
2+
from codebender_testing.utils import SeleniumTestCase
3+
from codebender_testing.config import LOGFILE_PREFIX
4+
5+
import pytest
6+
7+
LOG_FILE = LOGFILE_PREFIX.format(log_name="test_target_libraries")
8+
9+
GET_ALL_LIBRARIES_SCRIPT = """
10+
var libraries = {};
11+
var humanNameRegExp = /^.+\((.+)\)$/;
12+
$('#mycontainer').find('.library-expand-handle').map(function () {
13+
var libraryName = $(this).text();
14+
if (humanNameRegExp.test(libraryName)) {
15+
libraryName = libraryName.match(humanNameRegExp)[1].trim().replace(/\.h/, '');
16+
}
17+
libraries[libraryName] = $(this).parent().find('.library_link').attr('href');
18+
});
19+
return libraries;
20+
"""
21+
22+
GET_LIBRARY_EXAMPLES_SCRIPT = """
23+
var examples = [];
24+
$('#mycontainer').find('.list-group .list-group-item a').map(function () {
25+
examples.push(this.href);
26+
});
27+
return examples;
28+
"""
29+
30+
31+
class TestLibraryExamples(SeleniumTestCase):
32+
33+
def test_compile_target_libraries(self):
34+
targets = pytest.config.getoption("--libraries").split(',')
35+
36+
self.open('/libraries')
37+
libraries = self.execute_script(GET_ALL_LIBRARIES_SCRIPT, '$')
38+
39+
urls_to_follow = []
40+
for target in targets:
41+
if target in libraries:
42+
library_url = libraries[target]
43+
self.open(library_url)
44+
urls_to_follow += self.execute_script(GET_LIBRARY_EXAMPLES_SCRIPT, '$')
45+
46+
if len(urls_to_follow) > 0:
47+
"""Tests that specific library examples compile successfully."""
48+
self.compile_sketches(urls_to_follow,
49+
compile_type='library',
50+
iframe=False, project_view=True,
51+
create_report=True, logfile=LOG_FILE,
52+
comment=True)

0 commit comments

Comments
 (0)