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
This commit is contained in:
Matthias Koefferlein 2017-12-27 17:52:35 +01:00
parent 9906565013
commit c63a47dd89
30 changed files with 597 additions and 25 deletions

View File

@ -545,9 +545,7 @@ Class<ExpressionWrapper> decl_ExpressionWrapper ("Expression",
"@brief Evaluation of Expressions\n" "@brief Evaluation of Expressions\n"
"\n" "\n"
"This class allows evaluation of expressions. Expressions are used in many places throughout KLayout and " "This class allows evaluation of expressions. Expressions are used in many places throughout KLayout and "
"provide computation features for various applications.\n" "provide computation features for various applications. Having a script language, there is no real use for expressions "
"\n"
"This class allows evaluation of expressions. Having a script language, there is no real use for expressions "
"inside a script client. This class is provided mainly for testing purposes.\n" "inside a script client. This class is provided mainly for testing purposes.\n"
"\n" "\n"
"An expression is 'compiled' into an Expression object and can be evaluated multiple times.\n" "An expression is 'compiled' into an Expression object and can be evaluated multiple times.\n"

View File

@ -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
}

View File

@ -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
}

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -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

View File

@ -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

View File

@ -442,7 +442,6 @@ ApplicationBase::init_app (int &argc, char **argv, bool non_ui_mode)
} else if (a == "-wd" && (i + 1) < argc) { } else if (a == "-wd" && (i + 1) < argc) {
std::string v;
const char *p = args [++i].c_str (); const char *p = args [++i].c_str ();
const char *n0 = p; const char *n0 = p;
while (*p && *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); std::string n (n0, p - n0);
if (*p == '=') { if (*p == '=') {
tl::Eval::set_global_var (n, tl::Variant (v)); tl::Eval::set_global_var (n, tl::Variant (p + 1));
} else { } else {
tl::Eval::set_global_var (n, tl::Variant (true)); tl::Eval::set_global_var (n, tl::Variant (true));
} }

View File

@ -34,6 +34,7 @@
#include <fstream> #include <fstream>
#include <QFileInfo> #include <QFileInfo>
#include <QDir>
namespace lay namespace lay
{ {
@ -161,10 +162,16 @@ Session::restore (lay::MainWindow &mw)
std::map <std::string, const SessionLayoutDescriptor *>::const_iterator ld = ld_by_name.find (cvd->layout_name); std::map <std::string, const SessionLayoutDescriptor *>::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; bool ok = false;
if (ld != ld_by_name.end ()) { if (ld != ld_by_name.end ()) {
try { 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); view->cellview (cv)->set_save_options (ld->second->save_options, ld->second->save_options_valid);
ok = true; ok = true;
} catch (...) { } } catch (...) { }
@ -297,6 +304,9 @@ session_structure ("session",
void void
Session::load (const std::string &fn) 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); tl::XMLFileSource in (fn);
session_structure.parse (in, *this); session_structure.parse (in, *this);

View File

@ -173,6 +173,7 @@ private:
int m_current_view; int m_current_view;
std::string m_window_state; std::string m_window_state;
std::string m_window_geometry; std::string m_window_geometry;
std::string m_base_dir;
}; };
} }

View File

@ -30,11 +30,14 @@
#include "tlCommandLineParser.h" #include "tlCommandLineParser.h"
#include "layApplication.h" #include "layApplication.h"
#include "laySystemPaths.h" #include "laySystemPaths.h"
#include "layVersion.h"
#include "rba.h" #include "rba.h"
#include "pya.h" #include "pya.h"
#include "gsiDecl.h" #include "gsiDecl.h"
#include "gsiExternalMain.h" #include "gsiExternalMain.h"
#include "version.h"
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QTextCodec> #include <QTextCodec>
@ -320,6 +323,16 @@ run_tests (const std::vector<tl::TestBase *> &selected_tests, bool editable, boo
static int static int
main_cont (int &argc, char **argv) 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; int result = 0;
ut::TestConsole console (stdout); ut::TestConsole console (stdout);

148
testdata/klayout_main/main.rb vendored Normal file
View File

@ -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("<config/>") }
# 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")

214
testdata/klayout_main/session.lys vendored Normal file
View File

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="utf-8"?>
<session>
<window-width>1392</window-width>
<window-height>912</window-height>
<window-state>AAAA/wAAAAD9AAAAAgAAAAAAAAC5AAADLvwCAAAAAvsAAAAqAG4AYQB2AGkAZwBhAHQAbwByAF8AZABvAGMAawBfAHcAaQBkAGcAZQB0AAAAAAD/////AAAAkgD////7AAAAHABoAHAAXwBkAG8AYwBrAF8AdwBpAGQAZwBlAHQBAAAATAAAAy4AAAAZAP///wAAAAEAAAEdAAADLvwCAAAAAvsAAAAcAGwAcABfAGQAbwBjAGsAXwB3AGkAZABnAGUAdAEAAABMAAACnQAAABkA////+wAAABwAbAB0AF8AZABvAGMAawBfAHcAaQBkAGcAZQB0AQAAAu8AAACLAAAAiwAAAIsAAAOOAAADLgAAAAQAAAAEAAAACAAAAAj8AAAAAQAAAAIAAAABAAAADgB0AG8AbwBsAGIAYQByAQAAAAD/////AAAAAAAAAAA=</window-state>
<window-geometry>AdnQywABAAAAAAEpAAAAFQAABq4AAAPSAAABNAAAADgAAAajAAADxwAAAAAAAA==</window-geometry>
<current-view>0</current-view>
<layout>
<name>test1.gds</name>
<file-path>test1.gds</file-path>
<save-options-valid>false</save-options-valid>
<save-options>
<oasis>
<compression-level>2</compression-level>
<write-cblocks>false</write-cblocks>
<strict-mode>false</strict-mode>
<write-std-properties>1</write-std-properties>
<subst-char>*</subst-char>
<permissive>false</permissive>
</oasis>
<gds2>
<write-timestamps>true</write-timestamps>
<write-cell-properties>false</write-cell-properties>
<write-file-properties>false</write-file-properties>
<no-zero-length-paths>false</no-zero-length-paths>
<multi-xy-records>false</multi-xy-records>
<max-vertex-count>8000</max-vertex-count>
<max-cellname-length>32000</max-cellname-length>
<libname>LIB</libname>
</gds2>
<cif>
<polygon-mode>0</polygon-mode>
</cif>
<cif>
<dummy-calls>false</dummy-calls>
<blank-separator>false</blank-separator>
</cif>
</save-options>
<load-options>
<common>
<create-other-layers>true</create-other-layers>
<layer-map>layer_map()</layer-map>
<enable-properties>true</enable-properties>
<enable-text-objects>true</enable-text-objects>
</common>
<gds2>
<box-mode>1</box-mode>
<allow-big-records>true</allow-big-records>
<allow-multi-xy-records>true</allow-multi-xy-records>
</gds2>
<dxf>
<dbu>0.001</dbu>
<unit>1</unit>
<text-scaling>100</text-scaling>
<circle-points>100</circle-points>
<circle-accuracy>0</circle-accuracy>
<polyline-mode>0</polyline-mode>
<render-texts-as-polygons>false</render-texts-as-polygons>
<keep-other-cells>false</keep-other-cells>
<create-other-layers>true</create-other-layers>
<layer-map>layer_map()</layer-map>
</dxf>
<cif>
<wire-mode>0</wire-mode>
<dbu>0.001</dbu>
<layer-map>layer_map()</layer-map>
<create-other-layers>true</create-other-layers>
</cif>
</load-options>
</layout>
<layout>
<name>test2.gds</name>
<file-path>test2.gds</file-path>
<save-options-valid>true</save-options-valid>
<save-options>
<oasis>
<compression-level>2</compression-level>
<write-cblocks>false</write-cblocks>
<strict-mode>false</strict-mode>
<write-std-properties>1</write-std-properties>
<subst-char>*</subst-char>
<permissive>false</permissive>
</oasis>
<gds2>
<write-timestamps>true</write-timestamps>
<write-cell-properties>false</write-cell-properties>
<write-file-properties>false</write-file-properties>
<no-zero-length-paths>false</no-zero-length-paths>
<multi-xy-records>false</multi-xy-records>
<max-vertex-count>8000</max-vertex-count>
<max-cellname-length>32000</max-cellname-length>
<libname>LIB</libname>
</gds2>
<cif>
<polygon-mode>0</polygon-mode>
</cif>
<cif>
<dummy-calls>false</dummy-calls>
<blank-separator>false</blank-separator>
</cif>
</save-options>
<load-options>
<common>
<create-other-layers>true</create-other-layers>
<layer-map>layer_map()</layer-map>
<enable-properties>true</enable-properties>
<enable-text-objects>true</enable-text-objects>
</common>
<gds2>
<box-mode>1</box-mode>
<allow-big-records>true</allow-big-records>
<allow-multi-xy-records>true</allow-multi-xy-records>
</gds2>
<dxf>
<dbu>0.001</dbu>
<unit>1</unit>
<text-scaling>100</text-scaling>
<circle-points>100</circle-points>
<circle-accuracy>0</circle-accuracy>
<polyline-mode>0</polyline-mode>
<render-texts-as-polygons>false</render-texts-as-polygons>
<keep-other-cells>false</keep-other-cells>
<create-other-layers>true</create-other-layers>
<layer-map>layer_map()</layer-map>
</dxf>
<cif>
<wire-mode>0</wire-mode>
<dbu>0.001</dbu>
<layer-map>layer_map()</layer-map>
<create-other-layers>true</create-other-layers>
</cif>
</load-options>
</layout>
<view>
<title/>
<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>

3
testdata/klayout_main/test.py vendored Normal file
View File

@ -0,0 +1,3 @@
print("Variable v1="+str(v1)+" v2="+str(v2))

3
testdata/klayout_main/test.rb vendored Normal file
View File

@ -0,0 +1,3 @@
puts "Variable v1=#{$v1} v2=#{$v2}"

BIN
testdata/klayout_main/test1.gds vendored Normal file

Binary file not shown.

BIN
testdata/klayout_main/test2.gds vendored Normal file

Binary file not shown.

3
testdata/klayout_main/test2.rb vendored Normal file
View File

@ -0,0 +1,3 @@
puts "test2"

3
testdata/klayout_main/test3.rb vendored Normal file
View File

@ -0,0 +1,3 @@
puts "test3"

4
testdata/klayout_main/test_app.rb vendored Normal file
View File

@ -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")

3
testdata/klayout_main/test_em.rb vendored Normal file
View File

@ -0,0 +1,3 @@
puts RBA::Application.instance.is_editable?.inspect

36
testdata/klayout_main/test_epilogue.rb vendored Normal file
View File

@ -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

3
testdata/klayout_main/test_lay.rb vendored Normal file
View File

@ -0,0 +1,3 @@
puts RBA::LayoutView::current.active_cellview.layout.top_cell.name

8
testdata/klayout_main/test_lay2.rb vendored Normal file
View File

@ -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

37
testdata/klayout_main/test_prologue.rb vendored Normal file
View File

@ -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

View File

@ -0,0 +1,3 @@
puts RBA::Application.instance.get_config("key4test")

4
testdata/klayout_main/test_script.rb vendored Normal file
View File

@ -0,0 +1,4 @@
puts RBA::Expression::new("to_i(tv1)+to_i(tv2)").eval
puts RBA::Expression::new("tv3").eval

View File

@ -0,0 +1,3 @@
RBA::Application.instance.set_config("key4test", "42")

View File

@ -0,0 +1,3 @@
RBA::Application.instance.set_config("key4test", "17")