Skip to content
Open
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@

## Unreleased

* Fixed Chrome browser windows not being closed after a test run
* Updated dependencies
* Updated wax to 0.6.0
* Updated async-recursion to 1.1.1
* Updated similar to 2.7.0
* Updated inventory to 0.3.20
* Updated tempfile to 3.20.0
* Updated console to 0.16
* Updated async-trait to 0.1.88
* Updated schematic to 0.18.12
* Updated strip-ansi-escapes to 0.2.1
* Updated semver to 1.0.26

## v0.15.0 (May 16, 2025)

* Added a `--retry-count` option to retry failed tests
Expand Down
20 changes: 10 additions & 10 deletions toolproof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ license = "MIT"

[dependencies]
thiserror = "1.0"
wax = "0.5.0"
wax = "0.6.0"
tokio = { version = "1", features = ["full", "tracing"] }
futures = "0.3"
async-recursion = "1.1.0"
async-recursion = "1.1.1"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9"
serde_json = "1"
nondestructive = "0.0.20"
similar = { version = "2.4.0", features = ["inline"] }
inventory = "0.3.15"
similar = { version = "2.7.0", features = ["inline"] }
inventory = "0.3.20"
portpicker = "0.1"
actix-web = "4"
actix-files = "0.6"
json_dotpath = "1.1.0"
tempfile = "3.0.2"
tempfile = "3.20.0"
similar-string = "1.4.3"
console = "0.15"
console = "0.16"
dialoguer = { version = "0.11", features = ["fuzzy-select"] }
async-trait = "0.1.78"
async-trait = "0.1.88"
pagebrowse = "0.1.1"
chromiumoxide = "0.7"
clap = { version = "4", features = ["cargo"] }
schematic = { version = "0.18.4", features = ["yaml"] }
strip-ansi-escapes = "0.2.0"
schematic = { version = "0.18.12", features = ["yaml"] }
strip-ansi-escapes = "0.2.1"
path-slash = "0.2.1"
normalize-path = "0.2.1"
miette = { version = "7", features = ["fancy"] }
semver = "1.0.25"
semver = "1.0.26"

[profile.dev.package.similar]
opt-level = 3
9 changes: 8 additions & 1 deletion toolproof/src/civilization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ pub struct Civilization<'u> {
}

impl<'u> Civilization<'u> {
pub async fn shutdown(&mut self) {
pub async fn shutdown(self) {
for handle in &self.handles {
handle.stop(false).await;
}
for thread in &self.threads {
thread.abort();
}

if let Some(BrowserWindow::Chrome(window)) = self.window {
window
.close()
.await
.expect("Failed to close browser window");
}
}
}

Expand Down
28 changes: 13 additions & 15 deletions toolproof/src/definitions/assertions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::collections::HashMap;

use async_trait::async_trait;

use crate::civilization::Civilization;
use crate::errors::{ToolproofInputError, ToolproofInternalError, ToolproofStepError};
use crate::errors::{ToolproofInternalError, ToolproofStepError};

use super::{SegmentArgs, ToolproofAssertion, ToolproofInstruction, ToolproofRetriever};
use super::{SegmentArgs, ToolproofAssertion};

fn value_contains_value(
base: &serde_json::Value,
Expand Down Expand Up @@ -87,7 +85,7 @@ fn value_type(val: &serde_json::Value) -> &'static str {
}

mod contain {
use crate::errors::{ToolproofInternalError, ToolproofTestFailure};
use crate::errors::ToolproofTestFailure;

use super::*;

Expand All @@ -107,7 +105,7 @@ mod contain {
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
let expected = args.get_value("expected")?;

Expand Down Expand Up @@ -143,7 +141,7 @@ mod contain {
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
let expected = args.get_value("expected")?;

Expand All @@ -163,7 +161,7 @@ mod contain {
}

mod exactly {
use crate::errors::{ToolproofInternalError, ToolproofTestFailure};
use crate::errors::ToolproofTestFailure;

use super::*;

Expand All @@ -183,7 +181,7 @@ mod exactly {
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
let expected = args.get_value("expected")?;

Expand Down Expand Up @@ -217,7 +215,7 @@ mod exactly {
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
let expected = args.get_value("expected")?;

Expand All @@ -237,7 +235,7 @@ mod exactly {
}

mod empty {
use crate::errors::{ToolproofInternalError, ToolproofTestFailure};
use crate::errors::ToolproofTestFailure;

use super::*;

Expand All @@ -256,8 +254,8 @@ mod empty {
async fn run(
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_args: &SegmentArgs<'_>,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
if value_is_empty(&base_value) {
Ok(())
Expand Down Expand Up @@ -289,8 +287,8 @@ mod empty {
async fn run(
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_args: &SegmentArgs<'_>,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
if value_is_empty(&base_value) {
Err(ToolproofStepError::Assertion(
Expand Down
5 changes: 1 addition & 4 deletions toolproof/src/definitions/browser/browser_specific.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::path::PathBuf;

use chromiumoxide::cdp::browser_protocol::{
input::{DispatchKeyEventParams, DispatchKeyEventType},
page::CaptureScreenshotFormat,
};
use chromiumoxide::cdp::browser_protocol::page::CaptureScreenshotFormat;

use crate::errors::{ToolproofInputError, ToolproofStepError, ToolproofTestFailure};

Expand Down
12 changes: 2 additions & 10 deletions toolproof/src/definitions/browser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use std::path::PathBuf;
use std::sync::Arc;

use async_trait::async_trait;
use chromiumoxide::cdp::browser_protocol::page::{
CaptureScreenshotFormat, CaptureScreenshotParams,
};
use chromiumoxide::cdp::browser_protocol::page::CaptureScreenshotParams;
use chromiumoxide::cdp::browser_protocol::target::{
CreateBrowserContextParams, CreateTargetParams,
};
use chromiumoxide::cdp::js_protocol::runtime::RemoteObjectType;
use chromiumoxide::error::CdpError;
use chromiumoxide::handler::viewport::Viewport;
use chromiumoxide::page::ScreenshotParams;
Expand Down Expand Up @@ -627,10 +624,6 @@ mod load_page {
}

mod eval_js {
use std::time::Duration;

use futures::TryFutureExt;
use tokio::time::sleep;

use crate::errors::{ToolproofInternalError, ToolproofTestFailure};

Expand Down Expand Up @@ -747,7 +740,7 @@ mod eval_js {

async fn run(
&self,
args: &SegmentArgs<'_>,
_args: &SegmentArgs<'_>,
civ: &mut Civilization,
) -> Result<serde_json::Value, ToolproofStepError> {
eval_and_return_js("return toolproof_log_events[`ALL`];".to_string(), civ).await
Expand All @@ -756,7 +749,6 @@ mod eval_js {
}

pub mod screenshots {
use crate::errors::{ToolproofInternalError, ToolproofTestFailure};

use super::*;

Expand Down
3 changes: 0 additions & 3 deletions toolproof/src/definitions/filesystem/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::HashMap;

use async_trait::async_trait;

use crate::civilization::Civilization;
Expand Down Expand Up @@ -46,7 +44,6 @@ mod new_file {
}

mod read_files {
use crate::errors::ToolproofTestFailure;

use super::*;

Expand Down
5 changes: 1 addition & 4 deletions toolproof/src/definitions/hosting/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use std::collections::HashMap;

use super::{SegmentArgs, ToolproofInstruction};
use crate::civilization::Civilization;
use crate::errors::{ToolproofInputError, ToolproofStepError};
use crate::errors::ToolproofStepError;

use async_trait::async_trait;

mod host_dir {
use std::time::Duration;

use actix_web::{App, HttpServer};
use futures::pending;
use schematic::color::owo::OwoColorize;
use tokio::time::sleep;

Expand Down
21 changes: 10 additions & 11 deletions toolproof/src/definitions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::{collections::HashMap, hash::Hash};
use std::collections::HashMap;

use async_trait::async_trait;

use crate::{
civilization::Civilization,
errors::{ToolproofInputError, ToolproofStepError},
options::{ToolproofContext, ToolproofParams},
errors::ToolproofStepError,
parser::parse_segments,
segments::{SegmentArgs, ToolproofSegment, ToolproofSegments},
segments::{SegmentArgs, ToolproofSegments},
};

mod assertions;
Expand Down Expand Up @@ -115,8 +114,8 @@ mod test {

async fn run(
&self,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_args: &SegmentArgs<'_>,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
Ok(())
}
Expand Down Expand Up @@ -153,8 +152,8 @@ mod test {

async fn run(
&self,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_args: &SegmentArgs<'_>,
_civ: &mut Civilization,
) -> Result<serde_json::Value, ToolproofStepError> {
Ok(serde_json::Value::Null)
}
Expand Down Expand Up @@ -190,9 +189,9 @@ mod test {

async fn run(
&self,
base_value: serde_json::Value,
args: &SegmentArgs<'_>,
civ: &mut Civilization,
_base_value: serde_json::Value,
_args: &SegmentArgs<'_>,
_civ: &mut Civilization,
) -> Result<(), ToolproofStepError> {
Ok(())
}
Expand Down
10 changes: 4 additions & 6 deletions toolproof/src/definitions/process/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::collections::HashMap;

use async_trait::async_trait;

use crate::civilization::Civilization;
use crate::errors::{ToolproofInputError, ToolproofStepError};
use crate::errors::ToolproofStepError;

use super::{SegmentArgs, ToolproofAssertion, ToolproofInstruction, ToolproofRetriever};
use super::{SegmentArgs, ToolproofInstruction, ToolproofRetriever};

mod env_var {
use super::*;
Expand Down Expand Up @@ -135,7 +133,7 @@ mod stdio {

async fn run(
&self,
args: &SegmentArgs<'_>,
_args: &SegmentArgs<'_>,
civ: &mut Civilization,
) -> Result<serde_json::Value, ToolproofStepError> {
let Some(output) = &civ.last_command_output else {
Expand Down Expand Up @@ -164,7 +162,7 @@ mod stdio {

async fn run(
&self,
args: &SegmentArgs<'_>,
_args: &SegmentArgs<'_>,
civ: &mut Civilization,
) -> Result<serde_json::Value, ToolproofStepError> {
let Some(output) = &civ.last_command_output else {
Expand Down
2 changes: 0 additions & 2 deletions toolproof/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::path::PathBuf;

use chromiumoxide::error::CdpError;
use pagebrowse::PagebrowseError;
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion toolproof/src/interactive.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt::Display, io, path::PathBuf, sync::Arc};
use std::{io, sync::Arc};

use console::{Key, Term};
use dialoguer::{theme::ColorfulTheme, Confirm, FuzzySelect, Select};
Expand Down
18 changes: 2 additions & 16 deletions toolproof/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,22 +656,8 @@ async fn main_inner() -> Result<(), ()> {
}
}
}
ToolproofTestStep::Extract {
extract,
extract_location,
args,
orig,
state,
platforms,
} => todo!(),
ToolproofTestStep::Snapshot {
snapshot,
snapshot_content,
args,
orig,
state,
platforms,
} => todo!(),
ToolproofTestStep::Extract { .. } => todo!(),
ToolproofTestStep::Snapshot { .. } => todo!(),
}
}
_ => {
Expand Down
Loading
Loading