File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
test/blackbox-tests/test-cases/pkg/opam-var Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ Test the " version" variable for packages not in the solution in different
2+ contexts: string interpolation vs truthy/ filter context .
3+
4+ $ mkrepo
5+
6+ First, test the variable in string interpolation context (command argument):
7+
8+ $ mkpkg " string-context" << ' EOF'
9+ > build: [
10+ > [ " echo" " version=%{ not-in-lock: version} %" ]
11+ > ]
12+ > EOF
13+
14+ $ solve string-context
15+ Solution for dune. lock:
16+ - string-context. 0. 0. 1
17+
18+ The variable resolves to empty string at solve time :
19+
20+ $ cat dune. lock/ string-context. 0. 0. 1. pkg
21+ (version 0.0 . 1)
22+
23+ (build
24+ (all_platforms ((action (run echo version= % {pkg: not-in-lock: version})))))
25+
26+
27+ Now test the variable in truthy/ filter context (conditional on command):
28+
29+ $ mkpkg " truthy-context" << ' EOF'
30+ > build: [
31+ > [ " echo" " has version" ] {not-in-lock: version}
32+ > [ " echo" " no version" ] {! not-in-lock: version}
33+ > ]
34+ > EOF
35+
36+ $ solve truthy-context
37+ Solution for dune. lock:
38+ - truthy-context. 0. 0. 1
39+
40+ In truthy context , the variable is left for build time evaluation:
41+
42+ $ cat dune. lock/ truthy-context. 0. 0. 1. pkg
43+ (version 0.0 . 1)
44+
45+ (build
46+ (all_platforms
47+ ((action
48+ (progn
49+ (when % {pkg: not-in-lock: version} (run echo " has version" ))
50+ (when (not % {pkg: not-in-lock: version}) (run echo " no version" )))))))
51+
52+
53+
You can’t perform that action at this time.
0 commit comments