Skip to content

Commit

Permalink
ah lets see
Browse files Browse the repository at this point in the history
  • Loading branch information
gintama91 committed Jul 10, 2023
1 parent c78ea76 commit 5e3f8c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 2 additions & 4 deletions ext/wry_ruby/src/application/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ pub fn WindoWnew(title: String, width: u32, height: u32, resizable: bool,timeout
} => *control_flow = ControlFlow::Exit,
_ => (),
}

let elapsed = Instant::now() - start_time;
if elapsed >= timeout_duration {
println!("Window creation timed out after {:?}.", timeout_duration);
// Handle the timeout error here
*control_flow = ControlFlow::Exit;
panic!("Window creation timed out after {:?}.", timeout_duration);
}

});
}

Expand Down
18 changes: 13 additions & 5 deletions test/test_wry_ruby.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
require "test_helper"
require "timeout"

class TestWryRuby < Minitest::Test
# def test_that_it_has_a_version_number
# refute_nil ::WryRuby::VERSION
# end

def test_hello_wry
new_window "Hello Wry", 100, 400, true, 2 # title, width, height, resizable, timeout to close window for tests
timeout_seconds = 1
assert_timeout(timeout_seconds) do
new_window "Hello Wry", 100, 400, true, 1 # title, width, height, resizable
end
end

private

def assert_timeout(timeout_seconds, &block)
Timeout.timeout(timeout_seconds, &block)
rescue Timeout::Error
raise "Window creation timed out after #{timeout_seconds}s."
end
end

0 comments on commit 5e3f8c8

Please sign in to comment.