Skip to content

Store all temporary files under a single folder #2031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arduino/sketch/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,5 @@ func GenBuildPath(sketchPath *paths.Path) *paths.Path {
}
md5SumBytes := md5.Sum([]byte(path))
md5Sum := strings.ToUpper(hex.EncodeToString(md5SumBytes[:]))
return paths.TempDir().Join("arduino-sketch-" + md5Sum)
return paths.TempDir().Join("arduino/arduino-sketch-" + md5Sum)
}
4 changes: 2 additions & 2 deletions arduino/sketch/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ func TestNewSketchFolderSymlink(t *testing.T) {
}

func TestGenBuildPath(t *testing.T) {
want := paths.TempDir().Join("arduino-sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
want := paths.TempDir().Join("arduino/arduino-sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
assert.True(t, GenBuildPath(paths.New("foo")).EquivalentTo(want))

want = paths.TempDir().Join("arduino-sketch-D41D8CD98F00B204E9800998ECF8427E")
want = paths.TempDir().Join("arduino/arduino-sketch-D41D8CD98F00B204E9800998ECF8427E")
assert.True(t, GenBuildPath(nil).EquivalentTo(want))
}

Expand Down
2 changes: 1 addition & 1 deletion commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
// Optimize for debug
builderCtx.OptimizeForDebug = req.GetOptimizeForDebug()

builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino-core-cache")
builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino/arduino-core-cache")

builderCtx.Jobs = int(req.GetJobs())

Expand Down
8 changes: 4 additions & 4 deletions internal/integrationtest/compile_1/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func compileWithSimpleSketch(t *testing.T, env *integrationtest.Environment, cli
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
require.NotEmpty(t, sketchPathMd5)
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)
require.FileExists(t, buildDir.Join(sketchName+".ino.eep").String())
require.FileExists(t, buildDir.Join(sketchName+".ino.elf").String())
require.FileExists(t, buildDir.Join(sketchName+".ino.hex").String())
Expand Down Expand Up @@ -374,7 +374,7 @@ func compileWithOutputDirFlag(t *testing.T, env *integrationtest.Environment, cl
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
require.NotEmpty(t, sketchPathMd5)
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)
require.FileExists(t, buildDir.Join(sketchName+".ino.eep").String())
require.FileExists(t, buildDir.Join(sketchName+".ino.elf").String())
require.FileExists(t, buildDir.Join(sketchName+".ino.hex").String())
Expand Down Expand Up @@ -441,7 +441,7 @@ func compileWithCustomBuildPath(t *testing.T, env *integrationtest.Environment,
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
require.NotEmpty(t, sketchPathMd5)
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)
require.NoFileExists(t, buildDir.Join(sketchName+".ino.eep").String())
require.NoFileExists(t, buildDir.Join(sketchName+".ino.elf").String())
require.NoFileExists(t, buildDir.Join(sketchName+".ino.hex").String())
Expand Down Expand Up @@ -975,7 +975,7 @@ func compileWithInvalidBuildOptionJson(t *testing.T, env *integrationtest.Enviro
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
require.NotEmpty(t, sketchPathMd5)
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)

_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/integrationtest/compile_2/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func recompileWithDifferentLibrary(t *testing.T, env *integrationtest.Environmen
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
require.NotEmpty(t, sketchPathMd5)
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)

// Compile sketch using library not managed by CLI
stdout, _, err := cli.Run("compile", "-b", fqbn, "--library", manuallyInstalledLibPath.String(), sketchPath.String(), "-v")
Expand Down
2 changes: 1 addition & 1 deletion internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func TestCoreInstallEsp32(t *testing.T) {
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
require.NotEmpty(t, sketchPathMd5)
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)
require.FileExists(t, buildDir.Join(sketchName+".ino.partitions.bin").String())
}

Expand Down
2 changes: 1 addition & 1 deletion internal/integrationtest/upload_mock/upload_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ func TestUploadSketch(t *testing.T) {
func generateBuildDir(sketchPath *paths.Path, t *testing.T) *paths.Path {
md5 := md5.Sum(([]byte(sketchPath.String())))
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
buildDir := paths.TempDir().Join("arduino/arduino-sketch-" + sketchPathMd5)
require.NoError(t, buildDir.MkdirAll())
require.NoError(t, buildDir.ToAbs())
return buildDir
Expand Down