diff --git a/Cargo.lock b/Cargo.lock index af112883e..ff4c8373d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,7 +1779,6 @@ dependencies = [ "gosub_rendering", "gosub_shared", "gosub_taffy", - "gosub_testing", "gosub_useragent", "gosub_v8", "gosub_vello", @@ -1809,10 +1808,15 @@ dependencies = [ "derive_more", "gosub_css3", "gosub_shared", - "gosub_testing", "lazy_static", "log", + "nom", + "nom_locate", "phf", + "regex", + "serde", + "serde_derive", + "serde_json", "test-case", "thiserror 2.0.7", "ureq", @@ -1927,21 +1931,6 @@ dependencies = [ "taffy", ] -[[package]] -name = "gosub_testing" -version = "0.1.0" -dependencies = [ - "gosub_html5", - "gosub_shared", - "lazy_static", - "nom", - "nom_locate", - "regex", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "gosub_typeface" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index b7c3fed29..95123c16a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,6 @@ gosub_config = { path = "./crates/gosub_config", features = [] } gosub_html5 = { path = "./crates/gosub_html5", features = [] } gosub_css3 = { path = "./crates/gosub_css3", features = [] } gosub_jsapi = { path = "./crates/gosub_jsapi", features = [] } -gosub_testing = { path = "./crates/gosub_testing", features = [] } gosub_rendering = { path = "crates/gosub_render_utils", features = [] } gosub_renderer = { path = "./crates/gosub_renderer", features = [] } gosub_vello = { path = "./crates/gosub_vello", features = [] } diff --git a/crates/gosub_html5/Cargo.toml b/crates/gosub_html5/Cargo.toml index 9564a7769..cd8f7a8a6 100644 --- a/crates/gosub_html5/Cargo.toml +++ b/crates/gosub_html5/Cargo.toml @@ -14,15 +14,21 @@ lazy_static = "1.5" thiserror = "2.0.7" url = { version = "2.5.4", features = [] } log = { version = "0.4.22", features = [] } +nom = "7.1.3" +nom_locate = "4.2.0" +regex = "1" +serde = { version = "1.0", features = ["derive"] } +serde_json = { version = "1.0", features = ["preserve_order"] } +serde_derive = "1.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] ureq = "2.12.1" [dev-dependencies] -gosub_testing = { path = "../gosub_testing" } test-case = "3.3.1" criterion = { version = "0.5.1", features = ["html_reports"] } + [features] debug_parser = [] debug_parser_verbose = [] diff --git a/crates/gosub_html5/benches/tokenizer.rs b/crates/gosub_html5/benches/tokenizer.rs index e20824a6a..908f14501 100644 --- a/crates/gosub_html5/benches/tokenizer.rs +++ b/crates/gosub_html5/benches/tokenizer.rs @@ -1,5 +1,5 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use gosub_testing::testing::tokenizer::{self, FixtureFile}; +use gosub_html5::testing::tokenizer::{self, FixtureFile}; fn criterion_benchmark(c: &mut Criterion) { // Criterion can report inconsistent results from run to run in some cases. We attempt to diff --git a/crates/gosub_html5/benches/tree_construction.rs b/crates/gosub_html5/benches/tree_construction.rs index e8a6aa13d..61bda103d 100644 --- a/crates/gosub_html5/benches/tree_construction.rs +++ b/crates/gosub_html5/benches/tree_construction.rs @@ -5,8 +5,8 @@ use gosub_html5::document::document_impl::DocumentImpl; use gosub_html5::document::fragment::DocumentFragmentImpl; use gosub_html5::parser::Html5Parser; use gosub_shared::traits::config::{HasCssSystem, HasDocument, HasHtmlParser}; -use gosub_testing::testing::tree_construction; -use gosub_testing::testing::tree_construction::Harness; +use gosub_html5::testing::tree_construction; +use gosub_html5::testing::tree_construction::Harness; #[derive(Clone, Debug, PartialEq)] struct Config; diff --git a/crates/gosub_html5/src/lib.rs b/crates/gosub_html5/src/lib.rs index 8ca8f39b2..ed8186a35 100644 --- a/crates/gosub_html5/src/lib.rs +++ b/crates/gosub_html5/src/lib.rs @@ -17,6 +17,7 @@ pub mod parser; pub mod tokenizer; #[allow(dead_code)] pub mod writer; +pub mod testing; /// Parses the given HTML string and returns a handle to the resulting DOM tree. pub fn html_compile(html: &str) -> DocumentHandle { diff --git a/crates/gosub_html5/src/parser/tree_builder.rs b/crates/gosub_html5/src/parser/tree_builder.rs index 4630969e3..855e47512 100644 --- a/crates/gosub_html5/src/parser/tree_builder.rs +++ b/crates/gosub_html5/src/parser/tree_builder.rs @@ -34,10 +34,10 @@ mod tests { use crate::document::document_impl::DocumentImpl; use crate::document::fragment::DocumentFragmentImpl; use crate::parser::Html5Parser; + use crate::testing::tree_construction::fixture::{fixture_root_path, read_fixture_from_path}; + use crate::testing::tree_construction::Harness; use gosub_css3::system::Css3System; use gosub_shared::traits::config::{HasCssSystem, HasDocument, HasHtmlParser}; - use gosub_testing::testing::tree_construction::fixture::{fixture_root_path, read_fixture_from_path}; - use gosub_testing::testing::tree_construction::Harness; use test_case::test_case; #[derive(Clone, Debug, PartialEq)] @@ -119,6 +119,7 @@ mod tests { #[test_case("webkit01.dat")] #[test_case("webkit02.dat")] fn tree_construction(filename: &str) { + dbg!(fixture_root_path().join(filename)); let fixture_file = read_fixture_from_path(fixture_root_path().join(filename)).expect("fixture"); let mut harness = Harness::new(); diff --git a/crates/gosub_testing/src/testing.rs b/crates/gosub_html5/src/testing.rs similarity index 82% rename from crates/gosub_testing/src/testing.rs rename to crates/gosub_html5/src/testing.rs index 72668cab2..0041481c7 100644 --- a/crates/gosub_testing/src/testing.rs +++ b/crates/gosub_html5/src/testing.rs @@ -2,5 +2,5 @@ pub mod tokenizer; pub mod tree_construction; -pub const FIXTURE_ROOT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../gosub_html5/tests/data/html5lib-tests",); +pub const FIXTURE_ROOT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/./tests/data/html5lib-tests",); pub const TREE_CONSTRUCTION_PATH: &str = "tree-construction"; diff --git a/crates/gosub_testing/src/testing/tokenizer.rs b/crates/gosub_html5/src/testing/tokenizer.rs similarity index 99% rename from crates/gosub_testing/src/testing/tokenizer.rs rename to crates/gosub_html5/src/testing/tokenizer.rs index 6506d3ee0..e61d0eab4 100644 --- a/crates/gosub_testing/src/testing/tokenizer.rs +++ b/crates/gosub_html5/src/testing/tokenizer.rs @@ -1,7 +1,7 @@ use super::FIXTURE_ROOT; -use gosub_html5::parser::errors::ErrorLogger; -use gosub_html5::tokenizer::ParserData; -use gosub_html5::tokenizer::{ +use crate::parser::errors::ErrorLogger; +use crate::tokenizer::ParserData; +use crate::tokenizer::{ state::State as TokenState, token::Token, {Options, Tokenizer}, diff --git a/crates/gosub_testing/src/testing/tree_construction.rs b/crates/gosub_html5/src/testing/tree_construction.rs similarity index 98% rename from crates/gosub_testing/src/testing/tree_construction.rs rename to crates/gosub_html5/src/testing/tree_construction.rs index 2888b2edc..71bb733a4 100644 --- a/crates/gosub_testing/src/testing/tree_construction.rs +++ b/crates/gosub_html5/src/testing/tree_construction.rs @@ -1,10 +1,10 @@ pub mod fixture; mod generator; -pub(crate) mod parser; +pub mod parser; pub mod result; use generator::TreeOutputGenerator; -use gosub_html5::node::{HTML_NAMESPACE, MATHML_NAMESPACE, SVG_NAMESPACE}; +use crate::node::{HTML_NAMESPACE, MATHML_NAMESPACE, SVG_NAMESPACE}; use gosub_shared::byte_stream::{ByteStream, Config, Encoding, Location}; use gosub_shared::document::DocumentHandle; use gosub_shared::node::NodeId; diff --git a/crates/gosub_testing/src/testing/tree_construction/fixture.rs b/crates/gosub_html5/src/testing/tree_construction/fixture.rs similarity index 100% rename from crates/gosub_testing/src/testing/tree_construction/fixture.rs rename to crates/gosub_html5/src/testing/tree_construction/fixture.rs diff --git a/crates/gosub_testing/src/testing/tree_construction/generator.rs b/crates/gosub_html5/src/testing/tree_construction/generator.rs similarity index 97% rename from crates/gosub_testing/src/testing/tree_construction/generator.rs rename to crates/gosub_html5/src/testing/tree_construction/generator.rs index 83c96c103..948f3df59 100644 --- a/crates/gosub_testing/src/testing/tree_construction/generator.rs +++ b/crates/gosub_html5/src/testing/tree_construction/generator.rs @@ -1,5 +1,5 @@ -use gosub_html5::node::HTML_NAMESPACE; -use gosub_html5::node::{MATHML_NAMESPACE, SVG_NAMESPACE, XLINK_NAMESPACE, XMLNS_NAMESPACE}; +use crate::node::HTML_NAMESPACE; +use crate::node::{MATHML_NAMESPACE, SVG_NAMESPACE, XLINK_NAMESPACE, XMLNS_NAMESPACE}; use gosub_shared::document::DocumentHandle; use gosub_shared::traits::config::HasDocument; use gosub_shared::traits::document::Document; diff --git a/crates/gosub_testing/src/testing/tree_construction/parser.rs b/crates/gosub_html5/src/testing/tree_construction/parser.rs similarity index 100% rename from crates/gosub_testing/src/testing/tree_construction/parser.rs rename to crates/gosub_html5/src/testing/tree_construction/parser.rs diff --git a/crates/gosub_testing/src/testing/tree_construction/result.rs b/crates/gosub_html5/src/testing/tree_construction/result.rs similarity index 100% rename from crates/gosub_testing/src/testing/tree_construction/result.rs rename to crates/gosub_html5/src/testing/tree_construction/result.rs diff --git a/crates/gosub_html5/src/tokenizer/test_cases.rs b/crates/gosub_html5/src/tokenizer/test_cases.rs index a0aff123a..6e5088bb9 100644 --- a/crates/gosub_html5/src/tokenizer/test_cases.rs +++ b/crates/gosub_html5/src/tokenizer/test_cases.rs @@ -1,4 +1,4 @@ -use gosub_testing::testing::tokenizer::{self, FixtureFile}; +use crate::testing::tokenizer::{self, FixtureFile}; use lazy_static::lazy_static; use std::collections::HashSet; use test_case::test_case; diff --git a/crates/gosub_testing/Cargo.toml b/crates/gosub_testing/Cargo.toml deleted file mode 100644 index 644411f14..000000000 --- a/crates/gosub_testing/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "gosub_testing" -version = "0.1.0" -edition = "2021" -authors = ["Gosub Community "] -license = "MIT" - -[dependencies] -gosub_shared = { path = "../gosub_shared" } -gosub_html5 = { path = "../gosub_html5" } -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0", features = ["preserve_order"] } -serde_derive = "1.0" -lazy_static = "1.5" -nom = "7.1.3" -nom_locate = "4.2.0" -regex = "1" \ No newline at end of file diff --git a/crates/gosub_testing/src/lib.rs b/crates/gosub_testing/src/lib.rs deleted file mode 100644 index 57485cbae..000000000 --- a/crates/gosub_testing/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Testing functionality -//! -//! This crate supplies testing functionality to test all the gosub crates. -//! - -pub mod testing; diff --git a/docs/crates.md b/docs/crates.md index efd7c7a4a..91cc4e0c9 100644 --- a/docs/crates.md +++ b/docs/crates.md @@ -12,7 +12,6 @@ The engine is split up in a few different crates. This is done to keep the codeb * gosub_shared * gosub_svg * gosub_taffy -* gosub_testing * gosub_typeface * gosub_useragent * gosub_v8 @@ -53,9 +52,6 @@ Implementation of the SVG Document for `usvg` and optionally the `resvg` crates, ## gosub_taffy Implementation of layout traits for the `taffy` layouting system. -## gosub_testing -A dedicated crate for testing some of the engine. This will allow to easily test the different parts of the engine, most notably the html5 tokenizer and parser. - ## gosub_typeface Currently doesn't do much, but it is used to store fallback fonts and the `Font` trait diff --git a/src/bin/html5-parser-test.rs b/src/bin/html5-parser-test.rs index 8599b212a..debadffde 100755 --- a/src/bin/html5-parser-test.rs +++ b/src/bin/html5-parser-test.rs @@ -5,8 +5,8 @@ use gosub_html5::document::fragment::DocumentFragmentImpl; use gosub_html5::parser::Html5Parser; use gosub_shared::traits::config::{HasCssSystem, HasDocument, HasHtmlParser}; use gosub_shared::types::Result; -use gosub_testing::testing::tree_construction::fixture::{fixture_root_path, read_fixture_from_path}; -use gosub_testing::testing::tree_construction::Harness; +use gosub_html5::testing::tree_construction::fixture::{fixture_root_path, read_fixture_from_path}; +use gosub_html5::testing::tree_construction::Harness; use std::io::Write; use std::path::{Path, PathBuf}; use walkdir::WalkDir; diff --git a/src/bin/parser-test.rs b/src/bin/parser-test.rs index 8991f0402..c75a0136b 100755 --- a/src/bin/parser-test.rs +++ b/src/bin/parser-test.rs @@ -4,10 +4,10 @@ use gosub_html5::document::document_impl::DocumentImpl; use gosub_html5::document::fragment::DocumentFragmentImpl; use gosub_html5::parser::Html5Parser; use gosub_shared::traits::config::{HasCssSystem, HasDocument, HasHtmlParser}; -use gosub_testing::testing::tree_construction::fixture::read_fixtures; -use gosub_testing::testing::tree_construction::result::ResultStatus; -use gosub_testing::testing::tree_construction::Harness; -use gosub_testing::testing::tree_construction::Test; +use gosub_html5::testing::tree_construction::fixture::read_fixtures; +use gosub_html5::testing::tree_construction::result::ResultStatus; +use gosub_html5::testing::tree_construction::Harness; +use gosub_html5::testing::tree_construction::Test; /// Holds the results from all tests that are executed #[derive(Default)]