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 diff --git a/.rultor.yml b/.rultor.yml index 2fbc8c5..81f55f7 100644 --- a/.rultor.yml +++ b/.rultor.yml @@ -1,5 +1,5 @@ docker: - image: yegor256/rultor-image:1.17.2 + 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 diff --git a/Cargo.lock b/Cargo.lock index 5c695f5..0f3df4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,38 +4,32 @@ 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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" - -[[package]] -name = "anstyle" -version = "1.0.0" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +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.12" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8" dependencies = [ - "anstyle 1.0.0", + "anstyle", "bstr", "doc-comment", "predicates", @@ -50,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", ] @@ -76,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" @@ -102,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", @@ -125,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]] @@ -148,12 +155,21 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.2" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1586fa608b1dab41f667475b4a41faec5ba680aee428bfa5de4ea520fdc6e901" +checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" dependencies = [ "quote", - "syn 2.0.18", + "syn 2.0.52", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", ] [[package]] @@ -170,9 +186,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" @@ -189,44 +205,30 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -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.21" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", - "redox_syscall", - "windows-sys 0.48.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -250,9 +252,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", @@ -265,9 +267,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", @@ -275,15 +277,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", @@ -292,44 +294,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", @@ -345,11 +347,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", ] @@ -375,12 +377,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" @@ -398,34 +394,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" @@ -437,9 +413,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" @@ -449,27 +425,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 = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] [[package]] name = "log" -version = "0.4.18" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +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" @@ -477,35 +462,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 = "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 = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "b93f386bb233083c799e6e642a9d73db98c24a5deeb95ffc85bf281255dffc98" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "smallvec", + "winapi", +] [[package]] name = "peresil" @@ -515,9 +530,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" @@ -525,6 +540,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" @@ -533,14 +554,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 0.3.5", + "anstyle", "difflib", "float-cmp", - "itertools", "normalize-line-endings", "predicates-core", "regex", @@ -564,9 +584,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -579,9 +599,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.28" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -618,35 +638,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 = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.7.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cce168fea28d3e05f158bda4576cf0c844d5045bc2cc3620fa0292ed5bb5814c" +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.29" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reo" @@ -656,7 +688,7 @@ dependencies = [ "assert_cmd", "clap", "colored", - "ctor 0.2.2", + "ctor 0.2.7", "filetime", "fsutils", "glob", @@ -666,6 +698,7 @@ dependencies = [ "predicates", "rand", "regex", + "serial_test", "simple_logger", "sodg", "tempfile", @@ -689,7 +722,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", @@ -708,38 +741,65 @@ 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.156" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.156" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +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 = "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", @@ -748,9 +808,9 @@ dependencies = [ [[package]] name = "simple_logger" -version = "4.3.0" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0ca6504625ee1aa5fda33913d2005eab98c7a42dd85f116ecce3ff54c9d3ef" +checksum = "8e7e46c8c90251d47d08b28b8a419ffb4aede0f87c2eea95e17d1d5bacbf3ef1" dependencies = [ "colored", "log", @@ -760,18 +820,24 @@ dependencies = [ [[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.30" +version = "0.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbba9d8070919a5705cb7ac808bbba48d6062c8558787b458e71e7221f1722de" +checksum = "a93247d55e07882155c63f5267d8f75ce1c52fd11a0f4db91ca88bd91803dfcc" dependencies = [ "anyhow", "bincode", @@ -829,9 +895,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.18" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -840,22 +906,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", ] @@ -868,19 +933,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", @@ -888,16 +956,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", ] @@ -909,9 +978,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" @@ -946,9 +1015,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", ] @@ -961,153 +1030,138 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.48.5", ] [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.52.4", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "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.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "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.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +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 = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +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.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[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 a4546c2..be5ab86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,10 @@ lazy_static = "1.4.0" log = "0.4.18" predicates = "3.0.1" regex = "1.7.2" -simple_logger = "4.3.0" -sodg = {version = "0.0.30", features = ["sober"]} +serial_test = "0.4.0" +sodg = {version = "0.0.32", features = ["sober"]} #sodg = {path = "/code/o/sodg", features = ["sober"]} +simple_logger = "4.3.0" [dev-dependencies] assert_cmd = "2.0.12" 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/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/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/quick-tests/_16-copy-inside.sodg b/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/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/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 d4d9d4b..c79ddb6 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -20,13 +20,36 @@ 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; +macro_rules! enter { + ($self:expr, $($arg:tt)+) => { + $self.enter_it(format!($($arg)+))?; + } +} + +macro_rules! exit { + ($self:expr, $($arg:tt)+) => { + $self.exit_it(format!($($arg)+))?; + } +} + +// self.depth += 1; +// if self.depth > 20 { +// return Err(anyhow!("The recursion is too deep ({} levels)", self.depth)); +// } + impl Universe { /// Makes an empty Universe. pub fn empty() -> Self { @@ -86,7 +109,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 +134,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(), @@ -146,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) } } @@ -171,21 +199,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,67 +223,65 @@ 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.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, 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) + 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) } @@ -335,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. @@ -344,11 +367,129 @@ impl Universe { return Ok(kids.len() == 1 && kids.iter().all(|(a, _)| a == "ρ")); } - fn check_recursion(&mut self) -> Result<()> { + fn enter_it(&mut self, msg: String) -> Result<()> { self.depth += 1; - if self.depth > 20 { - return Err(anyhow!("The recursion is too deep ({} levels)", self.depth)); + self.snapshot(msg)?; + Ok(()) + } + + fn exit_it(&mut self, msg: String) -> Result<()> { + if self.depth > 0 { + self.depth -= 1; + } + self.snapshot(msg)?; + Ok(()) + } + + const COLORS: &'static str = "fillcolor=aquamarine3,style=filled,"; + + 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(); + } + if !Path::new(Self::FLAG).exists() { + return Ok(()); + } + 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}'"))?; + let total = fs::read_dir(home.as_str()) + .context(anyhow!("Can't list files in {home}"))? + .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")) + .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 { + 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') + .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') + .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()) + .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 {home}/list.tex for appending"))?; + writeln!(list, "\\graph{{{pos}}}")?; } + let mut log = OpenOptions::new() + .write(true) + .append(true) + .create(true) + .open(format!("{home}/log.txt")) + .context(anyhow!("Can't open {home}/log.txt for writing"))?; + 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(0i16, lines.len() as i16 - max) as usize) + .collect::>() + .join("\n"), + )?; Ok(()) } } @@ -357,7 +498,10 @@ impl Universe { use sodg::Script; #[cfg(test)] -use std::fs; +use std::process::Command; + +#[cfg(test)] +use serial_test::serial; #[cfg(test)] use glob::glob; @@ -373,6 +517,7 @@ fn rand(uni: &mut Universe, _: u32) -> Result { } #[test] +#[serial] fn generates_random_int() -> Result<()> { let mut uni = Universe::empty(); let root = uni.add(); @@ -447,18 +592,39 @@ fn fnd_absent_vertex() -> Result<()> { } #[test] +#[serial] fn quick_tests() -> Result<()> { for path in sodg_scripts_in_dir("quick-tests") { - trace!("#quick_tests: {path}"); - let mut s = Script::from_str(fs::read_to_string(path.clone())?.as_str()); + let name = *path + .split('/') + .collect::>() + .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))?; + 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()); + 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}'"))?; + } let mut uni = Universe::from_graph(g); uni.register("inc", inc); uni.register("times", times); let r = uni.dataize("Φ.foo"); - trace!("After:\n {}", uni.g.to_dot()); + 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) + .spawn() + .unwrap() + .wait() + .unwrap() + .success()); + } let hex = r.context(anyhow!("Failure in {path}"))?; assert_eq!(42, hex.to_i64()?, "Failure in {path}"); } @@ -466,10 +632,11 @@ fn quick_tests() -> Result<()> { } #[test] +#[serial] 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); diff --git a/surge-make/Makefile b/surge-make/Makefile new file mode 100644 index 0000000..5f486e4 --- /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 -interaction=batchmode -halt-on-error -shell-escape 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..c6637c1 --- /dev/null +++ b/surge-make/doc.tex @@ -0,0 +1,20 @@ +\documentclass[landscape,oneside]{article} +\usepackage[utf8]{inputenc} +\usepackage[paperwidth=18in, paperheight=9in, left=.2in, right=.2in, top=.2in, bottom=.2in]{geometry} +\RequirePackage{microtype} +\usepackage{svg} +\usepackage{multicol} +\usepackage{graphicx} +\usepackage{listings} +\lstset{basicstyle=\ttfamily} +\newcommand\graph[1]{% + \clearpage% + \begin{multicols}{2} + \includegraphics[height=8.6in]{#1.pdf}% + \par\columnbreak\par + \lstinputlisting{log-#1.txt} + \end{multicols} +} +\begin{document} +\input{list.tex} +\end{document} \ No newline at end of file diff --git a/test-pom.xml b/test-pom.xml index b8bcf3f..0b60224 100644 --- a/test-pom.xml +++ b/test-pom.xml @@ -32,13 +32,14 @@ SOFTWARE. org.eolang eo-maven-plugin - 0.29.2 + 0.35.4 compile register assemble + verify ${project.basedir}/eo-tests