Skip to content

Commit 415c711

Browse files
committed
Fixed unit tests
Previously the unit tests were creating the wrong env to test: internal/arduino/libraries/testdata/TestLib ├── examples │   ├── UpGoer1 -> testdata/TestLib │   └── UpGoer2 -> testdata/TestLib ├── library.properties └── src └── TestLib.h The two UpGoer1 and UpGoer2 are broken links. The correct tree is the following: internal/arduino/libraries/testdata/TestLib ├── examples │   ├── UpGoer1 -> .. │   └── UpGoer2 -> .. ├── library.properties └── src └── TestLib.h that actually triggers the symlink loop we are testing.
1 parent 2d15bc8 commit 415c711

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: internal/arduino/libraries/libraries_test.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ func TestLibrariesLoader(t *testing.T) {
9595
func TestSymlinkLoop(t *testing.T) {
9696
// Set up directory structure of test library.
9797
testLib := paths.New("testdata", "TestLib")
98-
examplesPath := testLib.Join("examples")
98+
examplesPath, err := testLib.Join("examples").Abs()
99+
require.NoError(t, err)
99100
require.NoError(t, examplesPath.Mkdir())
100101
defer examplesPath.RemoveAll()
101102

102103
// It's probably most friendly for contributors using Windows to create the symlinks needed for the test on demand.
103-
err := os.Symlink(examplesPath.Join("..").String(), examplesPath.Join("UpGoer1").String())
104+
err = os.Symlink(examplesPath.String(), examplesPath.Join("UpGoer1").String())
104105
require.NoError(t, err, "This test must be run as administrator on Windows to have symlink creation privilege.")
105106
// It's necessary to have multiple symlinks to a parent directory to create the loop.
106-
err = os.Symlink(examplesPath.Join("..").String(), examplesPath.Join("UpGoer2").String())
107+
err = os.Symlink(examplesPath.String(), examplesPath.Join("UpGoer2").String())
107108
require.NoError(t, err)
108109

109110
// The failure condition is Load() never returning, testing for which requires setting up a timeout.
@@ -123,15 +124,16 @@ func TestSymlinkLoop(t *testing.T) {
123124
func TestLegacySymlinkLoop(t *testing.T) {
124125
// Set up directory structure of test library.
125126
testLib := paths.New("testdata", "LegacyLib")
126-
examplesPath := testLib.Join("examples")
127+
examplesPath, err := testLib.Join("examples").Abs()
128+
require.NoError(t, err)
127129
require.NoError(t, examplesPath.Mkdir())
128130
defer examplesPath.RemoveAll()
129131

130132
// It's probably most friendly for contributors using Windows to create the symlinks needed for the test on demand.
131-
err := os.Symlink(examplesPath.Join("..").String(), examplesPath.Join("UpGoer1").String())
133+
err = os.Symlink(examplesPath.String(), examplesPath.Join("UpGoer1").String())
132134
require.NoError(t, err, "This test must be run as administrator on Windows to have symlink creation privilege.")
133135
// It's necessary to have multiple symlinks to a parent directory to create the loop.
134-
err = os.Symlink(examplesPath.Join("..").String(), examplesPath.Join("UpGoer2").String())
136+
err = os.Symlink(examplesPath.String(), examplesPath.Join("UpGoer2").String())
135137
require.NoError(t, err)
136138

137139
// The failure condition is Load() never returning, testing for which requires setting up a timeout.

0 commit comments

Comments
 (0)