Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions crates/wright-driver/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ pub struct SessionConfig {
/// [`CompilerSession::language_provider`] spawns a provider client for a
/// language id from this registry; when no provider is configured the
/// refusal is explicit and there is no fallback to in-process frontends.
/// The registry is empty by default; `wright_lpp::ProviderRegistry`
/// documents the configuration (and the `LPP_MOCK_PROVIDER` env hook
/// used by tests and CI).
/// The registry is empty by default; providers are registered explicitly
/// through `wright_lpp::ProviderRegistry` (integration tests and CI
/// locate the mock provider through the `LPP_MOCK_PROVIDER`
/// environment variable).
pub providers: wright_lpp::ProviderRegistry,
}

Expand Down
38 changes: 0 additions & 38 deletions crates/wright-lpp/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ use std::time::Duration;
use crate::error::ProviderError;
use crate::provider::StdioLanguageProvider;

/// The environment variable naming the LPP mock/conformance provider binary
/// used by integration tests and CI.
pub const LPP_MOCK_PROVIDER_ENV: &str = "LPP_MOCK_PROVIDER";

/// One configured provider, keyed by its opaque language id.
#[derive(Debug, Clone)]
pub struct ProviderConfig {
Expand Down Expand Up @@ -47,12 +43,6 @@ impl ProviderConfig {
request_timeout: Duration::from_secs(30),
}
}

/// Set an explicit per-request timeout.
pub fn with_request_timeout(mut self, request_timeout: Duration) -> ProviderConfig {
self.request_timeout = request_timeout;
self
}
}

/// A registry error.
Expand Down Expand Up @@ -99,16 +89,6 @@ impl ProviderRegistry {
Ok(())
}

/// The configuration registered for a language id, if any.
pub fn get(&self, language_id: &str) -> Option<&ProviderConfig> {
self.providers.get(language_id)
}

/// Every registered language id, in deterministic order.
pub fn languages(&self) -> impl Iterator<Item = &str> {
self.providers.keys().map(String::as_str)
}

/// Spawn a fresh provider session for `language_id`.
///
/// Refuses explicitly when no provider is configured for the id
Expand All @@ -123,22 +103,4 @@ impl ProviderRegistry {
})?;
StdioLanguageProvider::spawn(&config.command, &config.args, config.request_timeout)
}

/// A registry populated from the environment: `LPP_MOCK_PROVIDER` names
/// a mock/conformance provider binary serving the reference language
/// `x-demo-lang`. This is the integration-test/CI hook; production
/// configuration registers providers explicitly.
pub fn from_env() -> ProviderRegistry {
let mut registry = ProviderRegistry::new();
if let Ok(command) = std::env::var(LPP_MOCK_PROVIDER_ENV) {
if !command.is_empty() {
let _ = registry.register(ProviderConfig::new(
"x-demo-lang",
PathBuf::from(command),
Vec::new(),
));
}
}
registry
}
}
17 changes: 5 additions & 12 deletions crates/wright-lpp/tests/mock_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ fn registry_lookup_is_by_opaque_language_id() {
language_id: "x-other-lang".to_string(),
}
);
assert_eq!(
registry.languages().collect::<Vec<_>>(),
vec![DEMO_LANGUAGE_ID]
);
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -506,14 +502,11 @@ fn missing_capability_is_an_explicit_refusal_not_a_fallback() {
};
let mut registry = ProviderRegistry::new();
registry
.register(
ProviderConfig::new(
DEMO_LANGUAGE_ID,
path,
vec!["--without".to_string(), "compile".to_string()],
)
.with_request_timeout(std::time::Duration::from_secs(30)),
)
.register(ProviderConfig::new(
DEMO_LANGUAGE_ID,
path,
vec!["--without".to_string(), "compile".to_string()],
))
.expect("registered");
let mut provider = registry.spawn(DEMO_LANGUAGE_ID).expect("spawns");
let result = provider
Expand Down