|
| 1 | +/* |
| 2 | + * This file is part of Arduino Builder. |
| 3 | + * |
| 4 | + * Arduino Builder is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program; if not, write to the Free Software |
| 16 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | + * |
| 18 | + * As a special exception, you may use this file as part of a free software |
| 19 | + * library without restriction. Specifically, if other files instantiate |
| 20 | + * templates or use macros or inline functions from this file, or you compile |
| 21 | + * this file and link it with other files to produce an executable, this |
| 22 | + * file does not by itself cause the resulting executable to be covered by |
| 23 | + * the GNU General Public License. This exception does not however |
| 24 | + * invalidate any other reasons why the executable file might be covered by |
| 25 | + * the GNU General Public License. |
| 26 | + * |
| 27 | + * Copyright 2015 Arduino LLC (http://www.arduino.cc/) |
| 28 | + */ |
| 29 | + |
| 30 | +package test |
| 31 | + |
| 32 | +import ( |
| 33 | + "arduino.cc/builder" |
| 34 | + "arduino.cc/builder/constants" |
| 35 | + "github.com/stretchr/testify/require" |
| 36 | + "path/filepath" |
| 37 | + "testing" |
| 38 | +) |
| 39 | + |
| 40 | +func TestAddAdditionalEntriesToContextNoBuildPath(t *testing.T) { |
| 41 | + context := make(map[string]interface{}) |
| 42 | + |
| 43 | + command := builder.AddAdditionalEntriesToContext{} |
| 44 | + NoError(t, command.Run(context)) |
| 45 | + |
| 46 | + require.Nil(t, context[constants.CTX_PREPROC_PATH]) |
| 47 | + require.Nil(t, context[constants.CTX_SKETCH_BUILD_PATH]) |
| 48 | + require.Nil(t, context[constants.CTX_LIBRARIES_BUILD_PATH]) |
| 49 | + require.Nil(t, context[constants.CTX_CORE_BUILD_PATH]) |
| 50 | + |
| 51 | + require.NotNil(t, context[constants.CTX_WARNINGS_LEVEL]) |
| 52 | + require.NotNil(t, context[constants.CTX_VERBOSE]) |
| 53 | + require.NotNil(t, context[constants.CTX_DEBUG_LEVEL]) |
| 54 | +} |
| 55 | + |
| 56 | +func TestAddAdditionalEntriesToContextWithBuildPath(t *testing.T) { |
| 57 | + context := make(map[string]interface{}) |
| 58 | + |
| 59 | + context[constants.CTX_BUILD_PATH] = "folder" |
| 60 | + |
| 61 | + command := builder.AddAdditionalEntriesToContext{} |
| 62 | + NoError(t, command.Run(context)) |
| 63 | + |
| 64 | + require.Equal(t, Abs(t, filepath.Join("folder", constants.FOLDER_PREPROC)), context[constants.CTX_PREPROC_PATH]) |
| 65 | + require.Equal(t, Abs(t, filepath.Join("folder", constants.FOLDER_SKETCH)), context[constants.CTX_SKETCH_BUILD_PATH]) |
| 66 | + require.Equal(t, Abs(t, filepath.Join("folder", constants.FOLDER_LIBRARIES)), context[constants.CTX_LIBRARIES_BUILD_PATH]) |
| 67 | + require.Equal(t, Abs(t, filepath.Join("folder", constants.FOLDER_CORE)), context[constants.CTX_CORE_BUILD_PATH]) |
| 68 | + |
| 69 | + require.NotNil(t, context[constants.CTX_WARNINGS_LEVEL]) |
| 70 | + require.NotNil(t, context[constants.CTX_VERBOSE]) |
| 71 | + require.NotNil(t, context[constants.CTX_DEBUG_LEVEL]) |
| 72 | +} |
0 commit comments