From c63a47dd899c8fe84b8b2e75dea26f78d6e35cf7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 27 Dec 2017 17:52:35 +0100 Subject: [PATCH] Added tests for klayout app This commit also contains some important fixes: * Option -wd wasn't working * Relative layout file paths in session files are resolved as relative to the session file. On writing, absolute paths are used, so this change only affects session files build intentionally. Plus: * Program version is available in unit tests too * Fixed a typo in the RBA::Expression documentation --- src/gsi/gsi/gsiDeclTl.cc | 4 +- src/klayout_main/klayout_main.pro | 22 +- .../{ => klayout_main}/klayout.cc | 0 .../{ => klayout_main}/klayout.rc | 0 .../klayout_main/klayout_main.pro | 22 ++ src/klayout_main/{ => klayout_main}/logo.ico | Bin src/klayout_main/tests/klayout_main_tests.cc | 51 +++++ src/klayout_main/tests/tests.pro | 16 ++ src/lay/lay/layApplication.cc | 3 +- src/lay/lay/laySession.cc | 12 +- src/lay/lay/laySession.h | 1 + src/unit_tests/unit_test_main.cc | 13 ++ testdata/klayout_main/main.rb | 148 ++++++++++++ testdata/klayout_main/session.lys | 214 ++++++++++++++++++ testdata/klayout_main/test.py | 3 + testdata/klayout_main/test.rb | 3 + testdata/klayout_main/test1.gds | Bin 0 -> 170 bytes testdata/klayout_main/test2.gds | Bin 0 -> 170 bytes testdata/klayout_main/test2.rb | 3 + testdata/klayout_main/test3.rb | 3 + testdata/klayout_main/test_app.rb | 4 + testdata/klayout_main/test_em.rb | 3 + testdata/klayout_main/test_epilogue.rb | 36 +++ testdata/klayout_main/test_lay.rb | 3 + testdata/klayout_main/test_lay2.rb | 8 + testdata/klayout_main/test_prologue.rb | 37 +++ testdata/klayout_main/test_read_config.rb | 3 + testdata/klayout_main/test_script.rb | 4 + testdata/klayout_main/test_set_config1.rb | 3 + testdata/klayout_main/test_set_config2.rb | 3 + 30 files changed, 597 insertions(+), 25 deletions(-) rename src/klayout_main/{ => klayout_main}/klayout.cc (100%) rename src/klayout_main/{ => klayout_main}/klayout.rc (100%) create mode 100644 src/klayout_main/klayout_main/klayout_main.pro rename src/klayout_main/{ => klayout_main}/logo.ico (100%) create mode 100644 src/klayout_main/tests/klayout_main_tests.cc create mode 100644 src/klayout_main/tests/tests.pro create mode 100644 testdata/klayout_main/main.rb create mode 100644 testdata/klayout_main/session.lys create mode 100644 testdata/klayout_main/test.py create mode 100644 testdata/klayout_main/test.rb create mode 100644 testdata/klayout_main/test1.gds create mode 100644 testdata/klayout_main/test2.gds create mode 100644 testdata/klayout_main/test2.rb create mode 100644 testdata/klayout_main/test3.rb create mode 100644 testdata/klayout_main/test_app.rb create mode 100644 testdata/klayout_main/test_em.rb create mode 100644 testdata/klayout_main/test_epilogue.rb create mode 100644 testdata/klayout_main/test_lay.rb create mode 100644 testdata/klayout_main/test_lay2.rb create mode 100644 testdata/klayout_main/test_prologue.rb create mode 100644 testdata/klayout_main/test_read_config.rb create mode 100644 testdata/klayout_main/test_script.rb create mode 100644 testdata/klayout_main/test_set_config1.rb create mode 100644 testdata/klayout_main/test_set_config2.rb diff --git a/src/gsi/gsi/gsiDeclTl.cc b/src/gsi/gsi/gsiDeclTl.cc index 90130a8f2..81e9af288 100644 --- a/src/gsi/gsi/gsiDeclTl.cc +++ b/src/gsi/gsi/gsiDeclTl.cc @@ -545,9 +545,7 @@ Class decl_ExpressionWrapper ("Expression", "@brief Evaluation of Expressions\n" "\n" "This class allows evaluation of expressions. Expressions are used in many places throughout KLayout and " - "provide computation features for various applications.\n" - "\n" - "This class allows evaluation of expressions. Having a script language, there is no real use for expressions " + "provide computation features for various applications. Having a script language, there is no real use for expressions " "inside a script client. This class is provided mainly for testing purposes.\n" "\n" "An expression is 'compiled' into an Expression object and can be evaluated multiple times.\n" diff --git a/src/klayout_main/klayout_main.pro b/src/klayout_main/klayout_main.pro index fb70da893..704e6f75e 100644 --- a/src/klayout_main/klayout_main.pro +++ b/src/klayout_main/klayout_main.pro @@ -1,22 +1,6 @@ -DESTDIR = $$OUT_PWD/.. +TEMPLATE = subdirs +SUBDIRS = klayout_main tests -include($$PWD/../klayout.pri) +tests.depends += klayout_main -TARGET = klayout - -include($$PWD/../app.pri) -include($$PWD/../with_all_libs.pri) - -HEADERS = \ - -FORMS = \ - -SOURCES = \ - klayout.cc \ - -RESOURCES = \ - -win32 { - RC_FILE = $$PWD/klayout.rc -} diff --git a/src/klayout_main/klayout.cc b/src/klayout_main/klayout_main/klayout.cc similarity index 100% rename from src/klayout_main/klayout.cc rename to src/klayout_main/klayout_main/klayout.cc diff --git a/src/klayout_main/klayout.rc b/src/klayout_main/klayout_main/klayout.rc similarity index 100% rename from src/klayout_main/klayout.rc rename to src/klayout_main/klayout_main/klayout.rc diff --git a/src/klayout_main/klayout_main/klayout_main.pro b/src/klayout_main/klayout_main/klayout_main.pro new file mode 100644 index 000000000..043cf01bb --- /dev/null +++ b/src/klayout_main/klayout_main/klayout_main.pro @@ -0,0 +1,22 @@ + +DESTDIR = $$OUT_PWD/../.. + +include($$PWD/../../klayout.pri) + +TARGET = klayout + +include($$PWD/../../app.pri) +include($$PWD/../../with_all_libs.pri) + +HEADERS = \ + +FORMS = \ + +SOURCES = \ + klayout.cc \ + +RESOURCES = \ + +win32 { + RC_FILE = $$PWD/klayout.rc +} diff --git a/src/klayout_main/logo.ico b/src/klayout_main/klayout_main/logo.ico similarity index 100% rename from src/klayout_main/logo.ico rename to src/klayout_main/klayout_main/logo.ico diff --git a/src/klayout_main/tests/klayout_main_tests.cc b/src/klayout_main/tests/klayout_main_tests.cc new file mode 100644 index 000000000..ca207ea7c --- /dev/null +++ b/src/klayout_main/tests/klayout_main_tests.cc @@ -0,0 +1,51 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2017 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 + +*/ + +// NOTE: klayout_main_tests is actually a Ruby test which does all test automation +// The tests will also test Python capabilities, so Python is required too. + +#if defined(HAVE_RUBY) && defined(HAVE_PYTHON) + +#include "rba.h" +#include "gsiDecl.h" + +// On Windows, ruby.h is not compatible with windows.h which is included by utHead - at least not if +// windows.h is included before ruby.h ... +#include "tlUnitTest.h" + +void run_rubytest (tl::TestBase * /*_this*/, const std::string &fn) +{ + tl_assert (rba::RubyInterpreter::instance ()); + + std::string fp (tl::testsrc ()); + fp += "/testdata/klayout_main/"; + fp += fn; + rba::RubyInterpreter::instance ()->load_file (fp.c_str ()); +} + +#define RUBYTEST(n, file) \ + TEST(n) { run_rubytest(_this, file); } + +RUBYTEST (main, "main.rb") + +#endif + diff --git a/src/klayout_main/tests/tests.pro b/src/klayout_main/tests/tests.pro new file mode 100644 index 000000000..c8132a05c --- /dev/null +++ b/src/klayout_main/tests/tests.pro @@ -0,0 +1,16 @@ + +DESTDIR_UT = $$OUT_PWD/../.. +DESTDIR = $$OUT_PWD/.. + +TARGET = klayout_main_tests + +include($$PWD/../../lib_ut.pri) + +SOURCES = \ + klayout_main_tests.cc + +INCLUDEPATH += $$RBA_INC $$TL_INC $$DB_INC $$GSI_INC +DEPENDPATH += $$RBA_INC $$TL_INC $$DB_INC $$GSI_INC + +LIBS += -L$$DESTDIR_UT -lklayout_rba -lklayout_tl -lklayout_db -lklayout_gsi + diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 95ab3307a..b955c681c 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -442,7 +442,6 @@ ApplicationBase::init_app (int &argc, char **argv, bool non_ui_mode) } else if (a == "-wd" && (i + 1) < argc) { - std::string v; const char *p = args [++i].c_str (); const char *n0 = p; while (*p && *p != '=') { @@ -450,7 +449,7 @@ ApplicationBase::init_app (int &argc, char **argv, bool non_ui_mode) } std::string n (n0, p - n0); if (*p == '=') { - tl::Eval::set_global_var (n, tl::Variant (v)); + tl::Eval::set_global_var (n, tl::Variant (p + 1)); } else { tl::Eval::set_global_var (n, tl::Variant (true)); } diff --git a/src/lay/lay/laySession.cc b/src/lay/lay/laySession.cc index b908efdfe..91da14a77 100644 --- a/src/lay/lay/laySession.cc +++ b/src/lay/lay/laySession.cc @@ -34,6 +34,7 @@ #include #include +#include namespace lay { @@ -161,10 +162,16 @@ Session::restore (lay::MainWindow &mw) std::map ::const_iterator ld = ld_by_name.find (cvd->layout_name); + std::string fp = ld->second->file_path; + QFileInfo fi (tl::to_qstring (fp)); + if (! m_base_dir.empty () && fi.isRelative ()) { + fp = tl::to_string (QDir (tl::to_qstring (m_base_dir)).filePath (tl::to_qstring (ld->second->file_path))); + } + bool ok = false; if (ld != ld_by_name.end ()) { try { - cv = view->load_layout (ld->second->file_path, ld->second->load_options, cvd->tech_name, true /*add*/); + cv = view->load_layout (fp, ld->second->load_options, cvd->tech_name, true /*add*/); view->cellview (cv)->set_save_options (ld->second->save_options, ld->second->save_options_valid); ok = true; } catch (...) { } @@ -297,6 +304,9 @@ session_structure ("session", void Session::load (const std::string &fn) { + // Take the path to the file as the base directory + m_base_dir = tl::to_string (QFileInfo (tl::to_qstring (fn)).absolutePath ()); + tl::XMLFileSource in (fn); session_structure.parse (in, *this); diff --git a/src/lay/lay/laySession.h b/src/lay/lay/laySession.h index 7238e5472..81818a1de 100644 --- a/src/lay/lay/laySession.h +++ b/src/lay/lay/laySession.h @@ -173,6 +173,7 @@ private: int m_current_view; std::string m_window_state; std::string m_window_geometry; + std::string m_base_dir; }; } diff --git a/src/unit_tests/unit_test_main.cc b/src/unit_tests/unit_test_main.cc index 8fc313ece..a1c7b5e05 100644 --- a/src/unit_tests/unit_test_main.cc +++ b/src/unit_tests/unit_test_main.cc @@ -30,11 +30,14 @@ #include "tlCommandLineParser.h" #include "layApplication.h" #include "laySystemPaths.h" +#include "layVersion.h" #include "rba.h" #include "pya.h" #include "gsiDecl.h" #include "gsiExternalMain.h" +#include "version.h" + #include #include #include @@ -320,6 +323,16 @@ run_tests (const std::vector &selected_tests, bool editable, boo static int main_cont (int &argc, char **argv) { + // install the version strings + lay::Version::set_exe_name (prg_exe_name); + lay::Version::set_name (prg_name); + lay::Version::set_version (prg_version); + + std::string subversion (prg_date); + subversion += " r"; + subversion += prg_rev; + lay::Version::set_subversion (subversion.c_str ()); + int result = 0; ut::TestConsole console (stdout); diff --git a/testdata/klayout_main/main.rb b/testdata/klayout_main/main.rb new file mode 100644 index 000000000..51c1e1ce9 --- /dev/null +++ b/testdata/klayout_main/main.rb @@ -0,0 +1,148 @@ +# encoding: UTF-8 + +# KLayout Layout Viewer +# Copyright (C) 2006-2017 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 + +if !$:.member?(File::dirname($0)) + $:.push(File::dirname($0)) +end + +load("test_prologue.rb") + +# Tests for the klayout executable +# +# This tests actually runs inside a KLayout/unit_tests instance but +# only for providing the test automation. + +class KLayoutMain_TestClass < TestBase + + def test_1 + + # Basic + version = `./klayout -v` + assert_equal(version, "#{RBA::Application.instance.version}\n") + + end + + def test_2 + + # Basic Ruby + out = `./klayout -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.rb")}` + assert_equal(out, "Variable v1=42 v2=hello\n") + + out = `./klayout -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.rb")} -rm #{File.join(File.dirname(__FILE__), "test2.rb")} -rm #{File.join(File.dirname(__FILE__), "test3.rb")}` + assert_equal(out, "test2\ntest3\nVariable v1=42 v2=hello\n") + + end + + def test_3 + + # Basic Python + out = `./klayout -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.py")}` + assert_equal(out, "Variable v1=42 v2=hello\n") + + end + + def test_4 + + # Application class + + # QCoreApplication for (headless) mode + out = `./klayout -b -r #{File.join(File.dirname(__FILE__), "test_app.rb")}` + assert_equal(out, "RBA::Application superclass RBA::QCoreApplication_Native\nMainWindow is not there\n") + + # QApplication for GUI mode + out = `./klayout -z -nc -rx -r #{File.join(File.dirname(__FILE__), "test_app.rb")}` + assert_equal(out, "RBA::Application superclass RBA::QApplication_Native\nMainWindow is there\n") + + end + + def test_5 + + # Script variables + out = `./klayout -b -wd tv1=17 -wd tv2=25 -wd tv3 -r #{File.join(File.dirname(__FILE__), "test_script.rb")}` + assert_equal(out, "42\ntrue\n") + + end + + def test_6 + + # Editable / Non-editable mode + out = `./klayout -b -ne -r #{File.join(File.dirname(__FILE__), "test_em.rb")}` + assert_equal(out, "false\n") + + out = `./klayout -b -e -r #{File.join(File.dirname(__FILE__), "test_em.rb")}` + assert_equal(out, "true\n") + + end + + def test_7 + + cfg_file = File.join($ut_testtmp, "config.xml") + File.open(cfg_file, "w") { |file| file.puts("") } + + # Special configuration file + `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config1.rb")}` + + out = `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}` + assert_equal(out, "42\n") + + # Update + `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config2.rb")}` + + out = `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}` + assert_equal(out, "17\n") + + # Reset + `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config1.rb")}` + + out = `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}` + assert_equal(out, "42\n") + + # No update + `./klayout -b -t -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config2.rb")}` + + out = `./klayout -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}` + assert_equal(out, "42\n") + + end + + def test_8 + + # Loading layouts + out = `./klayout -z -nc -rx #{File.join(File.dirname(__FILE__), "test1.gds")} -r #{File.join(File.dirname(__FILE__), "test_lay.rb")}` + assert_equal(out, "TOP1\n") + + out = `./klayout -z -nc -rx #{File.join(File.dirname(__FILE__), "test1.gds")} #{File.join(File.dirname(__FILE__), "test2.gds")} -r #{File.join(File.dirname(__FILE__), "test_lay2.rb")}` + assert_equal(out, "TOP1\nTOP2\n") + + out = `./klayout -z -nc -rx #{File.join(File.dirname(__FILE__), "test1.gds")} #{File.join(File.dirname(__FILE__), "test2.gds")} -s -r #{File.join(File.dirname(__FILE__), "test_lay2.rb")}` + assert_equal(out, "TOP1;TOP2\n") + + end + + def test_9 + + # Sessions + out = `./klayout -z -nc -rx -u #{File.join(File.dirname(__FILE__), "session.lys")} -r #{File.join(File.dirname(__FILE__), "test_lay2.rb")}` + assert_equal(out, "TOP2;TOP1\n") + + end + +end + +load("test_epilogue.rb") diff --git a/testdata/klayout_main/session.lys b/testdata/klayout_main/session.lys new file mode 100644 index 000000000..73ac6c473 --- /dev/null +++ b/testdata/klayout_main/session.lys @@ -0,0 +1,214 @@ + + + 1392 + 912 + AAAA/wAAAAD9AAAAAgAAAAAAAAC5AAADLvwCAAAAAvsAAAAqAG4AYQB2AGkAZwBhAHQAbwByAF8AZABvAGMAawBfAHcAaQBkAGcAZQB0AAAAAAD/////AAAAkgD////7AAAAHABoAHAAXwBkAG8AYwBrAF8AdwBpAGQAZwBlAHQBAAAATAAAAy4AAAAZAP///wAAAAEAAAEdAAADLvwCAAAAAvsAAAAcAGwAcABfAGQAbwBjAGsAXwB3AGkAZABnAGUAdAEAAABMAAACnQAAABkA////+wAAABwAbAB0AF8AZABvAGMAawBfAHcAaQBkAGcAZQB0AQAAAu8AAACLAAAAiwAAAIsAAAOOAAADLgAAAAQAAAAEAAAACAAAAAj8AAAAAQAAAAIAAAABAAAADgB0AG8AbwBsAGIAYQByAQAAAAD/////AAAAAAAAAAA= + AdnQywABAAAAAAEpAAAAFQAABq4AAAPSAAABNAAAADgAAAajAAADxwAAAAAAAA== + 0 + + test1.gds + test1.gds + false + + + 2 + false + false + 1 + * + false + + + true + false + false + false + false + 8000 + 32000 + LIB + + + 0 + + + false + false + + + + + true + layer_map() + true + true + + + 1 + true + true + + + 0.001 + 1 + 100 + 100 + 0 + 0 + false + false + true + layer_map() + + + 0 + 0.001 + layer_map() + true + + + + + test2.gds + test2.gds + true + + + 2 + false + false + 1 + * + false + + + true + false + false + false + false + 8000 + 32000 + LIB + + + 0 + + + false + false + + + + + true + layer_map() + true + true + + + 1 + true + true + + + 0.001 + 1 + 100 + 100 + 0 + 0 + false + false + true + layer_map() + + + 0 + 0.001 + layer_map() + true + + + + + + <active-cellview-index>1</active-cellview-index> + <display> + <x-left>-0.892701664533</x-left> + <x-right>8.8947503201</x-right> + <y-bottom>-0.204353393086</y-bottom> + <y-top>8.19564660691</y-top> + <min-hier>0</min-hier> + <max-hier>1</max-hier> + <cellpaths> + <cellpath> + <cellname>TOP2</cellname> + </cellpath> + <cellpath> + <cellname>TOP1</cellname> + </cellpath> + </cellpaths> + </display> + <cellviews> + <cellview> + <layout-ref>test2.gds</layout-ref> + <tech-name/> + <hidden-cells> + </hidden-cells> + </cellview> + <cellview> + <layout-ref>test1.gds</layout-ref> + <tech-name/> + <hidden-cells> + </hidden-cells> + </cellview> + </cellviews> + <bookmarks> + </bookmarks> + <rdb-files> + </rdb-files> + <current-layer-property-tab>0</current-layer-property-tab> + <layer-properties-tabs> + <layer-properties> + <properties> + <frame-color>#ff80a8</frame-color> + <fill-color>#ff80a8</fill-color> + <frame-brightness>0</frame-brightness> + <fill-brightness>0</fill-brightness> + <dither-pattern>I9</dither-pattern> + <line-style/> + <valid>true</valid> + <visible>true</visible> + <transparent>false</transparent> + <width>1</width> + <marked>false</marked> + <xfill>false</xfill> + <animation>0</animation> + <name/> + <source>2/0@1</source> + </properties> + <properties> + <frame-color>#ff80a8</frame-color> + <fill-color>#ff80a8</fill-color> + <frame-brightness>0</frame-brightness> + <fill-brightness>0</fill-brightness> + <dither-pattern>I9</dither-pattern> + <line-style/> + <valid>true</valid> + <visible>true</visible> + <transparent>false</transparent> + <width/> + <marked>false</marked> + <xfill>false</xfill> + <animation>0</animation> + <name/> + <source>1/0@2</source> + </properties> + <name/> + </layer-properties> + </layer-properties-tabs> + <annotations> + </annotations> + </view> +</session> diff --git a/testdata/klayout_main/test.py b/testdata/klayout_main/test.py new file mode 100644 index 000000000..3870f2bcd --- /dev/null +++ b/testdata/klayout_main/test.py @@ -0,0 +1,3 @@ + +print("Variable v1="+str(v1)+" v2="+str(v2)) + diff --git a/testdata/klayout_main/test.rb b/testdata/klayout_main/test.rb new file mode 100644 index 000000000..8cf0250ed --- /dev/null +++ b/testdata/klayout_main/test.rb @@ -0,0 +1,3 @@ + +puts "Variable v1=#{$v1} v2=#{$v2}" + diff --git a/testdata/klayout_main/test1.gds b/testdata/klayout_main/test1.gds new file mode 100644 index 0000000000000000000000000000000000000000..7cfbe49107ec4eeb1ce3efaaa5664e155cd109d1 GIT binary patch literal 170 zcmZQzV_;&6V31*CVt>fM!ywHd$RNaEg3M;%U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`B^P4=`k4;b353<7HxCWMJcCVqjp<5nu+ANI>3!fdLsKNwEkrFtD%# HF$)6#f9ny) literal 0 HcmV?d00001 diff --git a/testdata/klayout_main/test2.gds b/testdata/klayout_main/test2.gds new file mode 100644 index 0000000000000000000000000000000000000000..93410146069c624053808507794a9f405f81030e GIT binary patch literal 170 zcmZQzV_;&6V31*CVt>fM!ywHd$RNxhjLc@>U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`B^P4=`e2;b353<7HxCVqoKAVqjp<5nu+ANI>3!fdLsKNwEkrFtD%# HF$)6#M*9&- literal 0 HcmV?d00001 diff --git a/testdata/klayout_main/test2.rb b/testdata/klayout_main/test2.rb new file mode 100644 index 000000000..b59aa43c1 --- /dev/null +++ b/testdata/klayout_main/test2.rb @@ -0,0 +1,3 @@ + +puts "test2" + diff --git a/testdata/klayout_main/test3.rb b/testdata/klayout_main/test3.rb new file mode 100644 index 000000000..217bb2326 --- /dev/null +++ b/testdata/klayout_main/test3.rb @@ -0,0 +1,3 @@ + +puts "test3" + diff --git a/testdata/klayout_main/test_app.rb b/testdata/klayout_main/test_app.rb new file mode 100644 index 000000000..768fcf107 --- /dev/null +++ b/testdata/klayout_main/test_app.rb @@ -0,0 +1,4 @@ + +puts "RBA::Application superclass " + RBA::Application.instance.class.superclass.to_s +puts "MainWindow is " + (RBA::Application.instance.main_window ? "there" : "not there") + diff --git a/testdata/klayout_main/test_em.rb b/testdata/klayout_main/test_em.rb new file mode 100644 index 000000000..10768b131 --- /dev/null +++ b/testdata/klayout_main/test_em.rb @@ -0,0 +1,3 @@ + +puts RBA::Application.instance.is_editable?.inspect + diff --git a/testdata/klayout_main/test_epilogue.rb b/testdata/klayout_main/test_epilogue.rb new file mode 100644 index 000000000..f0f5bacc3 --- /dev/null +++ b/testdata/klayout_main/test_epilogue.rb @@ -0,0 +1,36 @@ + +# In the test environment, we cannot make sure that we destroy the ruby interpreter before the RBA +# environment is shut down. Therefore we must release all RBA objects by explicitly calling the GC +# and start the test suite manually. + +err = 0 +any = nil +repeat = (ENV["TESTREPEAT"] || "1").to_i + +class MyTestRunner < Test::Unit::UI::Console::TestRunner + def initialize(suite, *args) + super(suite, *args) + end + def test_started(name) + super + end +end + +Object.constants.each do |c| + if c.to_s =~ /_TestClass$/ + repeat.times do + r = MyTestRunner::new(Object.const_get(c)).start + err += r.error_count + r.failure_count + end + any = true + end +end + +if !any + raise("No test class defined (any ending with _TestClass)") +end + +if err > 0 + raise("Tests failed (#{err} Errors + Failures)") +end + diff --git a/testdata/klayout_main/test_lay.rb b/testdata/klayout_main/test_lay.rb new file mode 100644 index 000000000..f30037a65 --- /dev/null +++ b/testdata/klayout_main/test_lay.rb @@ -0,0 +1,3 @@ + +puts RBA::LayoutView::current.active_cellview.layout.top_cell.name + diff --git a/testdata/klayout_main/test_lay2.rb b/testdata/klayout_main/test_lay2.rb new file mode 100644 index 000000000..9208a8090 --- /dev/null +++ b/testdata/klayout_main/test_lay2.rb @@ -0,0 +1,8 @@ + +RBA::Application::instance.main_window.views.times do |v| + view = RBA::Application::instance.main_window.view(v) + tc = [] + view.cellviews.times { |cv| tc << view.cellview(cv).layout.top_cell.name } + puts tc.join(";") +end + diff --git a/testdata/klayout_main/test_prologue.rb b/testdata/klayout_main/test_prologue.rb new file mode 100644 index 000000000..4dcd70124 --- /dev/null +++ b/testdata/klayout_main/test_prologue.rb @@ -0,0 +1,37 @@ + +# in MSVC environment: +if ENV["RUBY"] + ruby_libs = "#{ENV["RUBY"]}/lib/ruby/#{RUBY_VERSION}" + if !$:.member?(ruby_libs) + $:.push(ruby_libs) + end +end + +# Set this to true to disable some tests involving exceptions +$leak_check = ENV["TEST_LEAK_CHECK"] + +# Fetch location of source files and the temp files +$ut_testsrc = ENV["TESTSRC"] || raise("Environment variable $TESTSRC not set") +$ut_testtmp = ENV["TESTTMP_WITH_NAME"] || ENV["TESTTMP"] || raise("Environment variable $TESTTMP not set") + +# Pull packages from vendor drop-in +vendor = File.join($ut_testsrc, "testdata", "vendor", "ruby") +if !$:.member?(vendor) + $:.unshift(vendor) +end + +# Require Test::Unit +require 'test/unit/ui/console/testrunner' + +# TestBase is an alias for "TestCase" +Object.const_defined?(:TestBase) && Object.send(:remove_const, :TestBase) +TestBase = Test::Unit::TestCase + +# undefine existing classes + +Object.constants.each do |c| + if c.to_s =~ /_TestClass$/ + Object.send(:remove_const, c) + end +end + diff --git a/testdata/klayout_main/test_read_config.rb b/testdata/klayout_main/test_read_config.rb new file mode 100644 index 000000000..58f8a9fc0 --- /dev/null +++ b/testdata/klayout_main/test_read_config.rb @@ -0,0 +1,3 @@ + +puts RBA::Application.instance.get_config("key4test") + diff --git a/testdata/klayout_main/test_script.rb b/testdata/klayout_main/test_script.rb new file mode 100644 index 000000000..d5f30132a --- /dev/null +++ b/testdata/klayout_main/test_script.rb @@ -0,0 +1,4 @@ + +puts RBA::Expression::new("to_i(tv1)+to_i(tv2)").eval +puts RBA::Expression::new("tv3").eval + diff --git a/testdata/klayout_main/test_set_config1.rb b/testdata/klayout_main/test_set_config1.rb new file mode 100644 index 000000000..df1e4dacf --- /dev/null +++ b/testdata/klayout_main/test_set_config1.rb @@ -0,0 +1,3 @@ + +RBA::Application.instance.set_config("key4test", "42") + diff --git a/testdata/klayout_main/test_set_config2.rb b/testdata/klayout_main/test_set_config2.rb new file mode 100644 index 000000000..d0099b5cf --- /dev/null +++ b/testdata/klayout_main/test_set_config2.rb @@ -0,0 +1,3 @@ + +RBA::Application.instance.set_config("key4test", "17") +