Merge pull request #2205 from Skgland/file-based-cli-tests

File based cli tests using trycmd
This commit is contained in:
Mark Thom
2023-12-05 14:45:00 -07:00
committed by GitHub
67 changed files with 417 additions and 275 deletions

325
Cargo.lock generated
View File

@@ -60,12 +60,54 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstream"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]]
name = "anstyle-parse"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
]
[[package]]
name = "arrayvec"
version = "0.5.2"
@@ -303,7 +345,7 @@ dependencies = [
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets",
"windows-targets 0.48.5",
]
[[package]]
@@ -369,6 +411,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
@@ -379,6 +427,15 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "content_inspector"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38"
dependencies = [
"memchr",
]
[[package]]
name = "core-foundation"
version = "0.9.3"
@@ -556,7 +613,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf"
dependencies = [
"nix 0.27.1",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -723,6 +780,12 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "dunce"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
[[package]]
name = "either"
version = "1.9.0"
@@ -758,7 +821,7 @@ checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -795,7 +858,19 @@ checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5"
dependencies = [
"cfg-if",
"rustix",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
name = "filetime"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0"
dependencies = [
"cfg-if",
"libc",
"redox_syscall 0.3.5",
"windows-sys 0.48.0",
]
[[package]]
@@ -1014,6 +1089,12 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "h2"
version = "0.3.21"
@@ -1096,7 +1177,7 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -1158,6 +1239,22 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "humantime-serde"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c"
dependencies = [
"humantime",
"serde",
]
[[package]]
name = "hyper"
version = "0.14.27"
@@ -1318,7 +1415,7 @@ checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -1554,7 +1651,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
dependencies = [
"libc",
"wasi",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -1658,6 +1755,12 @@ dependencies = [
"libc",
]
[[package]]
name = "normalize-line-endings"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]]
name = "ntapi"
version = "0.3.7"
@@ -1791,6 +1894,16 @@ dependencies = [
"num-traits",
]
[[package]]
name = "os_pipe"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177"
dependencies = [
"libc",
"windows-sys 0.48.0",
]
[[package]]
name = "parking_lot"
version = "0.11.2"
@@ -1836,7 +1949,7 @@ dependencies = [
"libc",
"redox_syscall 0.3.5",
"smallvec",
"windows-targets",
"windows-targets 0.48.5",
]
[[package]]
@@ -2360,7 +2473,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -2434,7 +2547,7 @@ version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
dependencies = [
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -2515,6 +2628,7 @@ dependencies = [
"to-syn-value",
"to-syn-value_derive",
"tokio",
"trycmd",
"walkdir",
"warp",
"wasm-bindgen",
@@ -2608,6 +2722,15 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80"
dependencies = [
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -2690,6 +2813,12 @@ dependencies = [
"keccak",
]
[[package]]
name = "shlex"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
[[package]]
name = "signal-hook"
version = "0.3.17"
@@ -2720,6 +2849,12 @@ dependencies = [
"libc",
]
[[package]]
name = "similar"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597"
[[package]]
name = "siphasher"
version = "0.3.11"
@@ -2741,6 +2876,37 @@ version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
[[package]]
name = "snapbox"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b377c0b6e4715c116473d8e40d51e3fa5b0a2297ca9b2a931ba800667b259ed"
dependencies = [
"anstream",
"anstyle",
"content_inspector",
"dunce",
"filetime",
"libc",
"normalize-line-endings",
"os_pipe",
"similar",
"snapbox-macros",
"tempfile",
"wait-timeout",
"walkdir",
"windows-sys 0.48.0",
]
[[package]]
name = "snapbox-macros"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed1559baff8a696add3322b9be3e940d433e7bb4e38d79017205fd37ff28b28e"
dependencies = [
"anstream",
]
[[package]]
name = "socket2"
version = "0.4.9"
@@ -2758,7 +2924,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e"
dependencies = [
"libc",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -2915,7 +3081,7 @@ dependencies = [
"fastrand",
"redox_syscall 0.3.5",
"rustix",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -3017,7 +3183,7 @@ dependencies = [
"signal-hook-registry",
"socket2 0.5.4",
"tokio-macros",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@@ -3089,6 +3255,28 @@ dependencies = [
"tracing",
]
[[package]]
name = "toml_datetime"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
dependencies = [
"indexmap 2.0.1",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]]
name = "tower-service"
version = "0.3.2"
@@ -3122,6 +3310,22 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "trycmd"
version = "0.14.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed009372a42fb103e6f8767b9222925485e03cca032b700d203e2c5b67bee4fb"
dependencies = [
"glob",
"humantime",
"humantime-serde",
"rayon",
"serde",
"shlex",
"snapbox",
"toml_edit",
]
[[package]]
name = "tungstenite"
version = "0.18.0"
@@ -3425,7 +3629,7 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
"windows-targets",
"windows-targets 0.48.5",
]
[[package]]
@@ -3434,7 +3638,16 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets",
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
]
[[package]]
@@ -3443,13 +3656,28 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
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.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.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
]
[[package]]
@@ -3458,42 +3686,93 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[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.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winnow"
version = "0.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c8ac106f5ae4cb3786c9ef22f066b20646795d0262df031bf04fd68630cd39"
dependencies = [
"memchr",
]
[[package]]
name = "winreg"
version = "0.50.0"
@@ -3501,7 +3780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [
"cfg-if",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]

View File

@@ -114,6 +114,7 @@ maplit = "1.0.2"
serial_test = "2.0.0"
iai-callgrind = { git = "https://github.com/iai-callgrind/iai-callgrind.git", rev = "c77bc3c83d7f4e976cc42d4597236a8db259e772" }
criterion = "0.5.1"
trycmd = "0.14.19"
[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
pprof = { version = "0.13.0", features = ["criterion", "flamegraph"] }

View File

@@ -1,4 +0,0 @@
% hello
% line!
a :- b(X).

View File

@@ -0,0 +1,5 @@
X = 1.
use_module(library(dif)).
X = 1.
dif(X,1).
halt.

View File

@@ -0,0 +1,4 @@
X = 1.
true.
X = 1.
dif:dif(X,1).

View File

@@ -0,0 +1,2 @@
# issue 857
args = ["-f", "--no-add-history"]

View File

@@ -0,0 +1,3 @@
['tests/scryer/cli/issues/do_not_duplicate_path_components.pl'].
['tests/scryer/cli/issues/do_not_duplicate_path_components.pl'].
halt.

View File

@@ -0,0 +1,2 @@
throw(e).
throw(e).

View File

@@ -0,0 +1,2 @@
# issue 852
args = ["-f", "--no-add-history"]

View File

@@ -0,0 +1 @@
helloworld

View File

@@ -0,0 +1,2 @@
# issue 820
args = ["-f", "--no-add-history", "-g", "test,halt", "tests/scryer/cli/issues/goals.pl"]

View File

@@ -0,0 +1 @@
helloworld

View File

@@ -0,0 +1,2 @@
# issue 820
args = ["-f", "--no-add-history", "-g", "test", "-g", "halt", "tests/scryer/cli/issues/goals.pl"]

View File

@@ -0,0 +1,11 @@
use_module(library(dif)).
use_module(library(atts)).
-X\=X.
-X=X.
dif(-X,X).
dif(-X,X), -X=X.
call_residue_vars(dif(-X,X), Vars).
set_prolog_flag(occurs_check, true).
-X\=X.
dif(-X,X).
halt.

View File

@@ -0,0 +1,10 @@
true.
true.
false.
X = -X.
dif:dif(-X,X).
false.
Vars = [X], dif:dif(-X,X).
true.
true.
true.

View File

@@ -0,0 +1,2 @@
# issue 844
args = ["-f", "--no-add-history"]

View File

@@ -0,0 +1,2 @@
use_module(library(freeze)), freeze(X,false), X \=a.
halt.

View File

@@ -0,0 +1 @@
freeze:freeze(X,false).

View File

@@ -0,0 +1,2 @@
# issue 807
args = ["-f", "--no-add-history"]

View File

@@ -0,0 +1,2 @@
write(a), write(b), false.
halt.

View File

@@ -0,0 +1 @@
ab false.

View File

@@ -0,0 +1,2 @@
# issue 815
args = ["-f", "--no-add-history"]

View File

@@ -0,0 +1,2 @@
f(X, X).
halt.

View File

@@ -0,0 +1 @@
false.

View File

@@ -0,0 +1,2 @@
# issue 841
args = ["-f", "--no-add-history", "tests/scryer/cli/issues/occurs_check_flag.pl"]

View File

@@ -0,0 +1,6 @@
set_prolog_flag(occurs_check, true).
X = -X.
asserta(f(X,g(X))).
f(X,X).
X-X = X-g(X).
halt.

View File

@@ -0,0 +1,5 @@
true.
false.
true.
false.
false.

View File

@@ -0,0 +1,2 @@
# issue 841
args = ["-f", "--no-add-history"]

View File

View File

View File

@@ -0,0 +1,2 @@
# issue 839
args = ["-f", "--no-add-history", "tests/scryer/cli/issues/op3.pl", "-g", "halt"]

View File

@@ -0,0 +1,2 @@
['tests/scryer/cli/issues/issue812-singleton-warning.pl'].
halt.

View File

@@ -0,0 +1,2 @@
Warning: singleton variables X at line 4 of issue812-singleton-warning.pl
true.

View File

@@ -0,0 +1,2 @@
# issue 812
args = ["-f", "--no-add-history"]

View File

@@ -0,0 +1 @@
All tests passed

View File

@@ -0,0 +1 @@
args = ["-f", "--no-add-history", "src/tests/acyclic_term.pl", "-f", "-g", "main_quiet"]

View File

@@ -0,0 +1 @@
All tests passed

View File

@@ -0,0 +1 @@
args = ["-f", "--no-add-history", "src/tests/dif.pl", "-f", "-g", "main_quiet"]

View File

@@ -0,0 +1 @@
All tests passed

View File

@@ -0,0 +1 @@
args = ["-f", "--no-add-history", "src/tests/ground.pl", "-f", "-g", "main_quiet"]

View File

@@ -0,0 +1 @@
1+21+31+2>A+B1+G1+2>41+2>B1+2>31+2>31+2>4ba

View File

@@ -0,0 +1 @@
args = ["-f", "--no-add-history", "src/tests/setup_call_cleanup.pl", "-f", "-g", "halt"]

View File

@@ -0,0 +1 @@
All tests passed

View File

@@ -0,0 +1 @@
args = ["-f", "--no-add-history", "src/tests/term_variables.pl", "-f", "-g", "main_quiet"]

View File

@@ -1,6 +1,3 @@
use assert_cmd::Command;
use std::ffi::OsStr;
pub(crate) trait Expectable {
#[track_caller]
fn assert_eq(self, other: &[u8]);
@@ -34,41 +31,3 @@ pub(crate) fn load_module_test<T: Expectable>(file: &str, expected: T) {
let mut wam = Machine::with_test_streams();
expected.assert_eq(wam.test_load_file(file).as_slice());
}
pub const SCRYER_PROLOG: &str = "scryer-prolog";
pub fn run_top_level_test_no_args<
S: Into<Vec<u8>>,
O: assert_cmd::assert::IntoOutputPredicate<P>,
P: predicates_core::Predicate<[u8]>,
>(
stdin: S,
expected_stdout: O,
) {
run_top_level_test_with_args::<&[&str], _, _, _, _>(&[], stdin, expected_stdout)
}
/// Test whether scryer-prolog
/// produces the expected output when called with the supplied
/// arguments and fed the supplied input
pub fn run_top_level_test_with_args<
A: IntoIterator<Item = AS>,
S: Into<Vec<u8>>,
O: assert_cmd::assert::IntoOutputPredicate<P>,
AS: AsRef<OsStr>,
P: predicates_core::Predicate<[u8]>,
>(
args: A,
stdin: S,
expected_stdout: O,
) {
Command::cargo_bin(SCRYER_PROLOG)
.unwrap()
.arg("-f")
.arg("--no-add-history")
.args(args)
.write_stdin(stdin)
.assert()
.stdout(expected_stdout.into_output())
.success();
}

View File

@@ -1,166 +1,6 @@
use crate::helper::{load_module_test, run_top_level_test_no_args, run_top_level_test_with_args};
use crate::helper::load_module_test;
use serial_test::serial;
// issue #857
#[test]
fn display_constraints() {
run_top_level_test_no_args(
"\
X = 1.\n\
use_module(library(dif)).\n\
X = 1.\n\
dif(X,1).\n
halt.\n",
" \
X = 1.\n \
true.\n \
X = 1.\n \
dif:dif(X,1).\n\
",
);
}
// issue #852
#[test]
fn do_not_duplicate_path_components() {
run_top_level_test_no_args(
"\
['tests-pl/issue852-throw_e.pl'].\n\
['tests-pl/issue852-throw_e.pl'].\n\
halt.\n\
",
" throw(e).\n throw(e).\n",
);
}
// issue #844
#[test]
fn handle_residual_goal() {
run_top_level_test_no_args(
"\
use_module(library(dif)).\n\
use_module(library(atts)).\n\
-X\\=X.\n\
-X=X.\n\
dif(-X,X).\n\
dif(-X,X), -X=X.\n\
call_residue_vars(dif(-X,X), Vars).\n\
set_prolog_flag(occurs_check, true).\n\
-X\\=X.\n\
dif(-X,X).\n\
halt.\n\
",
" \
true.\n \
true.\n \
false.\n \
X = -X.\n \
dif:dif(-X,X).\n \
false.\n \
Vars = [X], dif:dif(-X,X).\n \
true.\n \
true.\n \
true.\n\
",
)
}
// issue #841
#[test]
fn occurs_check_flag() {
run_top_level_test_with_args(
["tests-pl/issue841-occurs-check.pl"],
"\
f(X, X).\n\
halt.\n\
",
" false.\n",
)
}
#[test]
fn occurs_check_flag2() {
run_top_level_test_no_args(
"\
set_prolog_flag(occurs_check, true).\n\
X = -X.\n\
asserta(f(X,g(X))).\n\
f(X,X).\n\
X-X = X-g(X).\n\
halt.\n\
",
" \
true.\n \
false.\n \
true.\n \
false.\n \
false.\n\
",
)
}
// issue #839
#[test]
fn op3() {
run_top_level_test_with_args(["tests-pl/issue839-op3.pl", "-g", "halt"], "", "")
}
// issue #820
#[test]
fn multiple_goals() {
run_top_level_test_with_args(
["-g", "test", "-g", "halt", "tests-pl/issue820-goals.pl"],
"",
"helloworld\n",
);
}
// issue #820
#[test]
fn compound_goal() {
run_top_level_test_with_args(
["-g", "test,halt", "tests-pl/issue820-goals.pl"],
"",
"helloworld\n",
)
}
// issue #815
#[test]
fn no_stutter() {
run_top_level_test_no_args(
"write(a), write(b), false.\n\
halt.\n\
",
"ab false.\n",
)
}
/*
// issue #812
#[test] // FIXME: the line number is of by one (should be 4), empty line not accounted for or starting to count at line 0?
fn singleton_warning() {
run_top_level_test_no_args(
"['tests-pl/issue812-singleton-warning.pl'].\n\
halt.\n",
"\
Warning: singleton variables X at line 3 of issue812-singleton-warning.pl\n \
true.\n\
",
);
}
*/
// issue #807
#[test]
fn ignored_constraint() {
run_top_level_test_no_args(
"use_module(library(freeze)), freeze(X,false), X \\=a.\n\
halt.",
" freeze:freeze(X,false).\n",
);
}
// issue #831
#[serial]
#[test]

View File

@@ -1,3 +1,22 @@
mod helper;
mod issues;
mod src_tests;
/// To add new cli test copy an existing .toml file in `tests/scryer/cli/issues/` or `tests/scryer/cli/issues/src_tests/`,
/// adjust as necessary the `-f` and `--no-add-history` args should be kept but additional args may be added.
/// For input on stdin add a .stdin file with the same filename.
/// Then to generate new reference output files into dump/ run `TRYCMD=dump cargo test -- cli_test`
/// check that the output in the .stdout and .stderr file is as expected, then move them next to the .toml file.
///
/// If a test does not have a .stderr or .stdout the corresponding output is ignored i.e. any and no output is accepted
///
/// to re-generate all reference output files run `TRYCMD=overwrite cargo test -- cli_test`
/// then check that the changes are as expected e.g. by looking at the `git diff`
#[test]
fn cli_tests() {
trycmd::TestCases::new()
.default_bin_name("scryer-prolog")
.case("tests/scryer/cli/issues/*.toml")
.skip("tests/scryer/cli/issues/singleton_warning.toml") // wrong line number
.case("tests/scryer/cli/src_tests/*.toml");
}

View File

@@ -1,4 +1,4 @@
use crate::helper::{load_module_test, run_top_level_test_with_args};
use crate::helper::load_module_test;
use serial_test::serial;
#[serial]
@@ -55,15 +55,6 @@ fn setup_call_cleanup_load() {
);
}
#[test]
fn setup_call_cleanup_process() {
run_top_level_test_with_args(
["src/tests/setup_call_cleanup.pl", "-f", "-g", "halt"],
"",
"1+21+31+2>A+B1+G1+2>41+2>B1+2>31+2>31+2>4ba",
);
}
#[serial]
#[test]
fn clpz_load() {
@@ -75,39 +66,3 @@ fn clpz_load() {
fn iso_conformity_tests() {
load_module_test("tests-pl/iso-conformity-tests.pl", "All tests passed");
}
#[test]
fn dif_tests() {
run_top_level_test_with_args(
["src/tests/dif.pl", "-f", "-g", "main_quiet"],
"",
"All tests passed",
);
}
#[test]
fn ground_tests() {
run_top_level_test_with_args(
["src/tests/ground.pl", "-f", "-g", "main_quiet"],
"",
"All tests passed",
);
}
#[test]
fn term_variables_tests() {
run_top_level_test_with_args(
["src/tests/term_variables.pl", "-f", "-g", "main_quiet"],
"",
"All tests passed",
);
}
#[test]
fn acyclic_term_tests() {
run_top_level_test_with_args(
["src/tests/acyclic_term.pl", "-f", "-g", "main_quiet"],
"",
"All tests passed",
);
}