refactor: align Ruby host with RuboCop while retaining double quotes
This commit is contained in:
+39
-2
@@ -10,7 +10,15 @@ use std::thread::{self, JoinHandle};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{collections::HashSet, env};
|
||||
|
||||
const RUNNER: &str = include_str!("ruby_host.rb");
|
||||
const RUNNER: &str = concat!(
|
||||
include_str!("ruby_values.rb"),
|
||||
"\n",
|
||||
include_str!("ruby_config.rb"),
|
||||
"\n",
|
||||
include_str!("ruby_plugin.rb"),
|
||||
"\n",
|
||||
include_str!("ruby_host.rb"),
|
||||
);
|
||||
const MAX_FRAME: usize = 4 * 1024 * 1024;
|
||||
const MAX_QUEUE: usize = 64;
|
||||
const STARTUP_TIMEOUT: Duration = Duration::from_secs(2);
|
||||
@@ -1243,6 +1251,27 @@ end
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nonstandard_callback_exceptions_are_reported_without_effects() {
|
||||
let fixture = Fixture::new();
|
||||
for (callback, expected) in [
|
||||
("exit 19", "SystemExit: exit"),
|
||||
("raise Interrupt, 'interrupted'", "Interrupt: interrupted"),
|
||||
] {
|
||||
let (mut plugin, _) = fixture.plugin(&format!(
|
||||
"Vamp.plugin 'failure'\nVamp.command('fail') {{ |editor, _| editor.insert 'must not escape'; {callback} }}"
|
||||
));
|
||||
let error = plugin.invoke("fail", "", &context()).unwrap_err();
|
||||
assert!(error.contains(expected), "{error}");
|
||||
assert!(
|
||||
plugin
|
||||
.invoke("fail", "", &context())
|
||||
.unwrap_err()
|
||||
.contains("disabled")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_and_config_hangs_are_bounded() {
|
||||
let fixture = Fixture::new();
|
||||
@@ -1681,7 +1710,15 @@ Vamp.command('flood') { |_, _| 256.times { Vamp.publish [{type: 'message', text:
|
||||
.queue(&serde_json::json!({"type": "shutdown", "version": 1}))
|
||||
.unwrap();
|
||||
let deadline = Instant::now() + STARTUP_TIMEOUT;
|
||||
while !marker.exists() {
|
||||
while plugin
|
||||
.host
|
||||
.child
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.try_wait()
|
||||
.unwrap()
|
||||
.is_none()
|
||||
{
|
||||
assert!(Instant::now() < deadline);
|
||||
thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user