Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
package_control_channel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
package_control_channel
Commits
5b5d597c
Commit
5b5d597c
authored
Feb 14, 2015
by
FichteFoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve live printing for --test-repositories test
parent
7a926e05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
58 deletions
+52
-58
test.py
tests/test.py
+52
-58
No files found.
tests/test.py
View file @
5b5d597c
...
...
@@ -465,55 +465,63 @@ class TestContainer(object):
A file-like object used for diagnostic output that provides .write()
and .flush()
"""
# TODO multi-threading
stream
.
write
(
"
%
s ... "
%
path
)
stream
.
flush
()
cls
.
_write
(
stream
,
"
%
s ... "
%
path
)
if
re
.
match
(
'https?://'
,
path
,
re
.
I
)
is
not
None
:
# Download the repository
try
:
with
urlopen
(
path
)
as
f
:
source
=
f
.
read
()
.
decode
(
"utf-8"
,
'replace'
)
except
Exception
as
e
:
cls
.
_write
(
stream
,
'failed (
%
s)
\n
'
%
str_cls
(
e
))
yield
cls
.
_fail
(
"Downloading
%
s failed"
%
path
,
e
)
success
=
False
try
:
if
re
.
match
(
'https?://'
,
path
,
re
.
I
)
is
not
None
:
# Download the repository
try
:
with
urlopen
(
path
)
as
f
:
source
=
f
.
read
()
.
decode
(
"utf-8"
,
'replace'
)
except
Exception
as
e
:
yield
cls
.
_fail
(
"Downloading
%
s failed"
%
path
,
e
)
return
else
:
try
:
with
_open
(
path
)
as
f
:
source
=
f
.
read
()
.
decode
(
'utf-8'
,
'replace'
)
except
Exception
as
e
:
yield
cls
.
_fail
(
"Opening
%
s failed"
%
path
,
e
)
return
if
not
source
:
yield
cls
.
_fail
(
"
%
s is empty"
%
path
)
return
else
:
# Parse the repository
try
:
with
_open
(
path
)
as
f
:
source
=
f
.
read
()
.
decode
(
'utf-8'
,
'replace'
)
data
=
json
.
loads
(
source
)
except
Exception
as
e
:
cls
.
_write
(
stream
,
'failed (
%
s)
\n
'
%
str_cls
(
e
))
yield
cls
.
_fail
(
"Opening
%
s failed"
%
path
,
e
)
yield
cls
.
_fail
(
"Could not parse
%
s"
%
path
,
e
)
return
if
not
source
:
yield
cls
.
_fail
(
"
%
s is empty"
%
path
)
return
# Check for the schema version first (and generator failures it's
# badly formatted)
if
'schema_version'
not
in
data
:
yield
cls
.
_fail
(
"No schema_version found in
%
s"
%
path
)
return
schema
=
data
[
'schema_version'
]
if
schema
!=
'3.0.0'
and
float
(
schema
)
not
in
(
1.0
,
1.1
,
1.2
,
2.0
):
yield
cls
.
_fail
(
"Unrecognized schema version
%
s in
%
s"
%
(
schema
,
path
))
return
# Parse the repository
try
:
data
=
json
.
loads
(
source
)
except
Exception
as
e
:
yield
cls
.
_fail
(
"Could not parse
%
s"
%
path
,
e
)
return
success
=
True
# Check for the schema version first (and generator failures it's
# badly formatted)
if
'schema_version'
not
in
data
:
yield
cls
.
_fail
(
"No schema_version found in
%
s"
%
path
)
return
schema
=
data
[
'schema_version'
]
if
schema
!=
'3.0.0'
and
float
(
schema
)
not
in
(
1.0
,
1.1
,
1.2
,
2.0
):
yield
cls
.
_fail
(
"Unrecognized schema version
%
s in
%
s"
%
(
schema
,
path
))
return
# Do not generate 1000 failing tests for not yet updated repos
if
schema
!=
'3.0.0'
:
cls
.
_write
(
stream
,
"skipping (schema version
%
s)
\n
"
%
data
[
'schema_version'
])
return
cls
.
_write
(
stream
,
'done
\n
'
)
# Do not generate 1000 failing tests for not yet updated repos
if
schema
!=
'3.0.0'
:
stream
.
write
(
"skipping (schema version
%
s)"
%
data
[
'schema_version'
])
return
else
:
stream
.
write
(
"done"
)
finally
:
if
not
success
:
stream
.
write
(
"failed"
)
stream
.
write
(
"
\n
"
)
# `path` is for output during tests only
yield
cls
.
_test_repository_keys
,
(
path
,
data
)
...
...
@@ -544,21 +552,6 @@ class TestContainer(object):
return
cls
.
_test_error
,
args
@
classmethod
def
_write
(
cls
,
stream
,
string
):
"""
Writes dianostic output to a file-like object.
:param stream:
Must have the methods .write() and .flush()
:param string:
The string to write - a newline will NOT be appended
"""
stream
.
write
(
string
)
stream
.
flush
()
class
DefaultChannelTests
(
TestContainer
,
unittest
.
TestCase
):
maxDiff
=
None
...
...
@@ -589,7 +582,7 @@ class DefaultChannelTests(TestContainer, unittest.TestCase):
# when run with "--test-repositories" parameter.
return
cls
.
_write
(
stream
,
"Fetching remote repositories:
\n
"
)
stream
.
write
(
"Fetching remote repositories:
\n
"
)
for
repository
in
cls
.
j
[
'repositories'
]:
if
repository
.
startswith
(
'.'
):
...
...
@@ -600,7 +593,8 @@ class DefaultChannelTests(TestContainer, unittest.TestCase):
for
test
in
cls
.
_include_tests
(
repository
,
stream
):
yield
test
cls
.
_write
(
stream
,
'
\n
'
)
stream
.
write
(
'
\n
'
)
stream
.
flush
()
class
DefaultRepositoryTests
(
TestContainer
,
unittest
.
TestCase
):
...
...
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