Skip to content

Commit d81e4a5

Browse files
committed
fix: fix file tests
1 parent 75de4a8 commit d81e4a5

12 files changed

Lines changed: 162 additions & 114 deletions

File tree

SCC-OUTPUT-REPORT.html

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
<tbody><tr>
1414
<th>Go</th>
1515
<th>34</th>
16-
<th>27374</th>
17-
<th>1796</th>
18-
<th>614</th>
19-
<th>24964</th>
20-
<th>2018</th>
21-
<th>558764</th>
22-
<th>8190</th>
16+
<th>27608</th>
17+
<th>1829</th>
18+
<th>633</th>
19+
<th>25146</th>
20+
<th>2080</th>
21+
<th>564680</th>
22+
<th>8285</th>
2323
</tr><tr>
2424
<td>processor/constants.go</td>
2525
<td></td>
@@ -63,33 +63,33 @@
6363
</tr><tr>
6464
<td>main_test.go</td>
6565
<td></td>
66-
<td>890</td>
67-
<td>70</td>
68-
<td>15</td>
69-
<td>805</td>
70-
<td>228</td>
71-
<td>21740</td>
72-
<td>471</td>
66+
<td>943</td>
67+
<td>76</td>
68+
<td>17</td>
69+
<td>850</td>
70+
<td>250</td>
71+
<td>23270</td>
72+
<td>493</td>
7373
</tr><tr>
7474
<td>processor/workers.go</td>
7575
<td></td>
7676
<td>866</td>
7777
<td>128</td>
7878
<td>92</td>
7979
<td>646</td>
80-
<td>213</td>
81-
<td>26343</td>
82-
<td>505</td>
80+
<td>212</td>
81+
<td>26321</td>
82+
<td>504</td>
8383
</tr><tr>
8484
<td>processor/processor.go</td>
8585
<td></td>
86-
<td>749</td>
86+
<td>750</td>
8787
<td>159</td>
8888
<td>123</td>
89-
<td>467</td>
89+
<td>468</td>
9090
<td>89</td>
91-
<td>21834</td>
92-
<td>495</td>
91+
<td>21855</td>
92+
<td>496</td>
9393
</tr><tr>
9494
<td>cmd/badges/main.go</td>
9595
<td></td>
@@ -130,6 +130,16 @@
130130
<td>57</td>
131131
<td>12733</td>
132132
<td>293</td>
133+
</tr><tr>
134+
<td>processor/file_test.go</td>
135+
<td></td>
136+
<td>335</td>
137+
<td>66</td>
138+
<td>13</td>
139+
<td>256</td>
140+
<td>67</td>
141+
<td>7741</td>
142+
<td>154</td>
133143
</tr><tr>
134144
<td>cmd/badges/main_test.go</td>
135145
<td></td>
@@ -150,6 +160,16 @@
150160
<td>68</td>
151161
<td>7503</td>
152162
<td>131</td>
163+
</tr><tr>
164+
<td>processor/workers_regression_test.go</td>
165+
<td></td>
166+
<td>249</td>
167+
<td>49</td>
168+
<td>7</td>
169+
<td>193</td>
170+
<td>50</td>
171+
<td>4794</td>
172+
<td>121</td>
153173
</tr><tr>
154174
<td>processor/workers_tokei_test.go</td>
155175
<td></td>
@@ -180,26 +200,6 @@
180200
<td>53</td>
181201
<td>6269</td>
182202
<td>151</td>
183-
</tr><tr>
184-
<td>processor/file_test.go</td>
185-
<td></td>
186-
<td>213</td>
187-
<td>50</td>
188-
<td>1</td>
189-
<td>162</td>
190-
<td>37</td>
191-
<td>4585</td>
192-
<td>97</td>
193-
</tr><tr>
194-
<td>processor/workers_regression_test.go</td>
195-
<td></td>
196-
<td>212</td>
197-
<td>42</td>
198-
<td>5</td>
199-
<td>165</td>
200-
<td>42</td>
201-
<td>4015</td>
202-
<td>105</td>
203203
</tr><tr>
204204
<td>processor/similar_flags_test.go</td>
205205
<td></td>
@@ -210,6 +210,16 @@
210210
<td>5</td>
211211
<td>3105</td>
212212
<td>78</td>
213+
</tr><tr>
214+
<td>processor/file.go</td>
215+
<td></td>
216+
<td>173</td>
217+
<td>27</td>
218+
<td>19</td>
219+
<td>127</td>
220+
<td>46</td>
221+
<td>3958</td>
222+
<td>106</td>
213223
</tr><tr>
214224
<td>processor/locomo.go</td>
215225
<td></td>
@@ -230,16 +240,6 @@
230240
<td>22</td>
231241
<td>2741</td>
232242
<td>70</td>
233-
</tr><tr>
234-
<td>processor/file.go</td>
235-
<td></td>
236-
<td>153</td>
237-
<td>23</td>
238-
<td>16</td>
239-
<td>114</td>
240-
<td>43</td>
241-
<td>3527</td>
242-
<td>94</td>
243243
</tr><tr>
244244
<td>processor/structs_test.go</td>
245245
<td></td>
@@ -253,13 +253,13 @@
253253
</tr><tr>
254254
<td>processor/result.go</td>
255255
<td></td>
256-
<td>136</td>
256+
<td>137</td>
257257
<td>24</td>
258258
<td>3</td>
259-
<td>109</td>
259+
<td>110</td>
260260
<td>31</td>
261-
<td>3226</td>
262-
<td>91</td>
261+
<td>3247</td>
262+
<td>92</td>
263263
</tr><tr>
264264
<td>processor/trace_test.go</td>
265265
<td></td>
@@ -320,16 +320,6 @@
320320
<td>0</td>
321321
<td>2209</td>
322322
<td>35</td>
323-
</tr><tr>
324-
<td>processor/cocomo_test.go</td>
325-
<td></td>
326-
<td>37</td>
327-
<td>8</td>
328-
<td>4</td>
329-
<td>25</td>
330-
<td>6</td>
331-
<td>686</td>
332-
<td>23</td>
333323
</tr><tr>
334324
<td>processor/bloom.go</td>
335325
<td></td>
@@ -340,6 +330,16 @@
340330
<td>2</td>
341331
<td>1062</td>
342332
<td>29</td>
333+
</tr><tr>
334+
<td>processor/cocomo_test.go</td>
335+
<td></td>
336+
<td>37</td>
337+
<td>8</td>
338+
<td>4</td>
339+
<td>25</td>
340+
<td>6</td>
341+
<td>686</td>
342+
<td>23</td>
343343
</tr><tr>
344344
<td>processor/helpers_test.go</td>
345345
<td></td>
@@ -364,15 +364,15 @@
364364
<tfoot><tr>
365365
<th>Total</th>
366366
<th>34</th>
367-
<th>27374</th>
368-
<th>1796</th>
369-
<th>614</th>
370-
<th>24964</th>
371-
<th>2018</th>
372-
<th>558764</th>
373-
<th>8190</th>
367+
<th>27608</th>
368+
<th>1829</th>
369+
<th>633</th>
370+
<th>25146</th>
371+
<th>2080</th>
372+
<th>564680</th>
373+
<th>8285</th>
374374
</tr>
375375
<tr>
376-
<th colspan="9">Estimated Cost to Develop (organic) $792,091<br>Estimated Schedule Effort (organic) 12.59 months<br>Estimated People Required (organic) 5.59<br></th>
376+
<th colspan="9">Estimated Cost to Develop (organic) $798,155<br>Estimated Schedule Effort (organic) 12.62 months<br>Estimated People Required (organic) 5.62<br></th>
377377
</tr></tfoot>
378378
</table></body></html>

examples/symlink/link.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/symlink/link2.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/symlink/link3.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/symlink/link4.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/symlink/test.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

main_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os/exec"
77
"path/filepath"
88
"regexp"
9+
"runtime"
910
"slices"
1011
"strconv"
1112
"strings"
@@ -721,6 +722,58 @@ func TestFileGCCount(t *testing.T) {
721722
}
722723
}
723724

725+
func TestIncludeSymlinks(t *testing.T) {
726+
if runtime.GOOS == "windows" {
727+
t.Skip("skipping symlink test on Windows due to privilege requirements")
728+
}
729+
730+
tmpDir, err := filepath.EvalSymlinks(t.TempDir())
731+
if err != nil {
732+
t.Fatal(err)
733+
}
734+
735+
dirA := filepath.Join(tmpDir, "a")
736+
dirB := filepath.Join(tmpDir, "b")
737+
if err := os.Mkdir(dirA, 0755); err != nil {
738+
t.Fatal(err)
739+
}
740+
if err := os.Mkdir(dirB, 0755); err != nil {
741+
t.Fatal(err)
742+
}
743+
744+
const fileName = "source.go"
745+
if err := os.WriteFile(filepath.Join(dirA, fileName), []byte("package main\n"), 0644); err != nil {
746+
t.Fatal(err)
747+
}
748+
if err := os.WriteFile(filepath.Join(dirB, fileName), []byte("package main\n"), 0644); err != nil {
749+
t.Fatal(err)
750+
}
751+
// link to another dir, should be counted under --include-symlinks
752+
if err := os.Symlink(filepath.Join(dirB, fileName), filepath.Join(dirA, "link1.go")); err != nil {
753+
t.Fatal(err)
754+
}
755+
// link to the same dir, this should be ignored in all times
756+
if err := os.Symlink(filepath.Join(dirA, fileName), filepath.Join(dirA, "link2.go")); err != nil {
757+
t.Fatal(err)
758+
}
759+
760+
output, err := runSCC("-f", "json", "--no-scc-ignore", dirA)
761+
if err != nil {
762+
t.Fatal(err)
763+
}
764+
if !strings.Contains(output, `"Count":1`) {
765+
t.Errorf("count without symlink failed, output:\n%s", output)
766+
}
767+
768+
output, err = runSCC("-f", "json", "--no-scc-ignore", "--include-symlinks", dirA)
769+
if err != nil {
770+
t.Fatal(err)
771+
}
772+
if !strings.Contains(output, `"Count":2`) {
773+
t.Errorf("count includes symlink failed, output:\n%s", output)
774+
}
775+
}
776+
724777
func TestLanguageNameTruncate(t *testing.T) {
725778
output, err := runSCC("examples/language")
726779
if err != nil {

processor/file.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func getExtension(name string) string {
4444
return extension.(string)
4545
}
4646

47+
func cleanVisitedPaths() {
48+
visitedPaths.Clear()
49+
}
50+
4751
func newFileJob(path, name string, fileInfo os.FileInfo) *FileJob {
4852
if NoLarge {
4953
if fileInfo.Size() >= LargeByteCount {

0 commit comments

Comments
 (0)