Skip to content

Commit f593c89

Browse files
cmagliefacchinm
authored andcommitted
FileToRead field moved in Context
Signed-off-by: Cristian Maglie <[email protected]>
1 parent 44d686b commit f593c89

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

Diff for: src/arduino.cc/builder/constants/constants.go

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ const BUILD_PROPERTIES_SOURCE_PATH = "build.source.path"
7373
const BUILD_PROPERTIES_TOOLS_KEY = "tools"
7474
const BUILD_PROPERTIES_VID = "vid"
7575
const CTAGS = "ctags"
76-
const CTX_FILE_PATH_TO_READ = "filePathToRead"
7776
const CTX_INCLUDE_SECTION = "includeSection"
7877
const CTX_INCLUDES_JUST_FOUND = "includesJustFound"
7978
const CTX_LINE_OFFSET = "lineOffset"

Diff for: src/arduino.cc/builder/gcc_preproc_runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}, ctx *types.Contex
6464
return i18n.WrapError(err)
6565
}
6666

67-
context[constants.CTX_FILE_PATH_TO_READ] = targetFilePath
67+
ctx.FileToRead = targetFilePath
6868

6969
return nil
7070
}

Diff for: src/arduino.cc/builder/read_file_and_store_in_context.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
package builder
3131

3232
import (
33-
"arduino.cc/builder/constants"
3433
"arduino.cc/builder/i18n"
3534
"arduino.cc/builder/types"
3635
"io/ioutil"
@@ -41,7 +40,7 @@ type ReadFileAndStoreInContext struct {
4140
}
4241

4342
func (s *ReadFileAndStoreInContext) Run(context map[string]interface{}, ctx *types.Context) error {
44-
bytes, err := ioutil.ReadFile(context[constants.CTX_FILE_PATH_TO_READ].(string))
43+
bytes, err := ioutil.ReadFile(ctx.FileToRead)
4544
if err != nil {
4645
return i18n.WrapError(err)
4746
}

Diff for: src/arduino.cc/builder/test/read_file_and_store_in_context_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ package test
3131

3232
import (
3333
"arduino.cc/builder"
34-
"arduino.cc/builder/constants"
3534
"arduino.cc/builder/types"
3635
"arduino.cc/builder/utils"
3736
"github.com/stretchr/testify/require"
@@ -49,7 +48,7 @@ func TestReadFileAndStoreInContext(t *testing.T) {
4948

5049
context := make(map[string]interface{})
5150
ctx := &types.Context{}
52-
context[constants.CTX_FILE_PATH_TO_READ] = file.Name()
51+
ctx.FileToRead = file.Name()
5352

5453
command := &builder.ReadFileAndStoreInContext{Target: &ctx.SourceGccMinusE}
5554
err = command.Run(context, ctx)

Diff for: src/arduino.cc/builder/types/context.go

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ type Context struct {
8282
logger i18n.Logger
8383
DebugLevel int
8484

85+
// ReadFileAndStoreInContext command
86+
FileToRead string
87+
8588
// For now it is used in conjunction with the old map[string]string, but
8689
// it will be slowly populated with all the fields currently used in the
8790
// map in the next commits.

0 commit comments

Comments
 (0)