mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-02 02:47:48 +02:00
Fixed some build errors, added tests
This commit is contained in:
Vendored
+31
-23
@@ -54,7 +54,7 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_1
|
||||
|
||||
# Basic
|
||||
version = `#{self.klayout_bin} -v`
|
||||
version = `#{self.klayout_bin} -v 2>&1`
|
||||
assert_equal(version, "#{RBA::Application.instance.version}\n")
|
||||
|
||||
end
|
||||
@@ -62,10 +62,10 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_2
|
||||
|
||||
# Basic Ruby
|
||||
out = `#{self.klayout_bin} -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.rb")}`
|
||||
out = `#{self.klayout_bin} -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.rb")} 2>&1`
|
||||
assert_equal(out, "Variable v1=42 v2=hello\n")
|
||||
|
||||
out = `#{self.klayout_bin} -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")}`
|
||||
out = `#{self.klayout_bin} -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")} 2>&1`
|
||||
assert_equal(out, "test2\ntest3\nVariable v1=42 v2=hello\n")
|
||||
|
||||
end
|
||||
@@ -73,7 +73,7 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_3
|
||||
|
||||
# Basic Python
|
||||
out = `#{self.klayout_bin} -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.py")}`
|
||||
out = `#{self.klayout_bin} -b -rd v1=42 -rd v2=hello -r #{File.join(File.dirname(__FILE__), "test.py")} 2>&1`
|
||||
assert_equal(out, "Variable v1=42 v2=hello\n")
|
||||
|
||||
end
|
||||
@@ -83,20 +83,20 @@ class KLayoutMain_TestClass < TestBase
|
||||
# Application class
|
||||
if !RBA.constants.find { |x| x == :QDialog || x == "QDialog" }
|
||||
|
||||
out = `#{self.klayout_bin} -b -r #{File.join(File.dirname(__FILE__), "test_app.rb")}`
|
||||
out = `#{self.klayout_bin} -b -r #{File.join(File.dirname(__FILE__), "test_app.rb")} 2>&1`
|
||||
assert_equal(out, "RBA::Application superclass Object\nMainWindow is not there\n")
|
||||
|
||||
out = `#{self.klayout_bin} -z -nc -rx -r #{File.join(File.dirname(__FILE__), "test_app.rb")}`
|
||||
out = `#{self.klayout_bin} -z -nc -rx -r #{File.join(File.dirname(__FILE__), "test_app.rb")} 2>&1`
|
||||
assert_equal(out, "RBA::Application superclass Object\nMainWindow is there\n")
|
||||
|
||||
else
|
||||
|
||||
# QCoreApplication for (headless) mode
|
||||
out = `#{self.klayout_bin} -b -r #{File.join(File.dirname(__FILE__), "test_app.rb")}`
|
||||
out = `#{self.klayout_bin} -b -r #{File.join(File.dirname(__FILE__), "test_app.rb")} 2>&1`
|
||||
assert_equal(out, "RBA::Application superclass RBA::QCoreApplication_Native\nMainWindow is not there\n")
|
||||
|
||||
# QApplication for GUI mode
|
||||
out = `#{self.klayout_bin} -z -nc -rx -r #{File.join(File.dirname(__FILE__), "test_app.rb")}`
|
||||
out = `#{self.klayout_bin} -z -nc -rx -r #{File.join(File.dirname(__FILE__), "test_app.rb")} 2>&1`
|
||||
assert_equal(out, "RBA::Application superclass RBA::QApplication_Native\nMainWindow is there\n")
|
||||
|
||||
end
|
||||
@@ -106,7 +106,7 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_5
|
||||
|
||||
# Script variables
|
||||
out = `#{self.klayout_bin} -b -wd tv1=17 -wd tv2=25 -wd tv3 -r #{File.join(File.dirname(__FILE__), "test_script.rb")}`
|
||||
out = `#{self.klayout_bin} -b -wd tv1=17 -wd tv2=25 -wd tv3 -r #{File.join(File.dirname(__FILE__), "test_script.rb")} 2>&1`
|
||||
assert_equal(out, "42\ntrue\n")
|
||||
|
||||
end
|
||||
@@ -114,10 +114,10 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_6
|
||||
|
||||
# Editable / Non-editable mode
|
||||
out = `#{self.klayout_bin} -b -ne -r #{File.join(File.dirname(__FILE__), "test_em.rb")}`
|
||||
out = `#{self.klayout_bin} -b -ne -r #{File.join(File.dirname(__FILE__), "test_em.rb")} 2>&1`
|
||||
assert_equal(out, "false\n")
|
||||
|
||||
out = `#{self.klayout_bin} -b -e -r #{File.join(File.dirname(__FILE__), "test_em.rb")}`
|
||||
out = `#{self.klayout_bin} -b -e -r #{File.join(File.dirname(__FILE__), "test_em.rb")} 2>&1`
|
||||
assert_equal(out, "true\n")
|
||||
|
||||
end
|
||||
@@ -128,27 +128,27 @@ class KLayoutMain_TestClass < TestBase
|
||||
File.open(cfg_file, "w") { |file| file.puts("<config/>") }
|
||||
|
||||
# Special configuration file
|
||||
`#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config1.rb")}`
|
||||
`#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config1.rb")} 2>&1`
|
||||
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}`
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")} 2>&1`
|
||||
assert_equal(out, "42\n")
|
||||
|
||||
# Update
|
||||
`#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config2.rb")}`
|
||||
`#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config2.rb")} 2>&1`
|
||||
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}`
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")} 2>&1`
|
||||
assert_equal(out, "17\n")
|
||||
|
||||
# Reset
|
||||
`#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config1.rb")}`
|
||||
`#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config1.rb")} 2>&1`
|
||||
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}`
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")} 2>&1`
|
||||
assert_equal(out, "42\n")
|
||||
|
||||
# No update
|
||||
`#{self.klayout_bin} -b -t -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config2.rb")}`
|
||||
`#{self.klayout_bin} -b -t -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_set_config2.rb")} 2>&1`
|
||||
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")}`
|
||||
out = `#{self.klayout_bin} -b -c #{cfg_file} -r #{File.join(File.dirname(__FILE__), "test_read_config.rb")} 2>&1`
|
||||
assert_equal(out, "42\n")
|
||||
|
||||
end
|
||||
@@ -156,13 +156,13 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_8
|
||||
|
||||
# Loading layouts
|
||||
out = `#{self.klayout_bin} -z -nc -rx #{File.join(File.dirname(__FILE__), "test1.gds")} -r #{File.join(File.dirname(__FILE__), "test_lay.rb")}`
|
||||
out = `#{self.klayout_bin} -z -nc -rx #{File.join(File.dirname(__FILE__), "test1.gds")} -r #{File.join(File.dirname(__FILE__), "test_lay.rb")} 2>&1`
|
||||
assert_equal(out, "TOP1\n")
|
||||
|
||||
out = `#{self.klayout_bin} -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")}`
|
||||
out = `#{self.klayout_bin} -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")} 2>&1`
|
||||
assert_equal(out, "TOP1\nTOP2\n")
|
||||
|
||||
out = `#{self.klayout_bin} -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")}`
|
||||
out = `#{self.klayout_bin} -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")} 2>&1`
|
||||
assert_equal(out, "TOP1;TOP2\n")
|
||||
|
||||
end
|
||||
@@ -170,11 +170,19 @@ class KLayoutMain_TestClass < TestBase
|
||||
def test_9
|
||||
|
||||
# Sessions
|
||||
out = `#{self.klayout_bin} -z -nc -rx -u #{File.join(File.dirname(__FILE__), "session.lys")} -r #{File.join(File.dirname(__FILE__), "test_lay2.rb")}`
|
||||
out = `#{self.klayout_bin} -z -nc -rx -u #{File.join(File.dirname(__FILE__), "session.lys")} -r #{File.join(File.dirname(__FILE__), "test_lay2.rb")} 2>&1`
|
||||
assert_equal(out, "TOP2;TOP1\n")
|
||||
|
||||
end
|
||||
|
||||
def test_10
|
||||
|
||||
# Headless LayoutView
|
||||
out = `#{self.klayout_bin} -b -rd input=#{File.join(File.dirname(__FILE__), "test1.gds")} -r #{File.join(File.dirname(__FILE__), "test10.rb")} 2>&1`
|
||||
assert_equal(out, "(0,0;8,8)\n")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
|
||||
lv = RBA::LayoutView::new
|
||||
lv.load_layout($input)
|
||||
lv.resize(800, 500)
|
||||
lv.save_screenshot("test10_screenshot.png") # smoke test
|
||||
|
||||
puts lv.active_cellview.layout.top_cell.dbbox.to_s
|
||||
|
||||
Reference in New Issue
Block a user