Skip to content

Commit 8f70567

Browse files
kit-ty-katerjbou
authored andcommitted
reftest: Add the unset builtin
1 parent bf27cc0 commit 8f70567

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

master_changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ users)
149149
* Bump `OPAM_REPO_SHA` in the github action workflows to allow patch 3.0.0 [#6663 @kit-ty-kate]
150150
* Allow `sed-cmd` to parse even if no space is after the command [#6675 @rjbou]
151151
* Harden the regexp used for substituting variable checksums [#6710 @kit-ty-kate]
152+
* Add the `unset` builtin [#6708 @kit-ty-kate]
152153

153154
## Github Actions
154155
* bump `actions/checkout` from 4 to 5 [#6643 @kit-ty-kate]

tests/reftests/reftests.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,3 +944,13 @@ name: "baz"
944944
version: "1"
945945
extra-files: ["xf-baz" "md5=9ac116bceba2bdf45065df19d26a6b64"]
946946
### opam-cache repo inexistent
947+
### :V:4: unset
948+
### env | grep REFTEST_UNSET
949+
### REFTEST_UNSET=test
950+
### env | grep REFTEST_UNSET
951+
REFTEST_UNSET=test
952+
### REFTEST_UNSET=""
953+
### env | grep REFTEST_UNSET
954+
REFTEST_UNSET=
955+
### unset REFTEST_UNSET
956+
### env | grep REFTEST_UNSET

tests/reftests/run.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ type command =
285285
unordered: bool;
286286
sort: bool;}
287287
| Export of (string * [`eq | `pluseq | `eqplus] * string) list
288+
| Unset of string list
288289
| Comment of string
289290

290291
module Parse = struct
@@ -496,6 +497,8 @@ module Parse = struct
496497
Opamfile { files = args; filter = rewr; }
497498
| Some "json-cat" ->
498499
Json { files = args; filter = rewr; }
500+
| Some "unset" ->
501+
Unset args
499502
| Some "opam-cache" ->
500503
let kind, switch, nvs =
501504
match args with
@@ -984,6 +987,8 @@ let run_test ?(vars=[]) ~opam t =
984987
in
985988
(v, value) :: List.filter (fun (w, _) -> not (String.equal v w)) vars)
986989
vars bindings
990+
| Unset l ->
991+
List.filter (fun (w, _) -> not (List.exists (fun v -> String.equal v w) l)) vars
987992
| Opamfile { files; filter } ->
988993
let files =
989994
List.map (fun s ->

0 commit comments

Comments
 (0)