From ac0ef0c0321dcf9a02ce99238dff112040ffa938 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 22 Feb 2024 17:35:56 +0100 Subject: [PATCH 1/7] Slighlty moved variables near their utilization place --- .../arduino/cores/packagemanager/loader.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/arduino/cores/packagemanager/loader.go b/internal/arduino/cores/packagemanager/loader.go index 00f87dd3002..7f9b866d8d1 100644 --- a/internal/arduino/cores/packagemanager/loader.go +++ b/internal/arduino/cores/packagemanager/loader.go @@ -239,16 +239,10 @@ func (pm *Builder) loadPlatform(targetPackage *cores.Package, architecture strin func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *paths.Path) error { platform.InstallDir = path - // Some useful paths - installedJSONPath := path.Join("installed.json") - platformTxtPath := path.Join("platform.txt") - platformTxtLocalPath := path.Join("platform.local.txt") - programmersTxtPath := path.Join("programmers.txt") - // If the installed.json file is found load it, this is done to handle the // case in which the platform's index and its url have been deleted locally, // if we don't load it some information about the platform is lost - if installedJSONPath.Exist() { + if installedJSONPath := path.Join("installed.json"); installedJSONPath.Exist() { if _, err := pm.LoadPackageIndexFromFile(installedJSONPath); err != nil { return fmt.Errorf(tr("loading %[1]s: %[2]s"), installedJSONPath, err) } @@ -256,12 +250,15 @@ func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *pa // Create platform properties platform.Properties = platform.Properties.Clone() // TODO: why CLONE? - if p, err := properties.SafeLoad(platformTxtPath.String()); err == nil { + platformTxtPath := path.Join("platform.txt") + if p, err := properties.SafeLoadFromPath(platformTxtPath); err == nil { platform.Properties.Merge(p) } else { return fmt.Errorf(tr("loading %[1]s: %[2]s"), platformTxtPath, err) } - if p, err := properties.SafeLoad(platformTxtLocalPath.String()); err == nil { + + platformTxtLocalPath := path.Join("platform.local.txt") + if p, err := properties.SafeLoadFromPath(platformTxtLocalPath); err == nil { platform.Properties.Merge(p) } else { return fmt.Errorf(tr("loading %[1]s: %[2]s"), platformTxtLocalPath, err) @@ -287,7 +284,8 @@ func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *pa } // Create programmers properties - if programmersProperties, err := properties.SafeLoad(programmersTxtPath.String()); err == nil { + programmersTxtPath := path.Join("programmers.txt") + if programmersProperties, err := properties.SafeLoadFromPath(programmersTxtPath); err == nil { for programmerID, programmerProps := range programmersProperties.FirstLevelOf() { if !platform.PluggableDiscoveryAware { convertUploadToolsToPluggableDiscovery(programmerProps) From 6992c977699a23538a5eb127eb603540a357de7f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 23 Feb 2024 15:17:59 +0100 Subject: [PATCH 2/7] Added facility to keep timestamps of used files --- internal/arduino/cores/cores.go | 48 +++++++++++++++++++ .../arduino/cores/packagemanager/loader.go | 13 ++++- .../cores/packagemanager/package_manager.go | 9 ++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/internal/arduino/cores/cores.go b/internal/arduino/cores/cores.go index 63d4a76428d..9be3c48f365 100644 --- a/internal/arduino/cores/cores.go +++ b/internal/arduino/cores/cores.go @@ -24,6 +24,7 @@ import ( "path/filepath" "sort" "strings" + "time" "github.com/arduino/arduino-cli/internal/arduino/globals" "github.com/arduino/arduino-cli/internal/arduino/resources" @@ -70,6 +71,7 @@ type PlatformRelease struct { Programmers map[string]*Programmer `json:"-"` Menus *properties.Map `json:"-"` InstallDir *paths.Path `json:"-"` + Timestamps *TimestampsStore // Contains the timestamps of the files used to build this PlatformRelease IsTrusted bool `json:"-"` PluggableDiscoveryAware bool `json:"-"` // true if the Platform supports pluggable discovery (no compatibility layer required) Monitors map[string]*MonitorDependency `json:"-"` @@ -77,6 +79,51 @@ type PlatformRelease struct { Compatible bool `json:"-"` // true if at all ToolDependencies are available for the current OS/ARCH. } +// TimestampsStore is a generic structure to store timestamps +type TimestampsStore struct { + timestamps map[*paths.Path]*time.Time +} + +// NewTimestampsStore creates a new TimestampsStore +func NewTimestampsStore() *TimestampsStore { + return &TimestampsStore{ + timestamps: map[*paths.Path]*time.Time{}, + } +} + +// AddFile adds a file to the TimestampsStore +func (t *TimestampsStore) AddFile(path *paths.Path) { + if info, err := path.Stat(); err != nil { + t.timestamps[path] = nil // Save a missing file with a nil timestamp + } else { + modtime := info.ModTime() + t.timestamps[path] = &modtime + } +} + +// Dirty returns true if one of the files stored in the TimestampsStore has been +// changed after being added to the store. +func (t *TimestampsStore) Dirty() bool { + for path, timestamp := range t.timestamps { + if info, err := path.Stat(); err != nil { + if timestamp != nil { + return true + } + } else { + if timestamp == nil || info.ModTime() != *timestamp { + return true + } + } + } + return false +} + +// Dirty returns true if one of the files of this PlatformRelease has been changed +// (it means that the PlatformRelease should be rebuilt to be used correctly). +func (release *PlatformRelease) Dirty() bool { + return release.Timestamps.Dirty() +} + // BoardManifest contains information about a board. These metadata are usually // provided by the package_index.json type BoardManifest struct { @@ -207,6 +254,7 @@ func (platform *Platform) GetOrCreateRelease(version *semver.Version) *PlatformR Properties: properties.NewMap(), Programmers: map[string]*Programmer{}, Platform: platform, + Timestamps: NewTimestampsStore(), } platform.Releases[tag] = release return release diff --git a/internal/arduino/cores/packagemanager/loader.go b/internal/arduino/cores/packagemanager/loader.go index 7f9b866d8d1..68c603044e5 100644 --- a/internal/arduino/cores/packagemanager/loader.go +++ b/internal/arduino/cores/packagemanager/loader.go @@ -242,15 +242,20 @@ func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *pa // If the installed.json file is found load it, this is done to handle the // case in which the platform's index and its url have been deleted locally, // if we don't load it some information about the platform is lost - if installedJSONPath := path.Join("installed.json"); installedJSONPath.Exist() { + installedJSONPath := path.Join("installed.json") + platform.Timestamps.AddFile(installedJSONPath) + if installedJSONPath.Exist() { if _, err := pm.LoadPackageIndexFromFile(installedJSONPath); err != nil { return fmt.Errorf(tr("loading %[1]s: %[2]s"), installedJSONPath, err) } } + // TODO: why CLONE? + platform.Properties = platform.Properties.Clone() + // Create platform properties - platform.Properties = platform.Properties.Clone() // TODO: why CLONE? platformTxtPath := path.Join("platform.txt") + platform.Timestamps.AddFile(platformTxtPath) if p, err := properties.SafeLoadFromPath(platformTxtPath); err == nil { platform.Properties.Merge(p) } else { @@ -258,6 +263,7 @@ func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *pa } platformTxtLocalPath := path.Join("platform.local.txt") + platform.Timestamps.AddFile(platformTxtLocalPath) if p, err := properties.SafeLoadFromPath(platformTxtLocalPath); err == nil { platform.Properties.Merge(p) } else { @@ -285,6 +291,7 @@ func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *pa // Create programmers properties programmersTxtPath := path.Join("programmers.txt") + platform.Timestamps.AddFile(programmersTxtPath) if programmersProperties, err := properties.SafeLoadFromPath(programmersTxtPath); err == nil { for programmerID, programmerProps := range programmersProperties.FirstLevelOf() { if !platform.PluggableDiscoveryAware { @@ -408,12 +415,14 @@ func (pm *Builder) loadBoards(platform *cores.PlatformRelease) error { } boardsTxtPath := platform.InstallDir.Join("boards.txt") + platform.Timestamps.AddFile(boardsTxtPath) allBoardsProperties, err := properties.LoadFromPath(boardsTxtPath) if err != nil { return err } boardsLocalTxtPath := platform.InstallDir.Join("boards.local.txt") + platform.Timestamps.AddFile(boardsLocalTxtPath) if boardsLocalProperties, err := properties.SafeLoadFromPath(boardsLocalTxtPath); err == nil { allBoardsProperties.Merge(boardsLocalProperties) } else { diff --git a/internal/arduino/cores/packagemanager/package_manager.go b/internal/arduino/cores/packagemanager/package_manager.go index d40fa6312f3..667c62870ec 100644 --- a/internal/arduino/cores/packagemanager/package_manager.go +++ b/internal/arduino/cores/packagemanager/package_manager.go @@ -22,6 +22,7 @@ import ( "os" "path" "path/filepath" + "slices" "strconv" "strings" "sync" @@ -898,3 +899,11 @@ func (pme *Explorer) NormalizeFQBN(fqbn *cores.FQBN) (*cores.FQBN, error) { } return normalizedFqbn, nil } + +// Dirty returns true if one of the loaded platforms needs to be re-initialized +// due to file changes in the platform releases. +func (pme *Explorer) Dirty() bool { + return slices.ContainsFunc( + pme.InstalledPlatformReleases(), + (*cores.PlatformRelease).Dirty) +} From b305906e5de0fd899266879e212ebac5050da702 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 26 Feb 2024 12:02:42 +0100 Subject: [PATCH 3/7] Compile will fail if platforms are changed --- commands/cmderrors/cmderrors.go | 16 + commands/compile/compile.go | 4 + rpc/cc/arduino/cli/commands/v1/compile.pb.go | 298 +++++++++++-------- rpc/cc/arduino/cli/commands/v1/compile.proto | 2 + 4 files changed, 198 insertions(+), 122 deletions(-) diff --git a/commands/cmderrors/cmderrors.go b/commands/cmderrors/cmderrors.go index 248b785df0e..ef88f6a55c2 100644 --- a/commands/cmderrors/cmderrors.go +++ b/commands/cmderrors/cmderrors.go @@ -869,3 +869,19 @@ func (e *MultipleLibraryInstallDetected) Error() string { func (e *MultipleLibraryInstallDetected) ToRPCStatus() *status.Status { return status.New(codes.InvalidArgument, e.Error()) } + +// InstanceNeedsReinitialization +type InstanceNeedsReinitialization struct { +} + +func (e *InstanceNeedsReinitialization) Error() string { + return tr("The instance is no more valid and needs to be reinitialized") +} + +// ToRPCStatus converts the error into a *status.Status +func (e *InstanceNeedsReinitialization) ToRPCStatus() *status.Status { + st, _ := status. + New(codes.InvalidArgument, e.Error()). + WithDetails(&rpc.InstanceNeedsReinitializationError{}) + return st +} diff --git a/commands/compile/compile.go b/commands/compile/compile.go index 0beebfa56ca..78f8b6d5345 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -63,6 +63,10 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream } defer release() + if pme.Dirty() { + return nil, &cmderrors.InstanceNeedsReinitialization{} + } + lm, err := instances.GetLibraryManager(req.GetInstance()) if err != nil { return nil, err diff --git a/rpc/cc/arduino/cli/commands/v1/compile.pb.go b/rpc/cc/arduino/cli/commands/v1/compile.pb.go index 959b2c2639f..f286359a9f1 100644 --- a/rpc/cc/arduino/cli/commands/v1/compile.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/compile.pb.go @@ -433,6 +433,44 @@ func (*CompileResponse_Progress) isCompileResponse_Message() {} func (*CompileResponse_Result) isCompileResponse_Message() {} +type InstanceNeedsReinitializationError struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *InstanceNeedsReinitializationError) Reset() { + *x = InstanceNeedsReinitializationError{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InstanceNeedsReinitializationError) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InstanceNeedsReinitializationError) ProtoMessage() {} + +func (x *InstanceNeedsReinitializationError) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InstanceNeedsReinitializationError.ProtoReflect.Descriptor instead. +func (*InstanceNeedsReinitializationError) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{2} +} + type BuilderResult struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -457,7 +495,7 @@ type BuilderResult struct { func (x *BuilderResult) Reset() { *x = BuilderResult{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[2] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -470,7 +508,7 @@ func (x *BuilderResult) String() string { func (*BuilderResult) ProtoMessage() {} func (x *BuilderResult) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[2] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -483,7 +521,7 @@ func (x *BuilderResult) ProtoReflect() protoreflect.Message { // Deprecated: Use BuilderResult.ProtoReflect.Descriptor instead. func (*BuilderResult) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{2} + return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{3} } func (x *BuilderResult) GetBuildPath() string { @@ -548,7 +586,7 @@ type ExecutableSectionSize struct { func (x *ExecutableSectionSize) Reset() { *x = ExecutableSectionSize{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[3] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -561,7 +599,7 @@ func (x *ExecutableSectionSize) String() string { func (*ExecutableSectionSize) ProtoMessage() {} func (x *ExecutableSectionSize) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[3] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -574,7 +612,7 @@ func (x *ExecutableSectionSize) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecutableSectionSize.ProtoReflect.Descriptor instead. func (*ExecutableSectionSize) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{3} + return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{4} } func (x *ExecutableSectionSize) GetName() string { @@ -624,7 +662,7 @@ type CompileDiagnostic struct { func (x *CompileDiagnostic) Reset() { *x = CompileDiagnostic{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[4] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -637,7 +675,7 @@ func (x *CompileDiagnostic) String() string { func (*CompileDiagnostic) ProtoMessage() {} func (x *CompileDiagnostic) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[4] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -650,7 +688,7 @@ func (x *CompileDiagnostic) ProtoReflect() protoreflect.Message { // Deprecated: Use CompileDiagnostic.ProtoReflect.Descriptor instead. func (*CompileDiagnostic) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{4} + return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{5} } func (x *CompileDiagnostic) GetSeverity() string { @@ -720,7 +758,7 @@ type CompileDiagnosticContext struct { func (x *CompileDiagnosticContext) Reset() { *x = CompileDiagnosticContext{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[5] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -733,7 +771,7 @@ func (x *CompileDiagnosticContext) String() string { func (*CompileDiagnosticContext) ProtoMessage() {} func (x *CompileDiagnosticContext) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[5] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -746,7 +784,7 @@ func (x *CompileDiagnosticContext) ProtoReflect() protoreflect.Message { // Deprecated: Use CompileDiagnosticContext.ProtoReflect.Descriptor instead. func (*CompileDiagnosticContext) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{5} + return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{6} } func (x *CompileDiagnosticContext) GetMessage() string { @@ -795,7 +833,7 @@ type CompileDiagnosticNote struct { func (x *CompileDiagnosticNote) Reset() { *x = CompileDiagnosticNote{} if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[6] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -808,7 +846,7 @@ func (x *CompileDiagnosticNote) String() string { func (*CompileDiagnosticNote) ProtoMessage() {} func (x *CompileDiagnosticNote) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[6] + mi := &file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -821,7 +859,7 @@ func (x *CompileDiagnosticNote) ProtoReflect() protoreflect.Message { // Deprecated: Use CompileDiagnosticNote.ProtoReflect.Descriptor instead. func (*CompileDiagnosticNote) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{6} + return file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP(), []int{7} } func (x *CompileDiagnosticNote) GetMessage() string { @@ -950,85 +988,88 @@ var file_cc_arduino_cli_commands_v1_compile_proto_rawDesc = []byte{ 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xa1, - 0x04, 0x0a, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, - 0x4a, 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x0d, 0x75, 0x73, - 0x65, 0x64, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x6b, 0x0a, 0x18, 0x65, - 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, + 0x75, 0x6c, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, + 0x0a, 0x22, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4e, 0x65, 0x65, 0x64, 0x73, 0x52, + 0x65, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa1, 0x04, 0x0a, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x4a, 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x6c, 0x69, + 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x69, 0x7a, 0x65, - 0x52, 0x16, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x5d, 0x0a, 0x0e, 0x62, 0x6f, 0x61, 0x72, - 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x36, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, - 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, - 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x5d, 0x0a, 0x0e, 0x62, 0x75, 0x69, 0x6c, 0x64, - 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x36, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, - 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x50, 0x6c, - 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x29, 0x0a, 0x10, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, - 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, - 0x73, 0x12, 0x4f, 0x0a, 0x0b, 0x64, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x73, - 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, + 0x72, 0x79, 0x52, 0x0d, 0x75, 0x73, 0x65, 0x64, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, + 0x73, 0x12, 0x6b, 0x0a, 0x18, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x69, 0x7a, 0x65, 0x52, 0x16, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x5d, + 0x0a, 0x0e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, - 0x6f, 0x73, 0x74, 0x69, 0x63, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, - 0x63, 0x73, 0x22, 0x5a, 0x0a, 0x15, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, - 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, - 0x69, 0x7a, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x61, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x22, 0xa2, - 0x02, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, - 0x73, 0x74, 0x69, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, - 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, - 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x6c, 0x69, - 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x4e, 0x0a, 0x07, 0x63, 0x6f, - 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x63, 0x63, - 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, - 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, - 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x47, 0x0a, 0x05, 0x6e, 0x6f, - 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x63, 0x2e, 0x61, - 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, - 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x05, 0x6e, 0x6f, - 0x74, 0x65, 0x73, 0x22, 0x74, 0x0a, 0x18, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, - 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x6c, 0x69, 0x6e, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x22, 0x71, 0x0a, 0x15, 0x43, 0x6f, 0x6d, + 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, + 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, + 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x5d, 0x0a, + 0x0e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x29, 0x0a, 0x10, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, + 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x50, 0x72, 0x6f, + 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x4f, 0x0a, 0x0b, 0x64, 0x69, 0x61, 0x67, 0x6e, + 0x6f, 0x73, 0x74, 0x69, 0x63, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, + 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x52, 0x0b, 0x64, 0x69, 0x61, + 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x73, 0x22, 0x5a, 0x0a, 0x15, 0x45, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x69, 0x7a, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x61, 0x78, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x61, 0x78, + 0x53, 0x69, 0x7a, 0x65, 0x22, 0xa2, 0x02, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, + 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, + 0x6d, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, + 0x12, 0x4e, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x34, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, + 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x12, 0x47, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x31, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x4e, 0x6f, - 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, - 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x42, 0x48, 0x5a, 0x46, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, - 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, - 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, - 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x74, 0x0a, 0x18, 0x43, 0x6f, 0x6d, + 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, + 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x22, + 0x71, 0x0a, 0x15, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, + 0x73, 0x74, 0x69, 0x63, 0x4e, 0x6f, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, + 0x6d, 0x6e, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, + 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1043,35 +1084,36 @@ func file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP() []byte { return file_cc_arduino_cli_commands_v1_compile_proto_rawDescData } -var file_cc_arduino_cli_commands_v1_compile_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_cc_arduino_cli_commands_v1_compile_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_cc_arduino_cli_commands_v1_compile_proto_goTypes = []interface{}{ - (*CompileRequest)(nil), // 0: cc.arduino.cli.commands.v1.CompileRequest - (*CompileResponse)(nil), // 1: cc.arduino.cli.commands.v1.CompileResponse - (*BuilderResult)(nil), // 2: cc.arduino.cli.commands.v1.BuilderResult - (*ExecutableSectionSize)(nil), // 3: cc.arduino.cli.commands.v1.ExecutableSectionSize - (*CompileDiagnostic)(nil), // 4: cc.arduino.cli.commands.v1.CompileDiagnostic - (*CompileDiagnosticContext)(nil), // 5: cc.arduino.cli.commands.v1.CompileDiagnosticContext - (*CompileDiagnosticNote)(nil), // 6: cc.arduino.cli.commands.v1.CompileDiagnosticNote - nil, // 7: cc.arduino.cli.commands.v1.CompileRequest.SourceOverrideEntry - (*Instance)(nil), // 8: cc.arduino.cli.commands.v1.Instance - (*wrapperspb.BoolValue)(nil), // 9: google.protobuf.BoolValue - (*TaskProgress)(nil), // 10: cc.arduino.cli.commands.v1.TaskProgress - (*Library)(nil), // 11: cc.arduino.cli.commands.v1.Library - (*InstalledPlatformReference)(nil), // 12: cc.arduino.cli.commands.v1.InstalledPlatformReference + (*CompileRequest)(nil), // 0: cc.arduino.cli.commands.v1.CompileRequest + (*CompileResponse)(nil), // 1: cc.arduino.cli.commands.v1.CompileResponse + (*InstanceNeedsReinitializationError)(nil), // 2: cc.arduino.cli.commands.v1.InstanceNeedsReinitializationError + (*BuilderResult)(nil), // 3: cc.arduino.cli.commands.v1.BuilderResult + (*ExecutableSectionSize)(nil), // 4: cc.arduino.cli.commands.v1.ExecutableSectionSize + (*CompileDiagnostic)(nil), // 5: cc.arduino.cli.commands.v1.CompileDiagnostic + (*CompileDiagnosticContext)(nil), // 6: cc.arduino.cli.commands.v1.CompileDiagnosticContext + (*CompileDiagnosticNote)(nil), // 7: cc.arduino.cli.commands.v1.CompileDiagnosticNote + nil, // 8: cc.arduino.cli.commands.v1.CompileRequest.SourceOverrideEntry + (*Instance)(nil), // 9: cc.arduino.cli.commands.v1.Instance + (*wrapperspb.BoolValue)(nil), // 10: google.protobuf.BoolValue + (*TaskProgress)(nil), // 11: cc.arduino.cli.commands.v1.TaskProgress + (*Library)(nil), // 12: cc.arduino.cli.commands.v1.Library + (*InstalledPlatformReference)(nil), // 13: cc.arduino.cli.commands.v1.InstalledPlatformReference } var file_cc_arduino_cli_commands_v1_compile_proto_depIdxs = []int32{ - 8, // 0: cc.arduino.cli.commands.v1.CompileRequest.instance:type_name -> cc.arduino.cli.commands.v1.Instance - 7, // 1: cc.arduino.cli.commands.v1.CompileRequest.source_override:type_name -> cc.arduino.cli.commands.v1.CompileRequest.SourceOverrideEntry - 9, // 2: cc.arduino.cli.commands.v1.CompileRequest.export_binaries:type_name -> google.protobuf.BoolValue - 10, // 3: cc.arduino.cli.commands.v1.CompileResponse.progress:type_name -> cc.arduino.cli.commands.v1.TaskProgress - 2, // 4: cc.arduino.cli.commands.v1.CompileResponse.result:type_name -> cc.arduino.cli.commands.v1.BuilderResult - 11, // 5: cc.arduino.cli.commands.v1.BuilderResult.used_libraries:type_name -> cc.arduino.cli.commands.v1.Library - 3, // 6: cc.arduino.cli.commands.v1.BuilderResult.executable_sections_size:type_name -> cc.arduino.cli.commands.v1.ExecutableSectionSize - 12, // 7: cc.arduino.cli.commands.v1.BuilderResult.board_platform:type_name -> cc.arduino.cli.commands.v1.InstalledPlatformReference - 12, // 8: cc.arduino.cli.commands.v1.BuilderResult.build_platform:type_name -> cc.arduino.cli.commands.v1.InstalledPlatformReference - 4, // 9: cc.arduino.cli.commands.v1.BuilderResult.diagnostics:type_name -> cc.arduino.cli.commands.v1.CompileDiagnostic - 5, // 10: cc.arduino.cli.commands.v1.CompileDiagnostic.context:type_name -> cc.arduino.cli.commands.v1.CompileDiagnosticContext - 6, // 11: cc.arduino.cli.commands.v1.CompileDiagnostic.notes:type_name -> cc.arduino.cli.commands.v1.CompileDiagnosticNote + 9, // 0: cc.arduino.cli.commands.v1.CompileRequest.instance:type_name -> cc.arduino.cli.commands.v1.Instance + 8, // 1: cc.arduino.cli.commands.v1.CompileRequest.source_override:type_name -> cc.arduino.cli.commands.v1.CompileRequest.SourceOverrideEntry + 10, // 2: cc.arduino.cli.commands.v1.CompileRequest.export_binaries:type_name -> google.protobuf.BoolValue + 11, // 3: cc.arduino.cli.commands.v1.CompileResponse.progress:type_name -> cc.arduino.cli.commands.v1.TaskProgress + 3, // 4: cc.arduino.cli.commands.v1.CompileResponse.result:type_name -> cc.arduino.cli.commands.v1.BuilderResult + 12, // 5: cc.arduino.cli.commands.v1.BuilderResult.used_libraries:type_name -> cc.arduino.cli.commands.v1.Library + 4, // 6: cc.arduino.cli.commands.v1.BuilderResult.executable_sections_size:type_name -> cc.arduino.cli.commands.v1.ExecutableSectionSize + 13, // 7: cc.arduino.cli.commands.v1.BuilderResult.board_platform:type_name -> cc.arduino.cli.commands.v1.InstalledPlatformReference + 13, // 8: cc.arduino.cli.commands.v1.BuilderResult.build_platform:type_name -> cc.arduino.cli.commands.v1.InstalledPlatformReference + 5, // 9: cc.arduino.cli.commands.v1.BuilderResult.diagnostics:type_name -> cc.arduino.cli.commands.v1.CompileDiagnostic + 6, // 10: cc.arduino.cli.commands.v1.CompileDiagnostic.context:type_name -> cc.arduino.cli.commands.v1.CompileDiagnosticContext + 7, // 11: cc.arduino.cli.commands.v1.CompileDiagnostic.notes:type_name -> cc.arduino.cli.commands.v1.CompileDiagnosticNote 12, // [12:12] is the sub-list for method output_type 12, // [12:12] is the sub-list for method input_type 12, // [12:12] is the sub-list for extension type_name @@ -1112,7 +1154,7 @@ func file_cc_arduino_cli_commands_v1_compile_proto_init() { } } file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BuilderResult); i { + switch v := v.(*InstanceNeedsReinitializationError); i { case 0: return &v.state case 1: @@ -1124,7 +1166,7 @@ func file_cc_arduino_cli_commands_v1_compile_proto_init() { } } file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExecutableSectionSize); i { + switch v := v.(*BuilderResult); i { case 0: return &v.state case 1: @@ -1136,7 +1178,7 @@ func file_cc_arduino_cli_commands_v1_compile_proto_init() { } } file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompileDiagnostic); i { + switch v := v.(*ExecutableSectionSize); i { case 0: return &v.state case 1: @@ -1148,7 +1190,7 @@ func file_cc_arduino_cli_commands_v1_compile_proto_init() { } } file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompileDiagnosticContext); i { + switch v := v.(*CompileDiagnostic); i { case 0: return &v.state case 1: @@ -1160,6 +1202,18 @@ func file_cc_arduino_cli_commands_v1_compile_proto_init() { } } file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CompileDiagnosticContext); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_cli_commands_v1_compile_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CompileDiagnosticNote); i { case 0: return &v.state @@ -1184,7 +1238,7 @@ func file_cc_arduino_cli_commands_v1_compile_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cc_arduino_cli_commands_v1_compile_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/rpc/cc/arduino/cli/commands/v1/compile.proto b/rpc/cc/arduino/cli/commands/v1/compile.proto index b53a124b6b8..67f003cf610 100644 --- a/rpc/cc/arduino/cli/commands/v1/compile.proto +++ b/rpc/cc/arduino/cli/commands/v1/compile.proto @@ -109,6 +109,8 @@ message CompileResponse { } } +message InstanceNeedsReinitializationError {} + message BuilderResult { // The compiler build path string build_path = 1; From 8d4b8203f1cfabe2b680fbc1210b5ab3740c1917 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 26 Feb 2024 12:03:14 +0100 Subject: [PATCH 4/7] Added integration test --- .../daemon/detect_core_changes_test.go | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 internal/integrationtest/daemon/detect_core_changes_test.go diff --git a/internal/integrationtest/daemon/detect_core_changes_test.go b/internal/integrationtest/daemon/detect_core_changes_test.go new file mode 100644 index 00000000000..a23e18fb76b --- /dev/null +++ b/internal/integrationtest/daemon/detect_core_changes_test.go @@ -0,0 +1,125 @@ +// This file is part of arduino-cli. +// +// Copyright 2022 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package daemon_test + +import ( + "context" + "errors" + "fmt" + "io" + "testing" + "time" + + "github.com/arduino/arduino-cli/internal/integrationtest" + "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" + "github.com/arduino/go-paths-helper" + + "github.com/stretchr/testify/require" +) + +func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { + // See: https://github.com/arduino/arduino-cli/issues/2523 + + env, cli := integrationtest.CreateEnvForDaemon(t) + defer env.CleanUp() + + // Create a new instance of the daemon + grpcInst := cli.Create() + require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { + fmt.Printf("INIT> %v\n", ir.GetMessage()) + })) + + // Install avr core + installCl, err := grpcInst.PlatformInstall(context.Background(), "arduino", "avr", "", true) + require.NoError(t, err) + for { + if installResp, err := installCl.Recv(); errors.Is(err, io.EOF) { + break + } else { + require.NoError(t, err) + fmt.Printf("INSTALL> %v\n", installResp) + } + } + installCl.CloseSend() + + // Run a compile + sketchPath, err := paths.New("testdata", "bare_minimum").Abs() + require.NoError(t, err) + tryCompile := func() error { + compileCl, err := grpcInst.Compile(context.Background(), "arduino:avr:uno", sketchPath.String(), "") + require.NoError(t, err) + defer compileCl.CloseSend() + for { + if compileResp, err := compileCl.Recv(); errors.Is(err, io.EOF) { + return nil + } else if err != nil { + return err + } else { + fmt.Printf("COMPILE> %v\n", compileResp) + } + } + } + require.NoError(t, tryCompile()) + + // Change a file in the AVR core and check if the change is detected + avrCorePath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6") + { + time.Sleep(time.Second) // await at least one second so the timestamp of the file is different + + f, err := avrCorePath.Join("boards.txt").Append() + require.NoError(t, err) + _, err = f.WriteString("\n") + require.NoError(t, err) + require.NoError(t, f.Close()) + } + err = tryCompile() + require.Error(t, err) + require.Contains(t, err.Error(), "The instance is no more valid and needs to be reinitialized") + + // Re-init instance and check again + require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { + fmt.Printf("INIT> %v\n", ir.GetMessage()) + })) + require.NoError(t, tryCompile()) + + // Delete a file and check if the change is detected + require.NoError(t, avrCorePath.Join("programmers.txt").Remove()) + err = tryCompile() + require.Error(t, err) + require.Contains(t, err.Error(), "The instance is no more valid and needs to be reinitialized") + + // Re-init instance and check again + require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { + fmt.Printf("INIT> %v\n", ir.GetMessage()) + })) + require.NoError(t, tryCompile()) + + // Create a file and check if the change is detected + { + f, err := avrCorePath.Join("programmers.txt").Create() + require.NoError(t, err) + require.NoError(t, f.Close()) + } + err = tryCompile() + require.Error(t, err) + require.Contains(t, err.Error(), "The instance is no more valid and needs to be reinitialized") + + // Re-init instance and check again + require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { + fmt.Printf("INIT> %v\n", ir.GetMessage()) + })) + require.NoError(t, tryCompile()) +} From a4f3a10bd2c2238c12971102523cd6d975fbb989 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 26 Feb 2024 12:15:38 +0100 Subject: [PATCH 5/7] Make linter happy --- .../integrationtest/daemon/detect_core_changes_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/integrationtest/daemon/detect_core_changes_test.go b/internal/integrationtest/daemon/detect_core_changes_test.go index a23e18fb76b..0c44636359d 100644 --- a/internal/integrationtest/daemon/detect_core_changes_test.go +++ b/internal/integrationtest/daemon/detect_core_changes_test.go @@ -46,12 +46,12 @@ func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { installCl, err := grpcInst.PlatformInstall(context.Background(), "arduino", "avr", "", true) require.NoError(t, err) for { - if installResp, err := installCl.Recv(); errors.Is(err, io.EOF) { + installResp, err := installCl.Recv() + if errors.Is(err, io.EOF) { break - } else { - require.NoError(t, err) - fmt.Printf("INSTALL> %v\n", installResp) } + require.NoError(t, err) + fmt.Printf("INSTALL> %v\n", installResp) } installCl.CloseSend() From 2f4afcecd990d7c047a1156e9108402dc275c8fa Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 26 Feb 2024 14:57:52 +0100 Subject: [PATCH 6/7] Fixed grammar --- commands/cmderrors/cmderrors.go | 2 +- internal/integrationtest/daemon/detect_core_changes_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/cmderrors/cmderrors.go b/commands/cmderrors/cmderrors.go index ef88f6a55c2..e6794ffdee9 100644 --- a/commands/cmderrors/cmderrors.go +++ b/commands/cmderrors/cmderrors.go @@ -875,7 +875,7 @@ type InstanceNeedsReinitialization struct { } func (e *InstanceNeedsReinitialization) Error() string { - return tr("The instance is no more valid and needs to be reinitialized") + return tr("The instance is no longer valid and needs to be reinitialized") } // ToRPCStatus converts the error into a *status.Status diff --git a/internal/integrationtest/daemon/detect_core_changes_test.go b/internal/integrationtest/daemon/detect_core_changes_test.go index 0c44636359d..ebf118ff4a0 100644 --- a/internal/integrationtest/daemon/detect_core_changes_test.go +++ b/internal/integrationtest/daemon/detect_core_changes_test.go @@ -87,7 +87,7 @@ func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { } err = tryCompile() require.Error(t, err) - require.Contains(t, err.Error(), "The instance is no more valid and needs to be reinitialized") + require.Contains(t, err.Error(), "The instance is no longer valid and needs to be reinitialized") // Re-init instance and check again require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { @@ -99,7 +99,7 @@ func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { require.NoError(t, avrCorePath.Join("programmers.txt").Remove()) err = tryCompile() require.Error(t, err) - require.Contains(t, err.Error(), "The instance is no more valid and needs to be reinitialized") + require.Contains(t, err.Error(), "The instance is no longer valid and needs to be reinitialized") // Re-init instance and check again require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { @@ -115,7 +115,7 @@ func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { } err = tryCompile() require.Error(t, err) - require.Contains(t, err.Error(), "The instance is no more valid and needs to be reinitialized") + require.Contains(t, err.Error(), "The instance is no longer valid and needs to be reinitialized") // Re-init instance and check again require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { From 185627b6de82be4c606b08b75512261bc1bc2398 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 26 Feb 2024 15:12:47 +0100 Subject: [PATCH 7/7] Test all monitored files --- .../daemon/detect_core_changes_test.go | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/internal/integrationtest/daemon/detect_core_changes_test.go b/internal/integrationtest/daemon/detect_core_changes_test.go index ebf118ff4a0..d7159240b78 100644 --- a/internal/integrationtest/daemon/detect_core_changes_test.go +++ b/internal/integrationtest/daemon/detect_core_changes_test.go @@ -55,7 +55,7 @@ func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { } installCl.CloseSend() - // Run a compile + // Utility functions: tryCompile sketchPath, err := paths.New("testdata", "bare_minimum").Abs() require.NoError(t, err) tryCompile := func() error { @@ -72,28 +72,39 @@ func TestDetectionOfChangesInCoreBeforeCompile(t *testing.T) { } } } - require.NoError(t, tryCompile()) - // Change a file in the AVR core and check if the change is detected - avrCorePath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6") - { + // Utility functions: tryTouch will touch a file and see if the compile detects the change + tryTouch := func(fileToTouch *paths.Path) { time.Sleep(time.Second) // await at least one second so the timestamp of the file is different - f, err := avrCorePath.Join("boards.txt").Append() + // touch the file + f, err := fileToTouch.Append() require.NoError(t, err) _, err = f.WriteString("\n") require.NoError(t, err) require.NoError(t, f.Close()) + + // try compile: should fail + err = tryCompile() + require.Error(t, err) + require.Contains(t, err.Error(), "The instance is no longer valid and needs to be reinitialized") + + // re-init instance + require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { + fmt.Printf("INIT> %v\n", ir.GetMessage()) + })) + + // try compile: should succeed + require.NoError(t, tryCompile()) } - err = tryCompile() - require.Error(t, err) - require.Contains(t, err.Error(), "The instance is no longer valid and needs to be reinitialized") - // Re-init instance and check again - require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { - fmt.Printf("INIT> %v\n", ir.GetMessage()) - })) - require.NoError(t, tryCompile()) + avrCorePath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6") + tryTouch(avrCorePath.Join("installed.json")) + tryTouch(avrCorePath.Join("platform.txt")) + tryTouch(avrCorePath.Join("platform.local.txt")) + tryTouch(avrCorePath.Join("programmers.txt")) + tryTouch(avrCorePath.Join("boards.txt")) + tryTouch(avrCorePath.Join("boards.local.txt")) // Delete a file and check if the change is detected require.NoError(t, avrCorePath.Join("programmers.txt").Remove())