Skip to content

Commit 016d23d

Browse files
Avoid a segfault after test runs.
1 parent 8146228 commit 016d23d

File tree

1 file changed

+55
-43
lines changed

1 file changed

+55
-43
lines changed

ruby/tests.rb

+55-43
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,33 @@ class TFImport_TestClass < Test::Unit::TestCase
1818

1919
def test_read1
2020

21-
lv = RBA::LayoutView::new
22-
23-
tf_file = File.join(File.dirname(__FILE__), "testdata_1", "techfile.tf")
24-
TechfileToKLayout.import_techfile(lv, tf_file)
25-
26-
lp = []
27-
28-
li = lv.begin_layers
29-
while !li.at_end?
30-
lp << [
31-
li.current.fill_color,
32-
li.current.frame_color,
33-
li.current.dither_pattern,
34-
li.current.line_style,
35-
li.current.name,
36-
li.current.source,
37-
li.current.width,
38-
li.current.valid?,
39-
li.current.xfill?
40-
]
41-
li.next
21+
begin
22+
23+
lv = RBA::LayoutView::new
24+
25+
tf_file = File.join(File.dirname(__FILE__), "testdata_1", "techfile.tf")
26+
TechfileToKLayout.import_techfile(lv, tf_file)
27+
28+
lp = []
29+
30+
li = lv.begin_layers
31+
while !li.at_end?
32+
lp << [
33+
li.current.fill_color,
34+
li.current.frame_color,
35+
li.current.dither_pattern,
36+
li.current.line_style,
37+
li.current.name,
38+
li.current.source,
39+
li.current.width,
40+
li.current.valid?,
41+
li.current.xfill?
42+
]
43+
li.next
44+
end
45+
46+
ensure
47+
lv._destroy
4248
end
4349

4450
ref = [
@@ -74,27 +80,33 @@ def test_read1
7480

7581
def test_read2
7682

77-
lv = RBA::LayoutView::new
78-
79-
tf_file = File.join(File.dirname(__FILE__), "testdata_2", "techfile.tf")
80-
TechfileToKLayout.import_techfile(lv, tf_file)
81-
82-
lp = []
83-
84-
li = lv.begin_layers
85-
while !li.at_end?
86-
lp << [
87-
li.current.fill_color,
88-
li.current.frame_color,
89-
li.current.dither_pattern,
90-
li.current.line_style,
91-
li.current.name,
92-
li.current.source,
93-
li.current.width,
94-
li.current.valid?,
95-
li.current.xfill?
96-
]
97-
li.next
83+
begin
84+
85+
lv = RBA::LayoutView::new
86+
87+
tf_file = File.join(File.dirname(__FILE__), "testdata_2", "techfile.tf")
88+
TechfileToKLayout.import_techfile(lv, tf_file)
89+
90+
lp = []
91+
92+
li = lv.begin_layers
93+
while !li.at_end?
94+
lp << [
95+
li.current.fill_color,
96+
li.current.frame_color,
97+
li.current.dither_pattern,
98+
li.current.line_style,
99+
li.current.name,
100+
li.current.source,
101+
li.current.width,
102+
li.current.valid?,
103+
li.current.xfill?
104+
]
105+
li.next
106+
end
107+
108+
ensure
109+
lv._destroy
98110
end
99111

100112
ref = [
@@ -152,4 +164,4 @@ def test_started(name)
152164

153165
err == 0 || $stderr.puts("Test(s) failed. See log for details")
154166

155-
end
167+
end

0 commit comments

Comments
 (0)