From eaef7d763f4f6bec4180074c64a531242a211aca Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 19 Mar 2023 14:25:08 +0800 Subject: [PATCH 01/14] #psi: #141 sodg 31 --- Cargo.lock | 35 +++++++++----- Cargo.toml | 2 +- Makefile | 3 +- quick-tests/02-self-is-attribute.sodg | 7 +-- quick-tests/03-copy-of-attribute.sodg | 11 +++-- quick-tests/08-copy-of-inc.sodg | 8 ++-- quick-tests/11-times-of-inc.sodg | 68 ++++++++++++++++----------- quick-tests/14-times-of-alpha.sodg | 19 ++++---- quick-tests/15-copy-of-abstract.sodg | 43 ++++++++++------- src/bin/reo.rs | 18 ++++--- src/universe.rs | 37 +++++++-------- test-pom.xml | 2 +- 12 files changed, 144 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15b5916..0000aa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "assert_cmd" @@ -137,7 +137,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -288,7 +288,7 @@ checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -680,7 +680,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", "unicode-ident", ] @@ -715,22 +715,22 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.156" +version = "1.0.157" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.156" +version = "1.0.157" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.0", ] [[package]] @@ -770,9 +770,9 @@ dependencies = [ [[package]] name = "sodg" -version = "0.0.30" +version = "0.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbba9d8070919a5705cb7ac808bbba48d6062c8558787b458e71e7221f1722de" +checksum = "a0376f9c6ff6413f454d7dfc2303423a959b1d234dbeaf3103b385fda8deb915" dependencies = [ "anyhow", "bincode", @@ -828,6 +828,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cff13bb1732bccfe3b246f3fdb09edfd51c01d6f5299b7ccd9457c2e4e37774" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.4.0" diff --git a/Cargo.toml b/Cargo.toml index 732c5b1..4f06181 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ log = "0.4.17" predicates = "3.0.1" regex = "1.7.1" simple_logger = "2.3.0" -sodg = {version = "0.0.30", features = ["sober"]} +sodg = {version = "0.0.31", features = ["sober"]} #sodg = {path = "/code/o/sodg", features = ["sober"]} [dev-dependencies] diff --git a/Makefile b/Makefile index 913196e..4e0b718 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ $(BINARIES): target/eo/1-parse $(SODGS) $(REO) compile $(subst .reo,.sodg,$(subst eo/reo/,eo/sodg/,$@)) $@ clean: - rm -rf target/eo/sodg - rm -rf target/eo/reo + rm -rf target/eo rm -rf target/runtime.reo rm -rf target/debug/reo diff --git a/quick-tests/02-self-is-attribute.sodg b/quick-tests/02-self-is-attribute.sodg index 38e51c2..6bf5407 100644 --- a/quick-tests/02-self-is-attribute.sodg +++ b/quick-tests/02-self-is-attribute.sodg @@ -1,5 +1,5 @@ # v1/bar -> [ x/v2 -> [ Δ -> 42 ] ] -# v4/foo -> v1.x +# v5/foo -> v1.x ADD(0); @@ -12,6 +12,7 @@ BIND($v2, $v3, Δ); PUT($v3, 00-00-00-00-00-00-00-2A); ADD($v4); -BIND(0, $v4, foo); -BIND($v4, $v1, β); BIND($v4, $v1, x); +ADD($v5); +BIND($v5, $v4, β); +BIND(0, $v5, foo); diff --git a/quick-tests/03-copy-of-attribute.sodg b/quick-tests/03-copy-of-attribute.sodg index 93c1add..923a215 100644 --- a/quick-tests/03-copy-of-attribute.sodg +++ b/quick-tests/03-copy-of-attribute.sodg @@ -1,5 +1,5 @@ # v1/bar -> [ a/v3 -> [ Δ -> 42 ] ] -# v4/foo -> v1.a() +# v6/foo -> v1.a() ADD(0); @@ -12,9 +12,10 @@ BIND($v2, $v3, Δ); PUT($v3, 00-00-00-00-00-00-00-2A); ADD($v4); -BIND($v4, $v1, β); BIND($v4, $v1, a); - ADD($v5); -BIND($v5, $v4, π); -BIND(0, $v5, foo); +BIND($v5, $v4, β); + +ADD($v6); +BIND($v6, $v5, π); +BIND(0, $v6, foo); diff --git a/quick-tests/08-copy-of-inc.sodg b/quick-tests/08-copy-of-inc.sodg index 12d5634..a8ad29a 100644 --- a/quick-tests/08-copy-of-inc.sodg +++ b/quick-tests/08-copy-of-inc.sodg @@ -1,6 +1,6 @@ # v1/integer -> [ v2/inc -> [ ρ -> v1, λ ] ] # v4 -> integer(Δ-> 41) -# v6/foo -> v4.inc +# v7/foo -> v4.inc ADD(0); @@ -20,6 +20,8 @@ BIND($v4, $v5, Δ); PUT($v5, 00-00-00-00-00-00-00-29); ADD($v6); -BIND(0, $v6, foo); -BIND($v6, $v4, β); BIND($v6, $v4, inc); +ADD($v7); +BIND($v7, $v6, β); + +BIND(0, $v7, foo); diff --git a/quick-tests/11-times-of-inc.sodg b/quick-tests/11-times-of-inc.sodg index 4bebfd9..3aa42c6 100644 --- a/quick-tests/11-times-of-inc.sodg +++ b/quick-tests/11-times-of-inc.sodg @@ -1,46 +1,58 @@ -# v1/int -> [ inc -> [ ρ -> v1, λ, x -> ? ], times -> [ ρ -> v1, λ, x -> ? ] ] -# v6 -> int(v7/Δ -> 6) -# v8 -> v6.inc -# v9/foo -> v6.times(α0 -> v8) +# v1/int -> [ v2/inc -> [ ρ -> v1, λ, v3/x -> ? ], v5/times -> [ ρ -> v1, λ, v6/x -> ? ] ] +# v8 -> int(v9/Δ -> 6) +# v11 -> v8.inc +# v13/foo -> v8.times(α0 -> v11) ADD(0); +# v1/int -> [] ADD($v1); BIND(0, $v1, int); + +# v2/inc -> [ ρ -> v1, v4/λ, v3/x -> ? ] ADD($v2); BIND($v1, $v2, inc); BIND($v2, $v1, ρ); -ADD($v11); -BIND($v2, $v11, x); -BIND($v11, $v2, ρ); ADD($v3); -BIND($v2, $v3, λ); -PUT($v3, 69-6E-63); +BIND($v2, $v3, x); +BIND($v3, $v2, ρ); ADD($v4); -BIND($v1, $v4, times); -BIND($v4, $v1, ρ); -ADD($v12); -BIND($v4, $v12, x); -BIND($v12, $v4, ρ); -ADD($v5); -BIND($v4, $v5, λ); -PUT($v5, 74-69-6D-65-73); +BIND($v2, $v4, λ); +PUT($v4, 69-6E-63); +# v5/times -> [ ρ -> v1, λ, v6/x -> ? ] ] +ADD($v5); +BIND($v1, $v5, times); +BIND($v5, $v1, ρ); ADD($v6); -BIND($v6, $v1, π); +BIND($v5, $v6, x); +BIND($v6, $v5, ρ); ADD($v7); -BIND($v6, $v7, Δ); -PUT($v7, 00-00-00-00-00-00-00-06); +BIND($v5, $v7, λ); +PUT($v7, 74-69-6D-65-73); +# v8 -> int(v9/Δ -> 6) ADD($v8); -BIND($v8, $v6, β); -BIND($v8, $v6, inc); - +BIND($v8, $v1, π); ADD($v9); -BIND($v9, $v6, β); -BIND($v9, $v6, times); +BIND($v8, $v9, Δ); +PUT($v9, 00-00-00-00-00-00-00-06); + +# v11 -> v8.inc ADD($v10); -BIND($v10, $v9, π); -BIND($v10, $v8, α0); +BIND($v10, $v8, inc); +ADD($v11); +BIND($v11, $v10, β); +BIND($v11, $v8, ρ); + +# v13/foo -> v8.times(α0 -> v9) +ADD($v12); +BIND($v12, $v8, times); +ADD($v13); +BIND($v13, $v12, β); +BIND($v13, $v8, ρ); +ADD($v14); +BIND($v14, $v13, π); +BIND($v14, $v11, α0); -BIND(0, $v10, foo); +BIND(0, $v14, foo); diff --git a/quick-tests/14-times-of-alpha.sodg b/quick-tests/14-times-of-alpha.sodg index 096c004..dc384a0 100644 --- a/quick-tests/14-times-of-alpha.sodg +++ b/quick-tests/14-times-of-alpha.sodg @@ -1,6 +1,6 @@ # v1/int -> [ v2/times -> [ x -> ?, ρ -> v1, λ ], Δ -> 6 ] -# v6 -> v1.times -# v7/foo -> v6(x -> v6) +# v7 -> v1.times +# v8/foo -> v7(x -> v6) ADD(0); @@ -20,16 +20,17 @@ BIND($v1, $v5, Δ); PUT($v5, 00-00-00-00-00-00-00-06); ADD($v6); -BIND($v6, $v1, β); BIND($v6, $v1, times); - ADD($v7); -BIND($v7, $v6, π); +BIND($v7, $v6, β); ADD($v8); -BIND($v7, $v8, α0); +BIND($v8, $v7, π); + ADD($v9); -BIND($v8, $v9, Δ); -PUT($v9, 00-00-00-00-00-00-00-07); +BIND($v8, $v9, α0); +ADD($v10); +BIND($v9, $v10, Δ); +PUT($v10, 00-00-00-00-00-00-00-07); -BIND(0, $v7, foo); +BIND(0, $v8, foo); diff --git a/quick-tests/15-copy-of-abstract.sodg b/quick-tests/15-copy-of-abstract.sodg index 0798566..7b3d565 100644 --- a/quick-tests/15-copy-of-abstract.sodg +++ b/quick-tests/15-copy-of-abstract.sodg @@ -1,32 +1,39 @@ # v1 -> [ v2/x -> $.y, y -> ? ] -# v5 -> [Δ -> 42] -# v7 -> v1(y -> v4) -# v8 -> v7.x +# v7 -> [Δ -> 42] +# v9 -> v1(y -> v7) +# v11 -> v9.x ADD(0); +# v1 -> [ v2/x -> $.y, y -> ? ] ADD($v1); ADD($v2); BIND($v1, $v2, x); ADD($v3); -BIND($v3, $v1, ξ); -BIND($v2, $v3, β); -BIND($v2, $v3, y); - +BIND($v2, $v3, ε); ADD($v4); -BIND($v1, $v4, y); -BIND($v4, $v1, ρ); - +BIND($v3, $v4, β); ADD($v5); +BIND($v4, $v5, y); +BIND($v5, $v1, ξ); ADD($v6); -BIND($v5, $v6, Δ); -PUT($v6, 00-00-00-00-00-00-00-2A); +BIND($v1, $v6, y); +BIND($v6, $v1, ρ); +# v7 -> [Δ -> 42] ADD($v7); -BIND($v7, $v1, π); -BIND($v7, $v5, y); - ADD($v8); -BIND($v8, $v7, β); -BIND($v8, $v7, x); -BIND(0, $v8, foo); +BIND($v7, $v8, Δ); +PUT($v8, 00-00-00-00-00-00-00-2A); + +# v9 -> v1(y -> v7) +ADD($v9); +BIND($v9, $v1, π); +BIND($v9, $v7, y); + +# v11 -> v9.x +ADD($v10); +BIND($v10, $v9, x); +ADD($v11); +BIND($v11, $v10, β); +BIND(0, $v11, foo); diff --git a/src/bin/reo.rs b/src/bin/reo.rs index bdf71c7..7845d8c 100644 --- a/src/bin/reo.rs +++ b/src/bin/reo.rs @@ -304,7 +304,7 @@ pub fn main() -> Result<()> { let mut g = Sodg::empty(); g.add(0)?; let size = g.save(bin)?; - info!("The SODG saved to '{}' ({size} bytes)", bin.display()); + info!("Empty SODG saved to '{}' ({size} bytes)", bin.display()); } Some(("merge", subs)) => { let target = subs @@ -329,7 +329,9 @@ pub fn main() -> Result<()> { info!("Merging from '{}':", source.display()); let mut g2 = Sodg::load(source)?; print_metas(&mut g2)?; - g1.merge(&g2.slice_some("ν0", |_, _, a| !a.starts_with('+'))?, 0, 0)?; + let slice = g2.slice_some("ν0", |_, _, a| !a.starts_with('+'))?; + debug!("merging {} vertices...", slice.len()); + g1.merge(&slice, 0, 0)?; let size = g1.save(target)?; info!("The SODG saved to '{}' ({size} bytes)", target.display()); } @@ -424,10 +426,12 @@ pub fn main() -> Result<()> { .unwrap_or(ValuesRef::default()) .copied() .collect(); - println!( - "Ignoring: {}", - ignore.iter().map(|v| format!("ν{}", v)).join(", ") - ); + if !ignore.is_empty() { + println!( + "Ignoring: {}", + ignore.iter().map(|v| format!("ν{}", v)).join(", ") + ); + } for v in ignore { seen.insert(v); } @@ -473,7 +477,7 @@ fn print_metas(g: &mut Sodg) -> Result<()> { Ok(vec) => { for (a, v) in vec { if a.starts_with('+') { - info!(" {a}: {}", g.data(v)?.to_utf8()?) + println!(" {a}: {}", g.data(v)?.to_utf8()?) } } } diff --git a/src/universe.rs b/src/universe.rs index d4d9d4b..112ae78 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -86,7 +86,7 @@ impl Universe { /// will panic. pub fn put(&mut self, v: u32, d: Hex) { self.g - .put(v, d) + .put(v, &d) .context(anyhow!("Failed to put the data to ν{v}")) .unwrap(); } @@ -111,7 +111,7 @@ impl Universe { let data = self .g .data(v) - .context(format!("There is no data in {}", self.g.v_print(v)))?; + .context(format!("There is no data in {}", self.g.v_print(v)?))?; trace!( "#dataize: data found in ν{v} ({} bytes): {}", data.len(), @@ -208,7 +208,7 @@ impl Universe { } else { Err(anyhow!( "There is no way to get .{a} from {}", - self.g.v_print(v) + self.g.v_print(v)? )) }; self.depth -= 1; @@ -219,27 +219,24 @@ impl Universe { fn dd(&mut self, v: u32, psi: u32) -> Result { self.check_recursion()?; trace!("#dd(ν{v}, {psi}): entering..."); + let psi2 = match self.g.kid(v, "ψ") { + Some(p) => p, + None => psi, + }; let r = if let Some(to) = self.g.kid(v, "ε") { - self.dd(to, psi) + self.dd(to, psi2) } else if self.g.kid(v, "ξ").is_some() { - self.dd(psi, psi) - } else if let Some(to) = self.g.kid(v, "β") { - let a = self + self.dd(psi2, psi2) + } else if let Some(beta) = self.g.kid(v, "β") { + let (a, to) = self .g - .kids(v)? - .iter() - .find(|e| e.0 != "β") - .unwrap() - .clone() - .0; - let nv = self.fnd(to, a.as_str(), psi)?; - self.dd(nv, psi) + .kids(beta)? + .first() + .ok_or(anyhow!("Can't find ν{beta}"))? + .clone(); + let nv = self.fnd(to, a.as_str(), psi2)?; + self.dd(nv, psi2) } else if let Some(to) = self.g.kid(v, "π") { - let psi2 = if let Some(p) = self.g.kid(v, "ψ") { - p - } else { - psi - }; let nv = self.dd(to, psi2)?; self.apply(nv, v) } else { diff --git a/test-pom.xml b/test-pom.xml index b8bcf3f..da83ab9 100644 --- a/test-pom.xml +++ b/test-pom.xml @@ -32,7 +32,7 @@ SOFTWARE. org.eolang eo-maven-plugin - 0.29.2 + 1.0-SNAPSHOT compile From abc00887d7e789de7e44450147c761f91a777f92 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 19 Mar 2023 17:54:33 +0800 Subject: [PATCH 02/14] surge simple --- ...6-copy-inside.sodg => 16-copy-inside.sodg} | 49 +++++---- src/universe.rs | 102 ++++++++++++------ surge-make/Makefile | 18 ++++ surge-make/doc.tex | 11 ++ 4 files changed, 130 insertions(+), 50 deletions(-) rename quick-tests/{_16-copy-inside.sodg => 16-copy-inside.sodg} (51%) create mode 100644 surge-make/Makefile create mode 100644 surge-make/doc.tex diff --git a/quick-tests/_16-copy-inside.sodg b/quick-tests/16-copy-inside.sodg similarity index 51% rename from quick-tests/_16-copy-inside.sodg rename to quick-tests/16-copy-inside.sodg index 05b8a19..7ad74d6 100644 --- a/quick-tests/_16-copy-inside.sodg +++ b/quick-tests/16-copy-inside.sodg @@ -1,8 +1,8 @@ # v1 -> [ # v2/times -> [x -> ?, ρ -> v1, λ], -# Δ -> 6, -# p -> [Δ -> 7], -# t -> $.times(α0 -> $.p) +# v5/Δ -> 6, +# v6/f -> [Δ -> 7], +# v8/t -> $.times(v12/α0 -> $.p) # ] # foo -> v1().t @@ -25,34 +25,43 @@ ADD($v5); BIND($v1, $v5, Δ); PUT($v5, 00-00-00-00-00-00-00-06); -# p -> [Δ -> 7], +# f -> [Δ -> 7], ADD($v6); -BIND($v1, $v6, p); +BIND($v1, $v6, f); BIND($v6, $v1, ρ); ADD($v7); BIND($v6, $v7, Δ); PUT($v7, 00-00-00-00-00-00-00-07); -# t -> $.times(α0 -> $.p) +# v8/t -> $.times(v12/α0 -> $.f) ADD($v8); -BIND($v8, $v1, ξ); +BIND($v1, $v8, t); ADD($v9); -BIND($v9, $v8, β); -BIND($v9, $v8, times); +BIND($v8, $v9, π); ADD($v10); -BIND($v10, $v9, π); -BIND($v1, $v10, t); +BIND($v9, $v10, β); ADD($v11); +BIND($v9, $v11, ρ); +BIND($v10, $v11, times); BIND($v11, $v1, ξ); -ADD($v12); -BIND($v12, $v11, β); -BIND($v12, $v11, p); -BIND($v10, $v12, α0); -# foo -> v1().t +ADD($v12); +BIND($v8, $v12, α0); ADD($v13); -BIND($v13, $v1, π); +BIND($v12, $v13, ε); ADD($v14); -BIND($v14, $v13, β); -BIND($v14, $v13, t); -BIND(0, $v14, foo); +BIND($v13, $v14, β); +ADD($v15); +BIND($v13, $v15, ρ); +BIND($v14, $v15, f); +BIND($v15, $v1, ξ); + +# foo -> v1().t +ADD($v16); +BIND($v16, $v1, π); +ADD($v17); +BIND($v17, $v16, t); +ADD($v18); +BIND($v18, $v16, ρ); +BIND($v18, $v17, β); +BIND(0, $v18, foo); diff --git a/src/universe.rs b/src/universe.rs index 112ae78..a6b1767 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -26,6 +26,26 @@ use sodg::{Hex, Relay}; use std::collections::HashMap; use std::path::Path; use std::str::FromStr; +use std::io::prelude::*; + +macro_rules! enter { + ($self:expr, $($arg:tt)+) => { + trace!($($arg)+); + $self.enter_it()?; + } +} + +macro_rules! exit { + ($self:expr, $($arg:tt)+) => { + trace!($($arg)+); + $self.exit_it()?; + } +} + +// self.depth += 1; +// if self.depth > 20 { +// return Err(anyhow!("The recursion is too deep ({} levels)", self.depth)); +// } impl Universe { /// Makes an empty Universe. @@ -171,21 +191,18 @@ impl Universe { /// Find. fn fnd(&mut self, v: u32, a: &str, psi: u32) -> Result { - self.check_recursion()?; + enter!(self, "#fnd(ν{v}, {a}, {psi}): entered..."); let v1 = self.dd(v, psi)?; - trace!("#fnd(ν{v}, {a}, {psi}): dd(ν{v}) returned ν{v1}"); let to = self.pf(v1, a, psi)?; - trace!("#fnd(ν{v}, {a}, {psi}): pf(ν{v}, {a}) returned ν{to}"); - self.depth -= 1; + exit!(self, "#fnd(ν{v}, {a}, {psi}): pf(ν{v}, {a}) returned ν{to}"); Ok(to) } /// Path find. fn pf(&mut self, v: u32, a: &str, psi: u32) -> Result { - self.check_recursion()?; - trace!("#pf(ν{v}, {a}, {psi}): entering..."); + enter!(self, "#pf(ν{v}, {a}, {psi}): entering..."); let r = if let Some(to) = self.g.kid(v, a) { - Ok(to) + to } else if let Some(lv) = self.g.kid(v, "λ") { let lambda = self.g.data(lv)?.to_utf8()?; trace!("#re: calling ν{v}.λ⇓{lambda}(ξ=ν?)..."); @@ -198,35 +215,34 @@ impl Universe { )) .unwrap()(self, v)?; trace!("#re: ν{v}.λ⇓{lambda}(ξ=ν?) returned ν{to}"); - self.fnd(to, a, psi) + self.fnd(to, a, psi)? } else if let Some(to) = self.g.kid(v, "φ") { - self.fnd(to, a, psi) + self.fnd(to, a, psi)? } else if let Some(to) = self.g.kid(v, "γ") { let t = Self::fnd(self, to, a, psi)?; self.g.bind(v, t, a)?; - Ok(t) + t } else { - Err(anyhow!( + return Err(anyhow!( "There is no way to get .{a} from {}", self.g.v_print(v)? - )) + )); }; - self.depth -= 1; - r + exit!(self, "#pf(ν{v}, {a}, {psi}): returning ν{}", r); + Ok(r) } /// Dynamic dispatch. fn dd(&mut self, v: u32, psi: u32) -> Result { - self.check_recursion()?; - trace!("#dd(ν{v}, {psi}): entering..."); + enter!(self, "#dd(ν{v}, {psi}): entering..."); let psi2 = match self.g.kid(v, "ψ") { Some(p) => p, None => psi, }; let r = if let Some(to) = self.g.kid(v, "ε") { - self.dd(to, psi2) + self.dd(to, psi2)? } else if self.g.kid(v, "ξ").is_some() { - self.dd(psi2, psi2) + self.dd(psi2, psi2)? } else if let Some(beta) = self.g.kid(v, "β") { let (a, to) = self .g @@ -235,27 +251,26 @@ impl Universe { .ok_or(anyhow!("Can't find ν{beta}"))? .clone(); let nv = self.fnd(to, a.as_str(), psi2)?; - self.dd(nv, psi2) + self.dd(nv, psi2)? } else if let Some(to) = self.g.kid(v, "π") { let nv = self.dd(to, psi2)?; - self.apply(nv, v) + self.apply(nv, v)? } else { - Ok(v) + v }; - self.depth -= 1; - r + exit!(self, "#dd(ν{v}, {psi}): returning ν{}", r); + Ok(r) } /// Apply `v1` to `v2` and return a new vertex. fn apply(&mut self, v1: u32, v2: u32) -> Result { - trace!("#apply(ν{v1}, ν{v2}): entering..."); + enter!(self, "#apply(ν{v1}, ν{v2}): entering..."); self.depth += 1; let nv = self.g.next_id(); self.g.add(nv)?; self.pull(nv, v1)?; self.push(nv, v2)?; - trace!("#apply(ν{v1}, ν{v2}): copy ν{v1}+ν{v2} created as ν{nv}"); - self.depth -= 1; + exit!(self, "#apply(ν{v1}, ν{v2}): copy ν{v1}+ν{v2} created as ν{nv}"); Ok(nv) } @@ -341,11 +356,30 @@ impl Universe { return Ok(kids.len() == 1 && kids.iter().all(|(a, _)| a == "ρ")); } - fn check_recursion(&mut self) -> Result<()> { + fn enter_it(&mut self) -> Result<()> { self.depth += 1; - if self.depth > 20 { - return Err(anyhow!("The recursion is too deep ({} levels)", self.depth)); + let home = self.g.data(256)?.to_utf8()?; + fs::create_dir_all(home.clone())?; + let total = fs::read_dir(home.as_str()).unwrap().filter(|f| f.as_ref().unwrap().path().as_os_str().to_str().unwrap().ends_with(".dot")).count(); + if total == 0 { + fs::copy("surge-make/Makefile", format!("{home}/Makefile"))?; + fs::copy("surge-make/doc.tex", format!("{home}/doc.tex"))?; + fs::write(format!("{home}/list.tex"), b"")?; } + let pos = total + 1; + let mut file = fs::File::create(format!("{home}/{pos}.dot"))?; + file.write_all(self.g.to_dot().as_bytes())?; + let mut list = OpenOptions::new() + .write(true) + .append(true) + .open(format!("{home}/list.tex")) + .unwrap(); + writeln!(list, "\\graph{{{pos}}}")?; + Ok(()) + } + + fn exit_it(&mut self) -> Result<()> { + self.depth -= 1; Ok(()) } } @@ -355,6 +389,7 @@ use sodg::Script; #[cfg(test)] use std::fs; +use std::fs::OpenOptions; #[cfg(test)] use glob::glob; @@ -446,11 +481,18 @@ fn fnd_absent_vertex() -> Result<()> { #[test] fn quick_tests() -> Result<()> { for path in sodg_scripts_in_dir("quick-tests") { - trace!("#quick_tests: {path}"); + let name = *path.split('/').collect::>().get(1).unwrap(); + trace!("#quick_tests: {name}"); let mut s = Script::from_str(fs::read_to_string(path.clone())?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; trace!("Before:\n {}", g.clone().to_dot()); + let home = format!("target/surge/{}", name); + g.add(256)?; + g.put(256, &Hex::from_str_bytes(home.as_str()))?; + if Path::new(home.as_str()).exists() { + fs::remove_dir_all(home).unwrap(); + } let mut uni = Universe::from_graph(g); uni.register("inc", inc); uni.register("times", times); diff --git a/surge-make/Makefile b/surge-make/Makefile new file mode 100644 index 0000000..347ee6f --- /dev/null +++ b/surge-make/Makefile @@ -0,0 +1,18 @@ +DOTS := $(wildcard *.dot) +BINS := $(patsubst %.dot,%.pdf,$(DOTS)) +PDF = doc.pdf + +.ONESHELL: +.SHELLFLAGS: -e -o pipefail -c +.PHONY: clean +SHELL = bash + +$(PDF): $(BINS) + pdflatex doc.tex + +%.pdf: %.dot + dot -Tpdf -o $@ $< + +clean: + rm -rf $(BINS) + rm -rf $(PDF) \ No newline at end of file diff --git a/surge-make/doc.tex b/surge-make/doc.tex new file mode 100644 index 0000000..483bf62 --- /dev/null +++ b/surge-make/doc.tex @@ -0,0 +1,11 @@ +\documentclass[landscape,oneside]{article} +\usepackage[paperwidth=9in, paperheight=9in, left=1in, right=1in, top=1in, bottom=1in]{geometry} +\usepackage{svg} +\usepackage{graphicx} +\newcommand\graph[1]{ + \clearpage + \includegraphics[height=7in]{#1.pdf} +} +\begin{document} +\input{list.tex} +\end{document} \ No newline at end of file From d711db13a22d641efc7d1cc33b82310182553fc3 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 19 Mar 2023 18:55:43 +0800 Subject: [PATCH 03/14] graphs --- src/universe.rs | 61 +++++++++++++++++++++++++++++++--------------- surge-make/doc.tex | 16 +++++++++--- 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index a6b1767..77454f9 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -18,6 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +use std::cmp; use crate::{Atom, Universe}; use anyhow::{anyhow, Context, Result}; use log::trace; @@ -30,15 +31,13 @@ use std::io::prelude::*; macro_rules! enter { ($self:expr, $($arg:tt)+) => { - trace!($($arg)+); - $self.enter_it()?; + $self.enter_it(format!($($arg)+))?; } } macro_rules! exit { ($self:expr, $($arg:tt)+) => { - trace!($($arg)+); - $self.exit_it()?; + $self.exit_it(format!($($arg)+))?; } } @@ -356,11 +355,23 @@ impl Universe { return Ok(kids.len() == 1 && kids.iter().all(|(a, _)| a == "ρ")); } - fn enter_it(&mut self) -> Result<()> { + fn enter_it(&mut self, msg: String) -> Result<()> { self.depth += 1; - let home = self.g.data(256)?.to_utf8()?; + self.snapshot(msg)?; + Ok(()) + } + + fn exit_it(&mut self, msg: String) -> Result<()> { + self.depth -= 1; + self.snapshot(msg)?; + Ok(()) + } + + fn snapshot(&mut self, msg: String) -> Result<()> { + let name = fs::read_to_string("target/surge-recent.txt")?; + let home = format!("target/surge/{name}"); fs::create_dir_all(home.clone())?; - let total = fs::read_dir(home.as_str()).unwrap().filter(|f| f.as_ref().unwrap().path().as_os_str().to_str().unwrap().ends_with(".dot")).count(); + let total = fs::read_dir(home.as_str())?.filter(|f| f.as_ref().unwrap().path().as_os_str().to_str().unwrap().ends_with(".dot")).count(); if total == 0 { fs::copy("surge-make/Makefile", format!("{home}/Makefile"))?; fs::copy("surge-make/doc.tex", format!("{home}/doc.tex"))?; @@ -372,14 +383,27 @@ impl Universe { let mut list = OpenOptions::new() .write(true) .append(true) - .open(format!("{home}/list.tex")) - .unwrap(); - writeln!(list, "\\graph{{{pos}}}")?; - Ok(()) - } - - fn exit_it(&mut self) -> Result<()> { - self.depth -= 1; + .open(format!("{home}/list.tex"))?; + if pos == 1 || fs::read_to_string(format!("{home}/{pos}.dot"))? != fs::read_to_string(format!("{home}/{}.dot", pos - 1))? { + writeln!(list, "\\graph{{{pos}}}")?; + } + let mut log = OpenOptions::new() + .write(true) + .append(true) + .create(true) + .open(format!("{home}/log.txt"))?; + writeln!( + log, "{}{}", + " ".repeat(self.depth), + msg.replace("ν", "v").replace("Δ", "D") + )?; + let full = fs::read_to_string(format!("{home}/log.txt"))?; + let lines = full.split("\n").collect::>(); + let max = 32; + fs::write( + format!("{home}/log-{pos}.txt"), + lines.clone().into_iter().skip(cmp::max(0 as i16, lines.len() as i16 - max) as usize).collect::>().join("\n"), + )?; Ok(()) } } @@ -481,17 +505,16 @@ fn fnd_absent_vertex() -> Result<()> { #[test] fn quick_tests() -> Result<()> { for path in sodg_scripts_in_dir("quick-tests") { - let name = *path.split('/').collect::>().get(1).unwrap(); + let name = *path.split('/').collect::>().get(1).ok_or(anyhow!("Can't understand path"))?; trace!("#quick_tests: {name}"); + fs::write("target/surge-recent.txt", name.as_bytes())?; let mut s = Script::from_str(fs::read_to_string(path.clone())?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; trace!("Before:\n {}", g.clone().to_dot()); let home = format!("target/surge/{}", name); - g.add(256)?; - g.put(256, &Hex::from_str_bytes(home.as_str()))?; if Path::new(home.as_str()).exists() { - fs::remove_dir_all(home).unwrap(); + fs::remove_dir_all(home)?; } let mut uni = Universe::from_graph(g); uni.register("inc", inc); diff --git a/surge-make/doc.tex b/surge-make/doc.tex index 483bf62..2a01267 100644 --- a/surge-make/doc.tex +++ b/surge-make/doc.tex @@ -1,10 +1,18 @@ \documentclass[landscape,oneside]{article} -\usepackage[paperwidth=9in, paperheight=9in, left=1in, right=1in, top=1in, bottom=1in]{geometry} +\usepackage[utf8]{inputenc} +\usepackage[paperwidth=18in, paperheight=9in, left=1in, right=1in, top=1in, bottom=1in]{geometry} +\RequirePackage{microtype} \usepackage{svg} +\usepackage{multicol} \usepackage{graphicx} -\newcommand\graph[1]{ - \clearpage - \includegraphics[height=7in]{#1.pdf} +\usepackage{listings} +\newcommand\graph[1]{% + \clearpage% + \begin{multicols}{2} + \includegraphics[height=7in]{#1.pdf}% + \par\columnbreak\par + \lstinputlisting{log-#1.txt} + \end{multicols} } \begin{document} \input{list.tex} From daef343a7d4453a64e5ef1cd5a1b77520bd966a8 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 19 Mar 2023 18:56:02 +0800 Subject: [PATCH 04/14] fmt --- src/universe.rs | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index 77454f9..fd761bc 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -18,16 +18,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -use std::cmp; use crate::{Atom, Universe}; use anyhow::{anyhow, Context, Result}; use log::trace; use sodg::Sodg; use sodg::{Hex, Relay}; +use std::cmp; use std::collections::HashMap; +use std::io::prelude::*; use std::path::Path; use std::str::FromStr; -use std::io::prelude::*; macro_rules! enter { ($self:expr, $($arg:tt)+) => { @@ -269,7 +269,10 @@ impl Universe { self.g.add(nv)?; self.pull(nv, v1)?; self.push(nv, v2)?; - exit!(self, "#apply(ν{v1}, ν{v2}): copy ν{v1}+ν{v2} created as ν{nv}"); + exit!( + self, + "#apply(ν{v1}, ν{v2}): copy ν{v1}+ν{v2} created as ν{nv}" + ); Ok(nv) } @@ -371,7 +374,17 @@ impl Universe { let name = fs::read_to_string("target/surge-recent.txt")?; let home = format!("target/surge/{name}"); fs::create_dir_all(home.clone())?; - let total = fs::read_dir(home.as_str())?.filter(|f| f.as_ref().unwrap().path().as_os_str().to_str().unwrap().ends_with(".dot")).count(); + let total = fs::read_dir(home.as_str())? + .filter(|f| { + f.as_ref() + .unwrap() + .path() + .as_os_str() + .to_str() + .unwrap() + .ends_with(".dot") + }) + .count(); if total == 0 { fs::copy("surge-make/Makefile", format!("{home}/Makefile"))?; fs::copy("surge-make/doc.tex", format!("{home}/doc.tex"))?; @@ -384,7 +397,10 @@ impl Universe { .write(true) .append(true) .open(format!("{home}/list.tex"))?; - if pos == 1 || fs::read_to_string(format!("{home}/{pos}.dot"))? != fs::read_to_string(format!("{home}/{}.dot", pos - 1))? { + if pos == 1 + || fs::read_to_string(format!("{home}/{pos}.dot"))? + != fs::read_to_string(format!("{home}/{}.dot", pos - 1))? + { writeln!(list, "\\graph{{{pos}}}")?; } let mut log = OpenOptions::new() @@ -393,16 +409,22 @@ impl Universe { .create(true) .open(format!("{home}/log.txt"))?; writeln!( - log, "{}{}", + log, + "{}{}", " ".repeat(self.depth), msg.replace("ν", "v").replace("Δ", "D") )?; let full = fs::read_to_string(format!("{home}/log.txt"))?; let lines = full.split("\n").collect::>(); - let max = 32; + let max = 32; fs::write( format!("{home}/log-{pos}.txt"), - lines.clone().into_iter().skip(cmp::max(0 as i16, lines.len() as i16 - max) as usize).collect::>().join("\n"), + lines + .clone() + .into_iter() + .skip(cmp::max(0 as i16, lines.len() as i16 - max) as usize) + .collect::>() + .join("\n"), )?; Ok(()) } @@ -505,7 +527,11 @@ fn fnd_absent_vertex() -> Result<()> { #[test] fn quick_tests() -> Result<()> { for path in sodg_scripts_in_dir("quick-tests") { - let name = *path.split('/').collect::>().get(1).ok_or(anyhow!("Can't understand path"))?; + let name = *path + .split('/') + .collect::>() + .get(1) + .ok_or(anyhow!("Can't understand path"))?; trace!("#quick_tests: {name}"); fs::write("target/surge-recent.txt", name.as_bytes())?; let mut s = Script::from_str(fs::read_to_string(path.clone())?.as_str()); From be57a8e617a693b2eddd503b2a63db3943e3d50f Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 19 Mar 2023 19:04:47 +0800 Subject: [PATCH 05/14] otpimized --- src/universe.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index fd761bc..183ccd9 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -391,16 +391,22 @@ impl Universe { fs::write(format!("{home}/list.tex"), b"")?; } let pos = total + 1; - let mut file = fs::File::create(format!("{home}/{pos}.dot"))?; - file.write_all(self.g.to_dot().as_bytes())?; + let dot = self.g.to_dot(); + let dot_file = format!("{home}/{pos}.dot"); + fs::write(&dot_file, &dot)?; let mut list = OpenOptions::new() .write(true) .append(true) .open(format!("{home}/list.tex"))?; - if pos == 1 - || fs::read_to_string(format!("{home}/{pos}.dot"))? - != fs::read_to_string(format!("{home}/{}.dot", pos - 1))? - { + let mut before = String::new(); + if pos > 1 { + before = fs::read_to_string(format!("{home}/{}.dot", pos - 1))?; + } + if dot == before { + if pos > 0 { + fs::remove_file(dot_file.as_str())?; + } + } else { writeln!(list, "\\graph{{{pos}}}")?; } let mut log = OpenOptions::new() @@ -534,10 +540,10 @@ fn quick_tests() -> Result<()> { .ok_or(anyhow!("Can't understand path"))?; trace!("#quick_tests: {name}"); fs::write("target/surge-recent.txt", name.as_bytes())?; - let mut s = Script::from_str(fs::read_to_string(path.clone())?.as_str()); + let mut s = Script::from_str(fs::read_to_string(&path)?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; - trace!("Before:\n {}", g.clone().to_dot()); + trace!("Before:\n {}", &g.to_dot()); let home = format!("target/surge/{}", name); if Path::new(home.as_str()).exists() { fs::remove_dir_all(home)?; @@ -557,7 +563,7 @@ fn quick_tests() -> Result<()> { fn quick_errors() -> Result<()> { for path in sodg_scripts_in_dir("quick-errors") { trace!("#quick_errors: {path}"); - let mut s = Script::from_str(fs::read_to_string(path.clone())?.as_str()); + let mut s = Script::from_str(fs::read_to_string(&path)?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; let mut uni = Universe::from_graph(g); From bce932cc2c9a2bdb5a37850cf69249a362118fa9 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 19 Mar 2023 19:20:00 +0800 Subject: [PATCH 06/14] pdf on failure --- src/universe.rs | 17 +++++++++++++++-- surge-make/doc.tex | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index 183ccd9..402d114 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -365,7 +365,9 @@ impl Universe { } fn exit_it(&mut self, msg: String) -> Result<()> { - self.depth -= 1; + if self.depth > 0 { + self.depth -= 1; + } self.snapshot(msg)?; Ok(()) } @@ -442,6 +444,7 @@ use sodg::Script; #[cfg(test)] use std::fs; use std::fs::OpenOptions; +use std::process::Command; #[cfg(test)] use glob::glob; @@ -546,12 +549,22 @@ fn quick_tests() -> Result<()> { trace!("Before:\n {}", &g.to_dot()); let home = format!("target/surge/{}", name); if Path::new(home.as_str()).exists() { - fs::remove_dir_all(home)?; + fs::remove_dir_all(&home)?; } let mut uni = Universe::from_graph(g); uni.register("inc", inc); uni.register("times", times); let r = uni.dataize("Φ.foo"); + uni.exit_it("The end".to_string())?; + if r.is_err() { + assert!(Command::new("make") + .current_dir(home) + .spawn() + .unwrap() + .wait() + .unwrap() + .success()); + } trace!("After:\n {}", uni.g.to_dot()); let hex = r.context(anyhow!("Failure in {path}"))?; assert_eq!(42, hex.to_i64()?, "Failure in {path}"); diff --git a/surge-make/doc.tex b/surge-make/doc.tex index 2a01267..ea973da 100644 --- a/surge-make/doc.tex +++ b/surge-make/doc.tex @@ -1,6 +1,6 @@ \documentclass[landscape,oneside]{article} \usepackage[utf8]{inputenc} -\usepackage[paperwidth=18in, paperheight=9in, left=1in, right=1in, top=1in, bottom=1in]{geometry} +\usepackage[paperwidth=18in, paperheight=9in, left=.2in, right=.2in, top=.2in, bottom=.2in]{geometry} \RequirePackage{microtype} \usepackage{svg} \usepackage{multicol} @@ -9,7 +9,7 @@ \newcommand\graph[1]{% \clearpage% \begin{multicols}{2} - \includegraphics[height=7in]{#1.pdf}% + \includegraphics[height=8.6in]{#1.pdf}% \par\columnbreak\par \lstinputlisting{log-#1.txt} \end{multicols} From 60ab16a86b13d6d2d3836d515e96231a688b084d Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Tue, 21 Mar 2023 10:10:26 +0800 Subject: [PATCH 07/14] #psi: graphs with colors --- Cargo.lock | 8 +++---- Cargo.toml | 2 +- src/universe.rs | 53 +++++++++++++++++++++++++++++++++++++--------- surge-make/doc.tex | 1 + 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0000aa2..74e8f00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -770,9 +770,9 @@ dependencies = [ [[package]] name = "sodg" -version = "0.0.31" +version = "0.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0376f9c6ff6413f454d7dfc2303423a959b1d234dbeaf3103b385fda8deb915" +checksum = "a93247d55e07882155c63f5267d8f75ce1c52fd11a0f4db91ca88bd91803dfcc" dependencies = [ "anyhow", "bincode", @@ -1043,6 +1043,6 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "xml-builder" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb75a3f8ef413a4fb3eb7203031bc6707c220f110e18983134866fd44ce02b3" +checksum = "efc4f1a86af7800dfc4056c7833648ea4515ae21502060b5c98114d828f5333b" diff --git a/Cargo.toml b/Cargo.toml index 4f06181..2805600 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ log = "0.4.17" predicates = "3.0.1" regex = "1.7.1" simple_logger = "2.3.0" -sodg = {version = "0.0.31", features = ["sober"]} +sodg = {version = "0.0.32", features = ["sober"]} #sodg = {path = "/code/o/sodg", features = ["sober"]} [dev-dependencies] diff --git a/src/universe.rs b/src/universe.rs index 402d114..49b6c16 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -20,11 +20,15 @@ use crate::{Atom, Universe}; use anyhow::{anyhow, Context, Result}; +use lazy_static::lazy_static; use log::trace; +use regex::Regex; use sodg::Sodg; use sodg::{Hex, Relay}; use std::cmp; use std::collections::HashMap; +use std::fs; +use std::fs::OpenOptions; use std::io::prelude::*; use std::path::Path; use std::str::FromStr; @@ -372,7 +376,12 @@ impl Universe { Ok(()) } + const COLORS: &'static str = "fillcolor=aquamarine3,style=filled,"; + fn snapshot(&mut self, msg: String) -> Result<()> { + lazy_static! { + static ref DOT_LINE: Regex = Regex::new("^ +v([0-9]+)\\[.*$").unwrap(); + } let name = fs::read_to_string("target/surge-recent.txt")?; let home = format!("target/surge/{name}"); fs::create_dir_all(home.clone())?; @@ -393,22 +402,48 @@ impl Universe { fs::write(format!("{home}/list.tex"), b"")?; } let pos = total + 1; - let dot = self.g.to_dot(); - let dot_file = format!("{home}/{pos}.dot"); - fs::write(&dot_file, &dot)?; - let mut list = OpenOptions::new() - .write(true) - .append(true) - .open(format!("{home}/list.tex"))?; let mut before = String::new(); if pos > 1 { - before = fs::read_to_string(format!("{home}/{}.dot", pos - 1))?; + before = + fs::read_to_string(format!("{home}/{}.dot", pos - 1))?.replace(Self::COLORS, ""); } + let seen: Vec = before + .split("\n") + .into_iter() + .map(|t| match &DOT_LINE.captures(t) { + Some(m) => m.get(1).unwrap().as_str().parse().unwrap(), + None => 0, + }) + .collect(); + let dot = self.g.to_dot(); + let dot_file = format!("{home}/{pos}.dot"); + fs::write( + &dot_file, + &dot.split("\n") + .into_iter() + .map(|t| match &DOT_LINE.captures(t) { + Some(m) => { + let v = m.get(1).unwrap().as_str().parse::().unwrap(); + if seen.contains(&v) { + t.to_string() + } else { + t.replace("[", format!("[{}", Self::COLORS).as_str()) + } + } + None => t.to_string(), + }) + .collect::>() + .join("\n"), + )?; if dot == before { if pos > 0 { fs::remove_file(dot_file.as_str())?; } } else { + let mut list = OpenOptions::new() + .write(true) + .append(true) + .open(format!("{home}/list.tex"))?; writeln!(list, "\\graph{{{pos}}}")?; } let mut log = OpenOptions::new() @@ -442,8 +477,6 @@ impl Universe { use sodg::Script; #[cfg(test)] -use std::fs; -use std::fs::OpenOptions; use std::process::Command; #[cfg(test)] diff --git a/surge-make/doc.tex b/surge-make/doc.tex index ea973da..c6637c1 100644 --- a/surge-make/doc.tex +++ b/surge-make/doc.tex @@ -6,6 +6,7 @@ \usepackage{multicol} \usepackage{graphicx} \usepackage{listings} +\lstset{basicstyle=\ttfamily} \newcommand\graph[1]{% \clearpage% \begin{multicols}{2} From dfe0251453cd89a1be5d14ae96c0be3f9b45da93 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 21 Dec 2023 13:40:34 +0300 Subject: [PATCH 08/14] #psi: more --- .rultor.yml | 2 +- src/lib.rs | 3 +++ src/universe.rs | 42 ++++++++++++++++++++++++++++-------------- surge-make/Makefile | 2 +- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.rultor.yml b/.rultor.yml index 2fbc8c5..f1d53a2 100644 --- a/.rultor.yml +++ b/.rultor.yml @@ -1,5 +1,5 @@ docker: - image: yegor256/rultor-image:1.17.2 + image: yegor256/rultor-image:1.18.0 assets: credentials: yegor256/objectionary-secrets#crates-credentials install: | diff --git a/src/lib.rs b/src/lib.rs index 8389937..9a29cd2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,8 +55,11 @@ pub type Atom = fn(&mut Universe, v: u32) -> Result; /// A Universe. pub struct Universe { + /// The graph. g: Sodg, + /// All known atoms. atoms: HashMap, + /// The depth of recursion of the current dataization. depth: usize, } diff --git a/src/universe.rs b/src/universe.rs index 49b6c16..956d208 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -378,14 +378,22 @@ impl Universe { const COLORS: &'static str = "fillcolor=aquamarine3,style=filled,"; + const FLAG: &'static str = "target/surge-recent.txt"; + fn snapshot(&mut self, msg: String) -> Result<()> { lazy_static! { static ref DOT_LINE: Regex = Regex::new("^ +v([0-9]+)\\[.*$").unwrap(); } - let name = fs::read_to_string("target/surge-recent.txt")?; + if !Path::new(Self::FLAG).exists() { + return Ok(()); + } + let name = fs::read_to_string(Self::FLAG) + .context(anyhow!("Can't read the flag file"))?; let home = format!("target/surge/{name}"); - fs::create_dir_all(home.clone())?; - let total = fs::read_dir(home.as_str())? + fs::create_dir_all(home.clone()) + .context(anyhow!("Can't create directory '{home}'"))?; + let total = fs::read_dir(home.as_str()) + .context(anyhow!("Can't list files in {home}"))? .filter(|f| { f.as_ref() .unwrap() @@ -397,15 +405,20 @@ impl Universe { }) .count(); if total == 0 { - fs::copy("surge-make/Makefile", format!("{home}/Makefile"))?; - fs::copy("surge-make/doc.tex", format!("{home}/doc.tex"))?; - fs::write(format!("{home}/list.tex"), b"")?; + fs::copy("surge-make/Makefile", format!("{home}/Makefile")) + .context(anyhow!("Can't copy Makefile to '{home}'"))?; + fs::copy("surge-make/doc.tex", format!("{home}/doc.tex")) + .context(anyhow!("Can't copy doc.tex to '{home}'"))?; + fs::write(format!("{home}/list.tex"), b"") + .context(anyhow!("Can't write empty list.tex"))?; } let pos = total + 1; let mut before = String::new(); if pos > 1 { before = - fs::read_to_string(format!("{home}/{}.dot", pos - 1))?.replace(Self::COLORS, ""); + fs::read_to_string(format!("{home}/{}.dot", pos - 1)) + .context(anyhow!("Can't read previous .dot file from '{home}'"))? + .replace(Self::COLORS, ""); } let seen: Vec = before .split("\n") @@ -437,20 +450,22 @@ impl Universe { )?; if dot == before { if pos > 0 { - fs::remove_file(dot_file.as_str())?; + fs::remove_file(dot_file.as_str()).context(anyhow!("Can't remove previous .dot file"))?; } } else { let mut list = OpenOptions::new() .write(true) .append(true) - .open(format!("{home}/list.tex"))?; + .open(format!("{home}/list.tex")) + .context(anyhow!("Can't open list.tex for appending"))?; writeln!(list, "\\graph{{{pos}}}")?; } let mut log = OpenOptions::new() .write(true) .append(true) .create(true) - .open(format!("{home}/log.txt"))?; + .open(format!("{home}/log.txt")) + .context(anyhow!("Can't open log.txt for writing"))?; writeln!( log, "{}{}", @@ -575,20 +590,20 @@ fn quick_tests() -> Result<()> { .get(1) .ok_or(anyhow!("Can't understand path"))?; trace!("#quick_tests: {name}"); - fs::write("target/surge-recent.txt", name.as_bytes())?; + fs::write(Universe::FLAG, name.as_bytes()).context(anyhow!("Can't write to {}", Universe::FLAG))?; let mut s = Script::from_str(fs::read_to_string(&path)?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; - trace!("Before:\n {}", &g.to_dot()); let home = format!("target/surge/{}", name); if Path::new(home.as_str()).exists() { - fs::remove_dir_all(&home)?; + fs::remove_dir_all(&home).context(anyhow!("Can't delete directory '{home}'"))?; } let mut uni = Universe::from_graph(g); uni.register("inc", inc); uni.register("times", times); let r = uni.dataize("Φ.foo"); uni.exit_it("The end".to_string())?; + fs::remove_file(Universe::FLAG).context(anyhow!("Can't delete {}", Universe::FLAG))?; if r.is_err() { assert!(Command::new("make") .current_dir(home) @@ -598,7 +613,6 @@ fn quick_tests() -> Result<()> { .unwrap() .success()); } - trace!("After:\n {}", uni.g.to_dot()); let hex = r.context(anyhow!("Failure in {path}"))?; assert_eq!(42, hex.to_i64()?, "Failure in {path}"); } diff --git a/surge-make/Makefile b/surge-make/Makefile index 347ee6f..5f486e4 100644 --- a/surge-make/Makefile +++ b/surge-make/Makefile @@ -8,7 +8,7 @@ PDF = doc.pdf SHELL = bash $(PDF): $(BINS) - pdflatex doc.tex + pdflatex -interaction=batchmode -halt-on-error -shell-escape doc.tex %.pdf: %.dot dot -Tpdf -o $@ $< From 212fd4e8dadec145c6af291c3533d97287f78b03 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 6 Mar 2024 15:35:16 +0300 Subject: [PATCH 09/14] #psi: clean --- Cargo.lock | 550 +++++++++++------- Cargo.toml | 1 + eo-tests/org/eolang/reo/fibonacci.eo.off | 2 + .../org/eolang/reo/simple/arithmetic.eo.off | 1 + eo-tests/org/eolang/reo/simple/naive.eo | 1 + eo-tests/org/eolang/reo/simple/rho.eo | 2 + eo-tests/org/eolang/reo/simple/sum.eo | 1 + ...-copy-inside.sodg => _16-copy-inside.sodg} | 0 src/universe.rs | 46 +- test-pom.xml | 3 +- 10 files changed, 377 insertions(+), 230 deletions(-) rename quick-tests/{16-copy-inside.sodg => _16-copy-inside.sodg} (100%) diff --git a/Cargo.lock b/Cargo.lock index 74e8f00..317251d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,30 +4,30 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "assert_cmd" -version = "2.0.10" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b2340f55d9661d76793b2bfc2eb0e62689bd79d067a95707ea762afd5e9dd" +checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8" dependencies = [ "anstyle", "bstr", @@ -44,7 +44,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] @@ -70,23 +70,28 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "bstr" -version = "1.3.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffdb39cb703212f3c11973452c2861b972f757b021158f3516ba10f2fa8b2c1" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", - "once_cell", "regex-automata", "serde", ] [[package]] -name = "cc" -version = "1.0.79" +name = "cfg-if" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" @@ -96,12 +101,12 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "once_cell", @@ -119,15 +124,23 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "colored" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" dependencies = [ - "atty", "lazy_static", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -140,6 +153,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "difflib" version = "0.4.0" @@ -154,9 +176,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "either" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "env_logger" @@ -173,44 +195,30 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", - "redox_syscall", - "windows-sys 0.45.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -234,9 +242,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -249,9 +257,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -259,15 +267,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -276,44 +284,44 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -329,11 +337,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi", ] @@ -359,12 +367,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - [[package]] name = "hex" version = "0.4.3" @@ -382,34 +384,14 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e86b86ae312accbf05ade23ce76b625e0e47a255712b7414037385a1c05380" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.45.0", -] - [[package]] name = "itertools" version = "0.10.5" @@ -421,9 +403,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "lazy_static" @@ -433,30 +415,36 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] -name = "log" -version = "0.4.17" +name = "lock_api" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ - "cfg-if", + "scopeguard", ] +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "normalize-line-endings" @@ -464,35 +452,65 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "num_threads" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + +[[package]] +name = "parking_lot" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93f386bb233083c799e6e642a9d73db98c24a5deeb95ffc85bf281255dffc98" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "smallvec", + "winapi", +] [[package]] name = "peresil" @@ -502,9 +520,9 @@ checksum = "f658886ed52e196e850cfbbfddab9eaa7f6d90dd0929e264c31e5cec07e09e57" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -512,6 +530,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -520,14 +544,13 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba7d6ead3e3966038f68caa9fc1f860185d95a793180bbcfe0d0da47b3961ed" +checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" dependencies = [ "anstyle", "difflib", "float-cmp", - "itertools", "normalize-line-endings", "predicates-core", "regex", @@ -551,9 +574,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -566,9 +589,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.26" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -605,35 +628,47 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", + "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.10" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reo" @@ -653,6 +688,7 @@ dependencies = [ "predicates", "rand", "regex", + "serial_test", "simple_logger 2.3.0", "sodg", "tempfile", @@ -676,7 +712,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7229b505ae0706e64f37ffc54a9c163e11022a6636d58fe1f3f52018257ff9f7" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "proc-macro2", "quote", "rustc_version", @@ -695,42 +731,69 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.9" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags", + "bitflags 2.4.2", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "semver" -version = "1.0.17" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.157" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.157" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "serial_test" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5" +checksum = "fef5f7c7434b2f2c598adc6f9494648a1e41274a75c0ba4056f680ae0c117fd6" +dependencies = [ + "lazy_static", + "parking_lot", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08338d8024b227c62bd68a12c7c9883f5c66780abaef15c550dc56f46ee6515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.0", + "syn 1.0.109", ] [[package]] @@ -748,26 +811,31 @@ dependencies = [ [[package]] name = "simple_logger" -version = "4.0.0" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e190a521c2044948158666916d9e872cbb9984f755e9bb3b5b75a836205affcd" +checksum = "8e7e46c8c90251d47d08b28b8a419ffb4aede0f87c2eea95e17d1d5bacbf3ef1" dependencies = [ - "atty", "colored", "log", "time", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + [[package]] name = "sodg" version = "0.0.32" @@ -784,7 +852,7 @@ dependencies = [ "regex", "rstest", "serde", - "simple_logger 4.0.0", + "simple_logger 4.3.3", "sxd-document", "sxd-xpath", "xml-builder", @@ -830,9 +898,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.0" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cff13bb1732bccfe3b246f3fdb09edfd51c01d6f5299b7ccd9457c2e4e37774" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -841,22 +909,21 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.52.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -869,19 +936,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "time" -version = "0.3.20" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ + "deranged", "itoa", "libc", + "num-conv", "num_threads", + "powerfmt", "serde", "time-core", "time-macros", @@ -889,16 +959,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -910,9 +981,9 @@ checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "wait-timeout" @@ -947,9 +1018,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -962,84 +1033,135 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-targets 0.48.5", ] [[package]] name = "windows-sys" -version = "0.45.0" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows-targets", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "xml-builder" diff --git a/Cargo.toml b/Cargo.toml index 2805600..cae974f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ lazy_static = "1.4.0" log = "0.4.17" predicates = "3.0.1" regex = "1.7.1" +serial_test = "0.4.0" simple_logger = "2.3.0" sodg = {version = "0.0.32", features = ["sober"]} #sodg = {path = "/code/o/sodg", features = ["sober"]} diff --git a/eo-tests/org/eolang/reo/fibonacci.eo.off b/eo-tests/org/eolang/reo/fibonacci.eo.off index a7df4f7..daf0b78 100644 --- a/eo-tests/org/eolang/reo/fibonacci.eo.off +++ b/eo-tests/org/eolang/reo/fibonacci.eo.off @@ -22,12 +22,14 @@ +package org.eolang.reo +# This is a simple object for testing of REO engine, used by eo_tests.rs. [] > fibonacci 8 > expected f 6 > @ + # This is a simple fibonacci function as an object, used by the fibonacci object. [x] > f if. > @ x.lt 2 diff --git a/eo-tests/org/eolang/reo/simple/arithmetic.eo.off b/eo-tests/org/eolang/reo/simple/arithmetic.eo.off index d1fd806..b6737ed 100644 --- a/eo-tests/org/eolang/reo/simple/arithmetic.eo.off +++ b/eo-tests/org/eolang/reo/simple/arithmetic.eo.off @@ -22,6 +22,7 @@ +package org.eolang.reo.simple +# This is a simple object for testing of REO engine, used by eo_tests.rs. [] > arithmetic 35 > expected times. > @ diff --git a/eo-tests/org/eolang/reo/simple/naive.eo b/eo-tests/org/eolang/reo/simple/naive.eo index 8a285fc..72e02a0 100644 --- a/eo-tests/org/eolang/reo/simple/naive.eo +++ b/eo-tests/org/eolang/reo/simple/naive.eo @@ -22,6 +22,7 @@ +package org.eolang.reo.simple +# This is a simple object for testing of REO engine, used by eo_tests.rs. [] > naive 42 > expected 42 > @ diff --git a/eo-tests/org/eolang/reo/simple/rho.eo b/eo-tests/org/eolang/reo/simple/rho.eo index c24b91b..acd973a 100644 --- a/eo-tests/org/eolang/reo/simple/rho.eo +++ b/eo-tests/org/eolang/reo/simple/rho.eo @@ -22,10 +22,12 @@ +package org.eolang.reo.simple +# This is a simple object for testing of REO engine, used by eo_tests.rs. [] > rho 13 > expected 5 > x kid 8 > @ +# This is a simple object for testing of REO engine, used by eo_tests.rs. [y] > kid ^.x.plus y > @ diff --git a/eo-tests/org/eolang/reo/simple/sum.eo b/eo-tests/org/eolang/reo/simple/sum.eo index 6eb45d4..31b2aac 100644 --- a/eo-tests/org/eolang/reo/simple/sum.eo +++ b/eo-tests/org/eolang/reo/simple/sum.eo @@ -22,6 +22,7 @@ +package org.eolang.reo.simple +# This is a simple object for testing of REO engine, used by eo_tests.rs. [] > sum 43 > expected 42.plus 1 > @ diff --git a/quick-tests/16-copy-inside.sodg b/quick-tests/_16-copy-inside.sodg similarity index 100% rename from quick-tests/16-copy-inside.sodg rename to quick-tests/_16-copy-inside.sodg diff --git a/src/universe.rs b/src/universe.rs index 956d208..369337e 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -169,15 +169,20 @@ impl Universe { } } +/// I have no idea why we need to have this intermediate +/// function, but without it Relay::re doesn't compile. +fn relay_it(u: *const Universe, at: u32, a: &str) -> Result { + unsafe { + let u1 = u as *mut Universe; + let u2 = &mut *u1; + Universe::mut_re(u2, at, a) + } +} + impl Relay for Universe { /// Resolve a locator on a vertex, if it is not found. fn re(&self, at: u32, a: &str) -> Result { - unsafe { - let cp = self as *const Self; - let mp = cp as *mut Self; - let uni = &mut *mp; - Self::mut_re(uni, at, a) - } + relay_it(self, at, a) } } @@ -380,6 +385,7 @@ impl Universe { const FLAG: &'static str = "target/surge-recent.txt"; + /// Create a new snapshot (PDF file) fn snapshot(&mut self, msg: String) -> Result<()> { lazy_static! { static ref DOT_LINE: Regex = Regex::new("^ +v([0-9]+)\\[.*$").unwrap(); @@ -389,6 +395,9 @@ impl Universe { } let name = fs::read_to_string(Self::FLAG) .context(anyhow!("Can't read the flag file"))?; + if name.is_empty() { + return Ok(()); + } let home = format!("target/surge/{name}"); fs::create_dir_all(home.clone()) .context(anyhow!("Can't create directory '{home}'"))?; @@ -415,10 +424,10 @@ impl Universe { let pos = total + 1; let mut before = String::new(); if pos > 1 { - before = - fs::read_to_string(format!("{home}/{}.dot", pos - 1)) - .context(anyhow!("Can't read previous .dot file from '{home}'"))? - .replace(Self::COLORS, ""); + let fname = format!("{}.dot", pos - 1); + before = fs::read_to_string(format!("{home}/{fname}")) + .context(anyhow!("Can't read previous {fname} file from '{home}'"))? + .replace(Self::COLORS, ""); } let seen: Vec = before .split("\n") @@ -450,14 +459,15 @@ impl Universe { )?; if dot == before { if pos > 0 { - fs::remove_file(dot_file.as_str()).context(anyhow!("Can't remove previous .dot file"))?; + fs::remove_file(dot_file.as_str()) + .context(anyhow!("Can't remove previous .dot file {dot_file}"))?; } } else { let mut list = OpenOptions::new() .write(true) .append(true) .open(format!("{home}/list.tex")) - .context(anyhow!("Can't open list.tex for appending"))?; + .context(anyhow!("Can't open {home}/list.tex for appending"))?; writeln!(list, "\\graph{{{pos}}}")?; } let mut log = OpenOptions::new() @@ -465,7 +475,7 @@ impl Universe { .append(true) .create(true) .open(format!("{home}/log.txt")) - .context(anyhow!("Can't open log.txt for writing"))?; + .context(anyhow!("Can't open {home}/log.txt for writing"))?; writeln!( log, "{}{}", @@ -581,22 +591,27 @@ fn fnd_absent_vertex() -> Result<()> { Ok(()) } +#[cfg(test)] +use serial_test::serial; + #[test] +#[serial] fn quick_tests() -> Result<()> { + fs::remove_dir_all("target/surge").context(anyhow!("Can't delete target/surge"))?; for path in sodg_scripts_in_dir("quick-tests") { let name = *path .split('/') .collect::>() .get(1) .ok_or(anyhow!("Can't understand path"))?; - trace!("#quick_tests: {name}"); + trace!("\n\n#quick_tests: {name}"); fs::write(Universe::FLAG, name.as_bytes()).context(anyhow!("Can't write to {}", Universe::FLAG))?; let mut s = Script::from_str(fs::read_to_string(&path)?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; let home = format!("target/surge/{}", name); if Path::new(home.as_str()).exists() { - fs::remove_dir_all(&home).context(anyhow!("Can't delete directory '{home}'"))?; + panic!("Directory already {home} exists"); } let mut uni = Universe::from_graph(g); uni.register("inc", inc); @@ -620,6 +635,7 @@ fn quick_tests() -> Result<()> { } #[test] +#[serial] fn quick_errors() -> Result<()> { for path in sodg_scripts_in_dir("quick-errors") { trace!("#quick_errors: {path}"); diff --git a/test-pom.xml b/test-pom.xml index da83ab9..0b60224 100644 --- a/test-pom.xml +++ b/test-pom.xml @@ -32,13 +32,14 @@ SOFTWARE. org.eolang eo-maven-plugin - 1.0-SNAPSHOT + 0.35.4 compile register assemble + verify ${project.basedir}/eo-tests From 64977b4b1bd6a985363dc6ee0d54220c113e5c2c Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 6 Mar 2024 15:40:28 +0300 Subject: [PATCH 10/14] #psi: clippy --- src/universe.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index 369337e..d512223 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -358,7 +358,7 @@ impl Universe { trace!("#tie(ν{v}, {a}): the {i}th attribute is {}", a1.0); return self.tie(v, a1.0); } - return Err(anyhow!("Can't tie to ν{v}.{a}")); + Err(anyhow!("Can't tie to ν{v}.{a}")) } /// The vertex is a dead-end, a nil. @@ -430,8 +430,7 @@ impl Universe { .replace(Self::COLORS, ""); } let seen: Vec = before - .split("\n") - .into_iter() + .split('\n') .map(|t| match &DOT_LINE.captures(t) { Some(m) => m.get(1).unwrap().as_str().parse().unwrap(), None => 0, @@ -441,15 +440,14 @@ impl Universe { let dot_file = format!("{home}/{pos}.dot"); fs::write( &dot_file, - &dot.split("\n") - .into_iter() + dot.split('\n') .map(|t| match &DOT_LINE.captures(t) { Some(m) => { let v = m.get(1).unwrap().as_str().parse::().unwrap(); if seen.contains(&v) { t.to_string() } else { - t.replace("[", format!("[{}", Self::COLORS).as_str()) + t.replace('[', format!("[{}", Self::COLORS).as_str()) } } None => t.to_string(), @@ -480,17 +478,17 @@ impl Universe { log, "{}{}", " ".repeat(self.depth), - msg.replace("ν", "v").replace("Δ", "D") + msg.replace('ν', "v").replace('Δ', "D") )?; let full = fs::read_to_string(format!("{home}/log.txt"))?; - let lines = full.split("\n").collect::>(); + let lines = full.split('\n').collect::>(); let max = 32; fs::write( format!("{home}/log-{pos}.txt"), lines .clone() .into_iter() - .skip(cmp::max(0 as i16, lines.len() as i16 - max) as usize) + .skip(cmp::max(0i16, lines.len() as i16 - max) as usize) .collect::>() .join("\n"), )?; @@ -597,7 +595,6 @@ use serial_test::serial; #[test] #[serial] fn quick_tests() -> Result<()> { - fs::remove_dir_all("target/surge").context(anyhow!("Can't delete target/surge"))?; for path in sodg_scripts_in_dir("quick-tests") { let name = *path .split('/') From e97af63c0c0b899cbf67496bfc0e11a9d8bf874e Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 6 Mar 2024 15:41:58 +0300 Subject: [PATCH 11/14] #psi: clean --- src/universe.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index d512223..c95d009 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -502,6 +502,9 @@ use sodg::Script; #[cfg(test)] use std::process::Command; +#[cfg(test)] +use serial_test::serial; + #[cfg(test)] use glob::glob; @@ -516,6 +519,7 @@ fn rand(uni: &mut Universe, _: u32) -> Result { } #[test] +#[serial] fn generates_random_int() -> Result<()> { let mut uni = Universe::empty(); let root = uni.add(); @@ -589,9 +593,6 @@ fn fnd_absent_vertex() -> Result<()> { Ok(()) } -#[cfg(test)] -use serial_test::serial; - #[test] #[serial] fn quick_tests() -> Result<()> { @@ -608,7 +609,7 @@ fn quick_tests() -> Result<()> { s.deploy_to(&mut g)?; let home = format!("target/surge/{}", name); if Path::new(home.as_str()).exists() { - panic!("Directory already {home} exists"); + fs::remove_dir_all(&home).context(anyhow!("Can't delete directory '{home}'"))?; } let mut uni = Universe::from_graph(g); uni.register("inc", inc); From 7383e3e51019c91ecf3c6e822a6afc6ad4ad84ac Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 6 Mar 2024 15:49:23 +0300 Subject: [PATCH 12/14] #psi: fmt --- src/universe.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/universe.rs b/src/universe.rs index c95d009..c79ddb6 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -393,14 +393,12 @@ impl Universe { if !Path::new(Self::FLAG).exists() { return Ok(()); } - let name = fs::read_to_string(Self::FLAG) - .context(anyhow!("Can't read the flag file"))?; + let name = fs::read_to_string(Self::FLAG).context(anyhow!("Can't read the flag file"))?; if name.is_empty() { return Ok(()); } let home = format!("target/surge/{name}"); - fs::create_dir_all(home.clone()) - .context(anyhow!("Can't create directory '{home}'"))?; + fs::create_dir_all(home.clone()).context(anyhow!("Can't create directory '{home}'"))?; let total = fs::read_dir(home.as_str()) .context(anyhow!("Can't list files in {home}"))? .filter(|f| { @@ -603,7 +601,8 @@ fn quick_tests() -> Result<()> { .get(1) .ok_or(anyhow!("Can't understand path"))?; trace!("\n\n#quick_tests: {name}"); - fs::write(Universe::FLAG, name.as_bytes()).context(anyhow!("Can't write to {}", Universe::FLAG))?; + fs::write(Universe::FLAG, name.as_bytes()) + .context(anyhow!("Can't write to {}", Universe::FLAG))?; let mut s = Script::from_str(fs::read_to_string(&path)?.as_str()); let mut g = Sodg::empty(); s.deploy_to(&mut g)?; From f667097826c15fe3144d689c0492bfb9ce6e735a Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 6 Mar 2024 15:54:12 +0300 Subject: [PATCH 13/14] #psi: version sup --- .github/workflows/cargo.yml | 8 ++++---- .github/workflows/tarpaulin.yml | 11 ++++++++--- .github/workflows/xcop.yml | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 8481e37..0a2158c 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -3,17 +3,17 @@ on: push: pull_request: concurrency: - group: ${{ github.ref }} + group: cargo-${{ github.ref }} cancel-in-progress: true jobs: - build: - runs-on: ubuntu-20.04 + cargo: + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 17 + java-version: 21 - uses: actions-rs/toolchain@v1 with: toolchain: stable diff --git a/.github/workflows/tarpaulin.yml b/.github/workflows/tarpaulin.yml index 9151f8b..23ebf1f 100644 --- a/.github/workflows/tarpaulin.yml +++ b/.github/workflows/tarpaulin.yml @@ -2,10 +2,14 @@ name: tarpaulin on: push: - pull_request: + branches: + - master +concurrency: + group: tarpaulin-${{ github.ref }} + cancel-in-progress: true jobs: - check: - runs-on: ubuntu-20.04 + tarpaulin: + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 @@ -18,4 +22,5 @@ jobs: args: '-- --test-threads 1' - uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true diff --git a/.github/workflows/xcop.yml b/.github/workflows/xcop.yml index cdc3c73..5480d7d 100644 --- a/.github/workflows/xcop.yml +++ b/.github/workflows/xcop.yml @@ -9,7 +9,7 @@ name: xcop - master jobs: xcop: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: g4s8/xcop-action@master From c6e087f8aef368e0701bd32d2688a02fae43a1c1 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 6 Mar 2024 15:55:01 +0300 Subject: [PATCH 14/14] #psi: rultor --- .rultor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.rultor.yml b/.rultor.yml index f1d53a2..81f55f7 100644 --- a/.rultor.yml +++ b/.rultor.yml @@ -1,5 +1,5 @@ docker: - image: yegor256/rultor-image:1.18.0 + image: yegor256/rultor-image:1.22.0 assets: credentials: yegor256/objectionary-secrets#crates-credentials install: | @@ -9,6 +9,7 @@ merge: cargo --color=never test -vv cargo --color=never fmt --check release: + pre: false script: |- [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1 sed -i -e "s/^version = \"0.0.0\"/version = \"${tag}\"/" Cargo.toml