From 1e67ff61d4dfd59c7404f15ef9777c1595f2a758 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 3 Jun 2024 22:49:59 +0200 Subject: [PATCH] Bugfix #35 (XSectionGenerator::run not working) - Added tests for API (run_api_tests.sh) - Version 1.10 --- .gitignore | 3 +++ CHANGELOG.md | 4 ++++ src/grain.xml | 2 +- src/macros/xsection.lym | 2 +- src/ruby/xsection_generator.rb | 2 +- tests/api_tests.rb | 42 ++++++++++++++++++++++++++++++++++ tests/run_api_tests.sh | 37 ++++++++++++++++++++++++++++++ tests/run_tests.sh | 2 +- 8 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 tests/api_tests.rb create mode 100755 tests/run_api_tests.sh diff --git a/.gitignore b/.gitignore index 212c154..9b2c06c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ tests/run_dir +.*.swp +.*.swo +klayout_crash.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a714ae..511d0f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ +# Version 1.10 - 2024-06-03 + +* Bugfix issue #35 (XSectionGenerator::run not working) + # Version 1.9 - 2024-05-28 * Bugfix issue #34 ("XSection: Active Technology" not working in Windows) diff --git a/src/grain.xml b/src/grain.xml index 5fea895..0adea93 100644 --- a/src/grain.xml +++ b/src/grain.xml @@ -1,7 +1,7 @@ xsection - 1.9 + 1.10 Ruby script A generator for vertical cross sections of layouts using a technology description file. diff --git a/src/macros/xsection.lym b/src/macros/xsection.lym index 70f17d7..9f1e466 100644 --- a/src/macros/xsection.lym +++ b/src/macros/xsection.lym @@ -32,7 +32,7 @@ require_relative("../ruby/xsection") module XS # UPDATE THE VERSION NUMBER ON EACH RELEASE HERE - VERSION = "1.9" + VERSION = "1.10" @xsection_processing_environment = XSectionScriptEnvironment.new diff --git a/src/ruby/xsection_generator.rb b/src/ruby/xsection_generator.rb index 7342591..1383c4e 100644 --- a/src/ruby/xsection_generator.rb +++ b/src/ruby/xsection_generator.rb @@ -488,7 +488,7 @@ def layers_file(lyp_file) # The basic generation method (single segment) def run(p1, p2, cv) - run_multi([ p1, p2 ]) + run_multi([[ p1, p2 ]], cv) end # The basic generation method (multiple segments) diff --git a/tests/api_tests.rb b/tests/api_tests.rb new file mode 100644 index 0000000..3744357 --- /dev/null +++ b/tests/api_tests.rb @@ -0,0 +1,42 @@ + +require "test/unit" +require 'test/unit/ui/console/testrunner' + +# NOTE: these tests are more like smoke tests +# For the real tests, see "run_tests.sh" + +class XSectionAPITest < Test::Unit::TestCase + + def test_run + + mw = RBA::MainWindow.instance + mw.load_layout($input_file, 1) + + cv = RBA::CellView.active + + gen = XS::XSectionGenerator.new($xs_file) + view = gen.run(RBA::DPoint.new(-1, 0), RBA::DPoint.new(1, 0), cv) + + assert_equal("(-0.042,-2.058;2.058,0.042)", view.box.to_s) + + end + + def test_run_multi + + mw = RBA::MainWindow.instance + mw.load_layout($input_file, 1) + + cv = RBA::CellView.active + + gen = XS::XSectionGenerator.new($xs_file) + view = gen.run_multi([[ RBA::DPoint.new(-1, 0), RBA::DPoint.new(0, 0) ], [ RBA::DPoint.new(0, 0), RBA::DPoint.new(1, 0) ]], cv) + + assert_equal("(-0.042,-2.058;2.058,0.042)", view.box.to_s) + + end + +end + +test_suite = XSectionAPITest.suite +Test::Unit::UI::Console::TestRunner.run(test_suite) + diff --git a/tests/run_api_tests.sh b/tests/run_api_tests.sh new file mode 100755 index 0000000..6bc965e --- /dev/null +++ b/tests/run_api_tests.sh @@ -0,0 +1,37 @@ +#!/bin/bash -e + +export KLAYOUT_HOME=/dev/null + +def_path_win="$HOME/AppData/Roaming/KLayout" +if [ -e "$def_path_win" ] && [ -d "$def_path_win" ]; then + echo "Adding default installation path: $def_path_win" + export PATH="$def_path_win:$PATH" +fi + +# locate klayout binary +for exe in klayout klayout_app.exe; do + if which $exe 2>/dev/null; then + klayout=$(which $exe) + break + fi +done + +if [ "$klayout" = "" ]; then + echo "No KLayout binary found in PATH .. please set path to point to klayout binary" + exit 1 +fi + +echo "Using KLayout binary from: $klayout" + +rm -rf run_dir +mkdir -p run_dir + +failed="" + +bin=../src/macros/xsection.lym + +export KLAYOUT_PATH=../src +export KLAYOUT_HOME=run_dir + +$klayout -nc -z -r api_tests.rb -rd xs_file=xs_etch1.xs -rd input_file=xs_test.gds + diff --git a/tests/run_tests.sh b/tests/run_tests.sh index d237966..cb7277c 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -53,7 +53,7 @@ for tc_file in $tc_files; do xs_cut="-1,0;1,0" fi - $klayout -rx -z -rd xs_run=$tc.xs -rd xs_cut="$xs_cut" -rd xs_out=run_dir/$tc.gds "$xs_input" -r $bin + $klayout -nc -rx -z -rd xs_run=$tc.xs -rd xs_cut="$xs_cut" -rd xs_out=run_dir/$tc.gds "$xs_input" -r $bin if $klayout -b -rd a=au/$tc.gds -rd b=run_dir/$tc.gds -rd tol=10 -r run_xor.rb; then echo "No differences found."