Skip to content

Commit a3f6574

Browse files
[skip-changelog] Migrate tests from test_profiles.py to profiles_test.go (#1858)
* Migrate TestCompileWithProfiles from test_profiles.py to profiles_test.go * Migrate TestBuilderDidNotCatchLibsFromUnusedPlatforms to profiles_test.go and delete test_profiles.py
1 parent 87d2efa commit a3f6574

File tree

5 files changed

+71
-49
lines changed

5 files changed

+71
-49
lines changed

Diff for: internal/integrationtest/profiles/profiles_test.go

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package profiles_test
17+
18+
import (
19+
"testing"
20+
21+
"github.com/arduino/arduino-cli/internal/integrationtest"
22+
"github.com/stretchr/testify/require"
23+
)
24+
25+
func TestCompileWithProfiles(t *testing.T) {
26+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
27+
defer env.CleanUp()
28+
29+
// Init the environment explicitly
30+
_, _, err := cli.Run("core", "update-index")
31+
require.NoError(t, err)
32+
33+
// copy sketch_with_profile into the working directory
34+
sketchPath := cli.CopySketch("sketch_with_profile")
35+
36+
// use profile without a required library -> should fail
37+
_, _, err = cli.Run("lib", "install", "Arduino_JSON")
38+
require.NoError(t, err)
39+
_, _, err = cli.Run("compile", "-m", "avr1", sketchPath.String())
40+
require.Error(t, err)
41+
42+
// use profile with the required library -> should succeed
43+
_, _, err = cli.Run("compile", "-m", "avr2", sketchPath.String())
44+
require.NoError(t, err)
45+
}
46+
47+
func TestBuilderDidNotCatchLibsFromUnusedPlatforms(t *testing.T) {
48+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
49+
defer env.CleanUp()
50+
51+
// Init the environment explicitly
52+
_, _, err := cli.Run("core", "update-index")
53+
require.NoError(t, err)
54+
55+
// copy sketch into the working directory
56+
sketchPath := cli.CopySketch("sketch_with_error_including_wire")
57+
58+
// install two platforms with the Wire library bundled
59+
_, _, err = cli.Run("core", "install", "arduino:avr")
60+
require.NoError(t, err)
61+
_, _, err = cli.Run("core", "install", "arduino:samd")
62+
require.NoError(t, err)
63+
64+
// compile for AVR
65+
stdout, stderr, err := cli.Run("compile", "-b", "arduino:avr:uno", sketchPath.String())
66+
require.Error(t, err)
67+
68+
// check that the libary resolver did not take the SAMD bundled Wire library into account
69+
require.NotContains(t, string(stdout), "samd")
70+
require.NotContains(t, string(stderr), "samd")
71+
}

Diff for: test/test_profiles.py

-49
This file was deleted.

0 commit comments

Comments
 (0)