Skip to content

Commit a9d6f4c

Browse files
committed
unzip :test
1 parent bc88ef8 commit a9d6f4c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pbat/core.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ def render_function(function: Function, opts: Opts, github_data: GithubData):
301301
lines = expand_macros(name, function._body, opts, github, github_data)
302302
head = []
303303
append_path_var(opts, head)
304+
#print('render_function', function._name, opts.need_patch_var)
305+
if opts.need_patch_var:
306+
head += expand_macros(name, ['PATCH = find_app(C:\\Program Files\\Git\\usr\\bin\\patch.exe)\n'], opts)
304307
lines = head + lines
305308
lines = [re.sub('[ ]+$', '', line) for line in lines] # replace trailing spaces
306309
res.append(":{}_begin\n".format(name))
@@ -552,6 +555,8 @@ def macro_download(name, args, kwargs, ret, opts: Opts, ctx: Ctx, githubdata: Gi
552555

553556
verbose = kwarg_value(kwargs, 'verbose', 'v')
554557

558+
test = kwarg_value(kwargs, 'test', 't')
559+
555560
if opts.env_policy and not ctx.github:
556561
curl = '"%CURL%"'
557562
opts.need_curl_var = True
@@ -601,6 +606,9 @@ def spacejoin_nonempty(*vs):
601606
exp = "if not exist {} (\n echo downloading {}\n {}\n)\n".format(quoted(dest), os.path.basename(url), cmd)
602607
else:
603608
exp = "if not exist {} {}\n".format(quoted(dest), cmd)
609+
610+
if test and os.path.splitext(dest)[1].lower() in ['.7z', '.zip']:
611+
exp = '7z t {} > NUL || del /f {}\n'.format(quoted(dest), quoted(dest)) + exp
604612
elif shell == 'msys2':
605613
if cache is None:
606614
exp = cmd
@@ -697,7 +705,7 @@ def macro_patch(name, args, kwargs, ret, opts: Opts, ctx: Ctx, githubdata: Githu
697705
validate_args("patch", args, kwargs, ret, 1, 1, {"N", "forward", "p1"})
698706

699707
opts.use_patch = True
700-
if (opts.env_policy and not ctx.github) or opts.use_patch_var:
708+
if opts.env_policy or opts.use_patch_var:
701709
patch = '"%PATCH%"'
702710
opts.need_patch_var = True
703711
else:

pbat/parsescript.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def insert_includes(dirname, lines, included: set[str]):
206206
res = []
207207
changed = False
208208
for line in lines:
209-
m = re.match('\\s*include\((.*)\)', line)
209+
m = re.match('\\s*include\\((.*)\\)', line)
210210
if m:
211211
name = m.group(1)
212212
if os.path.splitext(name)[1] == '':

0 commit comments

Comments
 (0)