Skip to content

Commit

Permalink
better doc
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Sep 18, 2023
1 parent e670372 commit 8f19efb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions sqllogictest/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ impl<T: ColumnType> std::fmt::Display for Record<T> {
}
}

/// Whether to enable or disable a feature. Used in `control` statements.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum OnOff {
On,
Expand Down
5 changes: 3 additions & 2 deletions sqllogictest/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::parser::*;
use crate::substitution::Substitution;
use crate::{ColumnType, Connections, MakeConnection};

/// Type-erased error type.
type AnyError = Arc<dyn std::error::Error + Send + Sync>;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -1067,8 +1068,8 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
block_on(self.run_parallel_async(glob, hosts, conn_builder, jobs))
}

/// Substitute the input SQL or command with environment variables and `__TEST_DIR__`, if
/// enabled with `control`.
/// Substitute the input SQL or command with [`Substitution`], if enabled by `control
/// substitution`.
fn may_substitute(&self, input: String) -> Result<String, AnyError> {
if let Some(substitution) = &self.substitution {
subst::substitute(&input, substitution).map_err(|e| Arc::new(e) as AnyError)
Expand Down
3 changes: 3 additions & 0 deletions sqllogictest/src/substitution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ use std::sync::OnceLock;
use subst::Env;
use tempfile::{tempdir, TempDir};

/// Substitute environment variables and special variables like `__TEST_DIR__` in SQL.
#[derive(Default)]
pub(crate) struct Substitution {
/// The temporary directory for `__TEST_DIR__`.
/// Lazily initialized and cleaned up when dropped.
test_dir: OnceLock<TempDir>,
}

Expand Down

0 comments on commit 8f19efb

Please sign in to comment.