Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Sergej Kostjucenko
cargo-contract
Commits
3495c43b
Unverified
Commit
3495c43b
authored
Jan 20, 2022
by
Michael Müller
Committed by
GitHub
Jan 20, 2022
Browse files
Retry on `ExecutableFileBusy` (#403)
parent
813fd22b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cmd/build.rs
View file @
3495c43b
...
...
@@ -515,18 +515,27 @@ fn do_optimization(
///
/// Currently this must be a version >= 99.
fn
check_wasm_opt_version_compatibility
(
wasm_opt_path
:
&
Path
)
->
Result
<
()
>
{
let
cmd
=
Command
::
new
(
wasm_opt_path
)
.arg
(
"--version"
)
.output
()
.map_err
(|
err
|
{
anyhow
::
anyhow!
(
"Executing `{:?} --version` failed with {:?}"
,
wasm_opt_path
.display
(),
err
)
})
?
;
if
!
cmd
.status
.success
()
{
let
err
=
str
::
from_utf8
(
&
cmd
.stderr
)
let
mut
cmd_res
=
Command
::
new
(
wasm_opt_path
)
.arg
(
"--version"
)
.output
();
// The following condition is a workaround for a spurious CI failure:
// ```
// Executing `"/tmp/cargo-contract.test.GGnC0p/wasm-opt-mocked" --version` failed with
// Os { code: 26, kind: ExecutableFileBusy, message: "Text file busy" }
// ```
if
cmd_res
.is_err
()
&&
format!
(
"{:?}"
,
cmd_res
)
.contains
(
"ExecutableFileBusy"
)
{
std
::
thread
::
sleep
(
std
::
time
::
Duration
::
from_secs
(
1
));
cmd_res
=
Command
::
new
(
wasm_opt_path
)
.arg
(
"--version"
)
.output
();
}
let
res
=
cmd_res
.map_err
(|
err
|
{
anyhow
::
anyhow!
(
"Executing `{:?} --version` failed with {:?}"
,
wasm_opt_path
.display
(),
err
)
})
?
;
if
!
res
.status
.success
()
{
let
err
=
str
::
from_utf8
(
&
res
.stderr
)
.expect
(
"Cannot convert stderr output of wasm-opt to string"
)
.trim
();
anyhow
::
bail!
(
...
...
@@ -545,7 +554,7 @@ fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> {
way forward is to download a recent binary release directly:
\n\n
\
https://github.com/WebAssembly/binaryen/releases
\n\n
\
Make sure that the `wasm-opt` file from that release is in your `PATH`."
;
let
version_stdout
=
str
::
from_utf8
(
&
cmd
.stdout
)
let
version_stdout
=
str
::
from_utf8
(
&
res
.stdout
)
.expect
(
"Cannot convert stdout output of wasm-opt to string"
)
.trim
();
let
re
=
Regex
::
new
(
r"wasm-opt version (\d+)"
)
.expect
(
"invalid regex"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment