|
| 1 | +package compile |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/arduino/arduino-cli/internal/integrationtest" |
| 7 | + "github.com/arduino/go-paths-helper" |
| 8 | + "github.com/stretchr/testify/require" |
| 9 | +) |
| 10 | + |
| 11 | +func TestBuildCacheLibWithNonASCIIChars(t *testing.T) { |
| 12 | + // See: https://github.com/arduino/arduino-cli/issues/2671 |
| 13 | + |
| 14 | + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
| 15 | + t.Cleanup(env.CleanUp) |
| 16 | + |
| 17 | + tmpUserDir, err := paths.MkTempDir("", "Håkan") |
| 18 | + require.NoError(t, err) |
| 19 | + t.Cleanup(func() { tmpUserDir.RemoveAll() }) |
| 20 | + customEnv := cli.GetDefaultEnv() |
| 21 | + customEnv["ARDUINO_DIRECTORIES_USER"] = tmpUserDir.String() |
| 22 | + |
| 23 | + // Install Arduino AVR Boards and Servo lib |
| 24 | + _, _, err = cli. Run( "core", "install", "arduino:[email protected]") |
| 25 | + require.NoError(t, err) |
| 26 | + _, _, err = cli.RunWithCustomEnv(customEnv, "lib", "install", "Servo") |
| 27 | + require.NoError(t, err) |
| 28 | + |
| 29 | + // Make a temp sketch |
| 30 | + sketchDir := tmpUserDir.Join("ServoSketch") |
| 31 | + sketchFile := sketchDir.Join("ServoSketch.ino") |
| 32 | + require.NoError(t, sketchDir.Mkdir()) |
| 33 | + require.NoError(t, sketchFile.WriteFile( |
| 34 | + []byte("#include <Servo.h>\nvoid setup() {}\nvoid loop() {}\n"), |
| 35 | + )) |
| 36 | + |
| 37 | + // Compile sketch |
| 38 | + _, _, err = cli.RunWithCustomEnv(customEnv, "compile", "-b", "arduino:avr:uno", sketchFile.String()) |
| 39 | + require.NoError(t, err) |
| 40 | + |
| 41 | + // Compile sketch again |
| 42 | + out, _, err := cli.RunWithCustomEnv(customEnv, "compile", "-b", "arduino:avr:uno", "-v", sketchFile.String()) |
| 43 | + require.NoError(t, err) |
| 44 | + require.Contains(t, string(out), "Compiling library \"Servo\"\nUsing previously compiled file") |
| 45 | +} |
0 commit comments