Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
lvzhengyang
git2
Commits
63964c89
Commit
63964c89
authored
Feb 20, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable caching in Clar
parent
fd69c7bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
59 deletions
+8
-59
tests-clar/generate.py
+8
-59
No files found.
tests-clar/generate.py
View file @
63964c89
...
...
@@ -60,10 +60,7 @@ class Module(object):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
mtime
=
0
self
.
enabled
=
True
self
.
modified
=
False
def
clean_name
(
self
):
return
self
.
name
.
replace
(
"_"
,
"::"
)
...
...
@@ -105,41 +102,17 @@ class Module(object):
return
self
.
callbacks
!=
[]
def
refresh
(
self
,
path
):
self
.
modified
=
False
def
load
(
self
,
path
):
try
:
st
=
os
.
stat
(
path
)
# Not modified
if
st
.
st_mtime
==
self
.
mtime
:
return
True
self
.
modified
=
True
self
.
mtime
=
st
.
st_mtime
with
open
(
path
)
as
fp
:
raw_content
=
fp
.
read
()
return
self
.
parse
(
fp
.
read
())
except
IOError
:
return
False
return
self
.
parse
(
raw_content
)
class
TestSuite
(
object
):
def
__init__
(
self
,
path
):
self
.
path
=
path
def
should_generate
(
self
,
path
):
if
not
os
.
path
.
isfile
(
path
):
return
True
if
any
(
module
.
modified
for
module
in
self
.
modules
.
values
()):
return
True
return
False
def
find_modules
(
self
):
modules
=
[]
for
root
,
_
,
files
in
os
.
walk
(
self
.
path
):
...
...
@@ -156,33 +129,15 @@ class TestSuite(object):
return
modules
def
load_cache
(
self
):
path
=
os
.
path
.
join
(
self
.
path
,
'.clarcache'
)
cache
=
{}
try
:
fp
=
open
(
path
,
'rb'
)
cache
=
pickle
.
load
(
fp
)
fp
.
close
()
except
(
IOError
,
ValueError
):
pass
return
cache
def
save_cache
(
self
):
path
=
os
.
path
.
join
(
self
.
path
,
'.clarcache'
)
with
open
(
path
,
'wb'
)
as
cache
:
pickle
.
dump
(
self
.
modules
,
cache
)
def
load
(
self
,
force
=
False
):
module_data
=
self
.
find_modules
()
self
.
modules
=
{}
if
force
else
self
.
load_cache
()
self
.
modules
=
{}
for
path
,
name
in
module_data
:
if
name
not
in
self
.
modules
:
self
.
modules
[
name
]
=
Module
(
name
)
if
not
self
.
modules
[
name
]
.
refresh
(
path
):
if
not
self
.
modules
[
name
]
.
load
(
path
):
del
self
.
modules
[
name
]
def
disable
(
self
,
excluded
):
...
...
@@ -202,9 +157,6 @@ class TestSuite(object):
def
write
(
self
):
output
=
os
.
path
.
join
(
self
.
path
,
'clar.suite'
)
if
not
self
.
should_generate
(
output
):
return
False
with
open
(
output
,
'w'
)
as
data
:
for
module
in
self
.
modules
.
values
():
t
=
Module
.
DeclarationTemplate
(
module
)
...
...
@@ -223,22 +175,19 @@ class TestSuite(object):
data
.
write
(
"static const size_t _clar_suite_count =
%
d;
\n
"
%
self
.
suite_count
())
data
.
write
(
"static const size_t _clar_callback_count =
%
d;
\n
"
%
self
.
callback_count
())
suite
.
save_cache
()
return
True
if
__name__
==
'__main__'
:
from
optparse
import
OptionParser
parser
=
OptionParser
()
parser
.
add_option
(
'-f'
,
'--force'
,
dest
=
'force'
,
default
=
False
)
parser
.
add_option
(
'-x'
,
'--exclude'
,
dest
=
'excluded'
,
action
=
'append'
,
default
=
[])
options
,
args
=
parser
.
parse_args
()
for
path
in
args
or
[
'.'
]:
suite
=
TestSuite
(
path
)
suite
.
load
(
options
.
force
)
suite
.
load
()
suite
.
disable
(
options
.
excluded
)
if
suite
.
write
():
print
(
"Written `clar.suite` (
%
d suites)"
%
len
(
suite
.
modules
))
suite
.
write
()
print
(
"Written `clar.suite` (
%
d suites)"
%
len
(
suite
.
modules
))
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