Unverified Commit dad5e9cd authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

Fix compile --build-path not working with relative paths (#1423)

parent 5c5cc785
......@@ -144,7 +144,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
if req.GetBuildPath() == "" {
builderCtx.BuildPath = sk.BuildPath
} else {
builderCtx.BuildPath = paths.New(req.GetBuildPath())
builderCtx.BuildPath = paths.New(req.GetBuildPath()).Canonical()
}
if err = builderCtx.BuildPath.MkdirAll(); err != nil {
return nil, &commands.PermissionDeniedError{Message: tr("Cannot create build directory"), Cause: err}
......
......@@ -1155,3 +1155,33 @@ def test_compile_sketch_with_ipp_file_include(run_command, copy_sketch):
fqbn = "arduino:avr:uno"
assert run_command(f"compile -b {fqbn} {sketch_path} --verbose")
def test_compile_with_relative_build_path(run_command, data_dir, copy_sketch):
assert run_command("update")
run_command("core install arduino:avr@1.8.3")
sketch_name = "sketch_simple"
sketch_path = copy_sketch(sketch_name)
fqbn = "arduino:avr:uno"
build_path = Path("..", "build_path")
working_dir = Path(data_dir, "working_dir")
working_dir.mkdir()
assert run_command(f"compile -b {fqbn} --build-path {build_path} {sketch_path} -v", custom_working_dir=working_dir)
absolute_build_path = Path(data_dir, "build_path")
built_files = [f.name for f in absolute_build_path.glob("*")]
assert f"{sketch_name}.ino.eep" in built_files
assert f"{sketch_name}.ino.elf" in built_files
assert f"{sketch_name}.ino.hex" in built_files
assert f"{sketch_name}.ino.with_bootloader.bin" in built_files
assert f"{sketch_name}.ino.with_bootloader.hex" in built_files
assert "build.options.json" in built_files
assert "compile_commands.json" in built_files
assert "core" in built_files
assert "includes.cache" in built_files
assert "libraries" in built_files
assert "preproc" in built_files
assert "sketch" in built_files
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment