Skip to content

Commit 0bcb021

Browse files
Migrated TestCompileWithProfiles from test_profiles.py to profiles_test.go
1 parent 736608f commit 0bcb021

File tree

4 files changed

+53
-16
lines changed

4 files changed

+53
-16
lines changed

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

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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/arduino/go-paths-helper"
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func TestCompileWithProfiles(t *testing.T) {
27+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
28+
defer env.CleanUp()
29+
30+
// Init the environment explicitly
31+
_, _, err := cli.Run("core", "update-index")
32+
require.NoError(t, err)
33+
34+
// copy sketch_with_profile into the working directory
35+
sketchName := "sketch_with_profile"
36+
p, err := paths.Getwd()
37+
require.NoError(t, err)
38+
require.NotNil(t, p)
39+
testSketch := p.Parent().Join("testdata", sketchName)
40+
sketchPath := cli.SketchbookDir().Join(sketchName)
41+
err = testSketch.CopyDirTo(sketchPath)
42+
require.NoError(t, err)
43+
44+
// use profile without a required library -> should fail
45+
_, _, err = cli.Run("lib", "install", "Arduino_JSON")
46+
require.NoError(t, err)
47+
_, _, err = cli.Run("compile", "-m", "avr1", sketchPath.String())
48+
require.Error(t, err)
49+
50+
// use profile with the required library -> should succeed
51+
_, _, err = cli.Run("compile", "-m", "avr2", sketchPath.String())
52+
require.NoError(t, err)
53+
}

Diff for: test/test_profiles.py

-16
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@
1414
# a commercial license, send an email to [email protected].
1515

1616

17-
def test_compile_with_profiles(run_command, copy_sketch):
18-
# Init the environment explicitly
19-
run_command(["core", "update-index"])
20-
21-
sketch_path = copy_sketch("sketch_with_profile")
22-
23-
# use profile without a required library -> should fail
24-
assert run_command(["lib", "install", "Arduino_JSON"])
25-
result = run_command(["compile", "-m", "avr1", sketch_path])
26-
assert result.failed
27-
28-
# use profile with the required library -> should succeed
29-
result = run_command(["compile", "-m", "avr2", sketch_path])
30-
assert result.ok
31-
32-
3317
def test_builder_did_not_catch_libs_from_unused_platforms(run_command, copy_sketch):
3418
# Init the environment explicitly
3519
run_command(["core", "update-index"])

0 commit comments

Comments
 (0)