Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
879a6225
Commit
879a6225
authored
Dec 03, 2013
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test script for plugin testing, and some asserts, no bugs fixed.
parent
ab36d235
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
2 deletions
+108
-2
fp_lib_table.cpp
common/fp_lib_table.cpp
+6
-0
github_plugin.cpp
pcbnew/github/github_plugin.cpp
+15
-2
test_kicad_plugin.py
scripts/test_kicad_plugin.py
+87
-0
No files found.
common/fp_lib_table.cpp
View file @
879a6225
...
...
@@ -172,6 +172,12 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString&
// having to copy the FPID and its two strings, twice each.
FPID
&
fpid
=
(
FPID
&
)
ret
->
GetFPID
();
// Catch any misbehaving plugin, which should be setting internal footprint name properly:
wxASSERT
(
aFootprintName
==
FROM_UTF8
(
fpid
.
GetFootprintName
().
c_str
()
)
);
// and clearing nickname
wxASSERT
(
!
fpid
.
GetLibNickname
().
size
()
);
fpid
.
SetLibNickname
(
row
->
GetNickName
()
);
}
...
...
pcbnew/github/github_plugin.cpp
View file @
879a6225
...
...
@@ -157,10 +157,15 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
MODULE
*
local
=
PCB_IO
::
FootprintLoad
(
m_pretty_dir
,
aFootprintName
,
aProperties
);
if
(
local
)
{
// It has worked, see <src>/scripts/test_kicad_plugin.py. So this was not firing:
// wxASSERT( aFootprintName == FROM_UTF8( local->GetFPID().GetFootprintName().c_str() ) );
// Moving it to higher API layer FP_LIB_TABLE::FootprintLoad().
return
local
;
}
}
string
fp_name
=
TO_UTF8
(
aFootprintName
);
MODULE_CITER
it
=
m_gh_cache
->
find
(
fp_name
);
...
...
@@ -178,13 +183,21 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
if
(
zis
.
OpenEntry
(
*
entry
)
)
{
INPUTSTREAM_LINE_READER
reader
(
&
zis
);
#if 1
// I am a PCB_IO derivative with my own PCB_PARSER
m_parser
->
SetLineReader
(
&
reader
);
// ownership not passed
MODULE
*
ret
=
(
MODULE
*
)
m_parser
->
Parse
();
#else
PCB_PARSER
parser
(
&
reader
);
MODULE
*
ret
=
(
MODULE
*
)
parser
.
Parse
();
#endif
// Dude, the footprint name comes from the file name in
// a github library. Zero out the library name, we don't know it here.
// Caller always has to set the library nickname if it knows it.
// Some caller may set the library nickname, one such instance is
// FP_LIB_TABLE::FootprintLoad().
ret
->
SetFPID
(
fp_name
);
return
ret
;
...
...
scripts/test_kicad_plugin.py
0 → 100755
View file @
879a6225
#!/usr/bin/python
# Test the KiCad plugin regarding some expected features.
# 1) Build target _pcbnew after enabling scripting in cmake.
# $ make _pcbnew
# 2) Changed dir to pcbnew
# $ cd pcbnew
# $ pwd
# build/pcbnew
# 3) Entered following command line, script takes no arguments
# $ PYTHONPATH=. <path_to>/test_kicad_plugin.py
from
__future__
import
print_function
from
pcbnew
import
*
import
sys
import
os
lib_path1
=
'/tmp/lib1.pretty'
lib_path2
=
'/tmp/lib2.pretty'
plugin
=
IO_MGR
.
PluginFind
(
IO_MGR
.
KICAD
)
# Expecting "KiCad":
print
(
"Plugin Type"
,
plugin
.
PluginName
()
)
try
:
plugin
.
FootprintLibDelete
(
lib_path1
)
except
:
None
# ignore, new may not exist if first run
try
:
plugin
.
FootprintLibDelete
(
lib_path2
)
except
:
None
# ignore, new may not exist if first run
plugin
.
FootprintLibCreate
(
lib_path1
)
# Verify that the same plugin instance can edge trigger on a lib_path change
# for a FootprintLibCreate()
plugin
.
FootprintLibCreate
(
lib_path2
)
board
=
BOARD
()
# The only way to construct a MODULE is to pass it a BOARD? Yep.
module
=
MODULE
(
board
)
fpid
=
FPID
(
'mine'
)
module
.
SetFPID
(
fpid
)
plugin
.
FootprintSave
(
lib_path2
,
module
)
# Verify that the same plugin instance can edge trigger on a lib_path change
# for a FootprintSave()
plugin
.
FootprintSave
(
lib_path1
,
module
)
# create a disparity between the library's name ("footprint"),
# and the module's internal useless name ("mine"). Module is officially named "footprint" now
# but has (module mine ...) internally:
os
.
rename
(
'/tmp/lib2.pretty/mine.kicad_mod'
,
'/tmp/lib2.pretty/footprint.kicad_mod'
)
footprint
=
plugin
.
FootprintLoad
(
lib_path2
,
'footprint'
)
fpid
=
footprint
.
GetFPID
()
# Always after a FootprintLoad() the internal name should match the one used to load it.
print
(
"internal name should be 'footprint':"
,
fpid
.
GetFootprintName
()
)
# Verify that the same plugin instance can edge trigger on a lib_path change
# for FootprintLoad()
footprint
=
plugin
.
FootprintLoad
(
lib_path1
,
'mine'
)
fpid
=
footprint
.
GetFPID
()
# Always after a FootprintLoad() the internal name should match the one used to load it.
print
(
"internal name should be 'mine':"
,
fpid
.
GetFootprintName
()
)
# As of 3-Dec-2013 this test is passed by KICAD_PLUGIN and Wayne is owed an atta boy!
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