WIP: some fixes at unit test level

This commit is contained in:
Matthias Koefferlein 2022-05-15 21:47:15 +02:00
parent 249642d5f3
commit bdc8fc2801
10 changed files with 69 additions and 63 deletions

View File

@ -5,7 +5,7 @@ set -xe
if [[ -f "/etc/centos-release" ]]; then
# sometimes the epel server is down. retry 5 times
for i in $(seq 1 5); do
yum install -y zlib-devel curl-devel expat-devel ccache && s=0 && break || s=$? && sleep 15;
yum install -y zlib-devel curl-devel expat-devel libpng-devel ccache && s=0 && break || s=$? && sleep 15;
done
[ $s -eq 0 ] || exit $s
@ -27,7 +27,7 @@ if [[ -f "/etc/centos-release" ]]; then
elif [[ -f "/etc/alpine-release" ]]; then
# musllinux prep
# ccache already present
apk add curl-dev expat-dev zlib-dev ccache
apk add curl-dev expat-dev zlib-dev libpng-dev ccache
export PATH="/usr/lib/ccache/bin:$PATH"
fi

View File

@ -5,7 +5,7 @@ test-command = [
"python {package}/testdata/pymod/import_rdb.py",
"python {package}/testdata/pymod/import_tl.py",
"python {package}/testdata/pymod/import_lib.py",
"python {package}/testdata/pymod/import_lay.py",
"python {package}/testdata/pymod/import_lay_noqt.py",
"python {package}/testdata/pymod/pya_tests.py"
]
# Disable building PyPy wheels on all platforms

View File

@ -9,12 +9,13 @@ SOURCES = \
HEADERS += \
equals(HAVE_QT, "0") {
LIBS += -lklayout_laybasic
} else {
LIBS += -lklayout_layview
!equals(HAVE_QT, "0") {
LIBS += -lklayout_layui
LIBS += -lklayout_lay
}
# hard linked as they contribute GSI classes to "lay" module:
LIBS += -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym
LIBS += -lklayout_laybasic -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym

View File

@ -23,7 +23,11 @@
#include "../pymodHelper.h"
// to force linking of the layview module
#if defined(HAVE_QT)
# include "../../lay/lay/layForceLink.h"
#else
# include "../../layview/layview/layviewForceLink.h"
#endif
// Force-include other dependencies
// NOTE: these libraries contribute to the "lay" module space. Hence we have to include them.
@ -33,4 +37,3 @@
#include "../../lym/lym/lymForceLink.h"
DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'")

View File

@ -87,12 +87,7 @@ PYMODTEST (bridge, "bridge.py")
PYMODTEST (import_tl, "import_tl.py")
PYMODTEST (import_db, "import_db.py")
PYMODTEST (import_rdb, "import_rdb.py")
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
PYMODTEST (import_lay, "import_lay.py")
#else
PYMODTEST (import_lay, "import_lay_noqt.py")
#endif
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)

View File

@ -21,18 +21,38 @@ import klayout.lay as lay
import unittest
import sys
def can_create_layoutview():
if not "MainWindow" in lay.__dict__:
return True # Qt-less
elif not "Application" in lay.__dict__:
return False # cannot instantiate Application
elif lay.__dict__["Application"].instance() is None:
return False # Application is not present
else:
return True
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be instantiated")
return
lv = lay.LayoutView()
lv.resize(800, 600)
lv.zoom_box(db.DBox(-42, -17, 142, 117))
bx = lv.box()
self.assertEqual(str(bx), "(-42.09,-19.09;141.91,118.91)")
def test_2(self):
p = lay.LayerPropertiesNode()
p.name = "u"
self.assertEqual(p.name, "u")
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()

View File

@ -1,47 +0,0 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2022 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.db as db
import klayout.lay as lay
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("Annotation" in lay.__all__, True)
def test_2(self):
# Some smoke test
ant = lay.Annotation()
ant.style = lay.Annotation.StyleRuler
self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler))
ant.fmt_x = "abc"
self.assertEqual(ant.fmt_x, "abc")
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

View File

@ -177,7 +177,7 @@ class DBLayoutVsSchematicTests(unittest.TestCase):
# run unit tests
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests)
suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutVsSchematicTests)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

View File

@ -179,7 +179,7 @@ class DBNetlistCrossReferenceTests(unittest.TestCase):
# run unit tests
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests)
suite = unittest.TestLoader().loadTestsFromTestCase(DBNetlistCrossReferenceTests)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

View File

@ -21,6 +21,16 @@ import unittest
import os
import sys
def can_create_layoutview():
if not "MainWindow" in pya.__dict__:
return True # Qt-less
elif not "Application" in pya.__dict__:
return False # cannot instantiate Application
elif pya.__dict__["Application"].instance() is None:
return False # Application is not present
else:
return True
def astr(a):
astr = []
for i in a:
@ -57,6 +67,10 @@ class LAYLayersTests(unittest.TestCase):
def test_1(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be created.")
return
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True)
@ -202,6 +216,10 @@ class LAYLayersTests(unittest.TestCase):
def test_1a(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be created.")
return
mgr = pya.Manager()
cv = pya.LayoutView(False, mgr)
@ -647,6 +665,10 @@ class LAYLayersTests(unittest.TestCase):
# direct replacement of objects and attributes
def test_3(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be created.")
return
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", True)
@ -765,6 +787,10 @@ class LAYLayersTests(unittest.TestCase):
# propagation of "real" attributes through the hierarchy
def test_4(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be created.")
return
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True)
@ -795,6 +821,10 @@ class LAYLayersTests(unittest.TestCase):
# delete method of iterator
def test_5(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be created.")
return
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
@ -883,6 +913,10 @@ class LAYLayersTests(unittest.TestCase):
# custom stipples and line styles
def test_6(self):
if not can_create_layoutview():
print("Skipped test as LayoutView cannot be created.")
return
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
@ -926,7 +960,7 @@ if __name__ == '__main__':
suite = unittest.TestSuite()
# NOTE: Use this instead of loadTestsfromTestCase to select a specific test:
# suite.addTest(BasicTest("test_26"))
suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTest)
suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTests)
# Only runs with Application available
if "Application" in pya.__all__ and not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():