-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
test-all.sh
executable file
·1128 lines (1018 loc) · 36.6 KB
/
test-all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# make sure this script can be executed from any dir
cd $(dirname $0)
GREEN='\033[1;32m'
RED='\033[0;31m'
NC='\033[0m'
echo "Running go generate..."
go generate
echo "Running go fmt..."
go fmt ./...
echo "Running unit tests..."
go test ./... || exit
# Race Detection
echo "Running race detection..."
if go run --race . 2>&1 >/dev/null | grep -q "Found" ; then
echo -e "${RED}======================================================="
echo -e "FAILED race detection run 'go run --race .' to identify"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED race detection${NC}"
fi
echo "Building application..."
go build -ldflags="-s -w" || exit
echo '```' > LANGUAGES.md
./scc --languages >> LANGUAGES.md
echo '```' >> LANGUAGES.md
echo "Running with @file flag parsing syntax"
# include \n, \r\n and no line terminators
echo -e "go.mod\ngo.sum\r\nLICENSE" > flags.txt
if ./scc @flags.txt ; then
echo -e "${GREEN}PASSED @file flag syntax"
# post processing
rm flags.txt
else
echo -e "${RED}======================================================="
echo -e "FAILED Should handle @file flag parsing syntax"
echo -e "=======================================================${NC}"
# post processing
rm flags.txt
exit
fi
echo "Building HTML report..."
./scc --format html -a --by-file -i go -o SCC-OUTPUT-REPORT.html
echo "Running integration tests..."
if ./scc --not-a-real-option > /dev/null ; then
echo -e "${RED}================================================="
echo -e "FAILED Invalid option should produce error code "
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED invalid option test"
fi
## NB you need to have pyyaml installed via pip install pyyaml for this to work
#if ./scc "examples/language/" --format cloc-yaml -o .tmp_scc_yaml >/dev/null && python <<EOS
#import yaml,sys
#try:
# with open('.tmp_scc_yaml','r') as f:
# data = yaml.load(f.read())
# if type(data) is dict and data.keys():
# sys.exit(0)
# else:
# print('data was {}'.format(type(data)))
#except Exception as e:
# pass
#sys.exit(1)
#EOS
#
#then
# echo -e "${GREEN}PASSED cloc-yaml format test"
#else
# echo -e "${RED}======================================================="
# echo -e "${RED}FAILED Should accept --format cloc-yaml and should generate valid output"
# echo -e "=======================================================${NC}"
# rm -f .tmp_scc_yaml
# exit
#fi
#
#if ./scc "examples/language/" --format cloc-yml -o .tmp_scc_yaml >/dev/null && python <<EOS
#import yaml,sys
#try:
# with open('.tmp_scc_yaml','r') as f:
# data = yaml.load(f.read())
# if type(data) is dict and data.keys():
# sys.exit(0)
# else:
# print('data was {}'.format(type(data)))
#except Exception as e:
# pass
#sys.exit(1)
#EOS
#
#then
# echo -e "${GREEN}PASSED cloc-yml format test"
#else
# echo -e "${RED}======================================================="
# echo -e "${RED}FAILED Should accept --format cloc-yml and should generate valid output"
# echo -e "=======================================================${NC}"
# rm -f .tmp_scc_yaml
# exit
#fi
if ./scc NOTAREALDIRECTORYORFILE > /dev/null ; then
echo -e "${RED}================================================="
echo -e "FAILED Invalid file/directory should produce error code "
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED invalid file/directory test"
fi
if ./scc > /dev/null ; then
echo -e "${GREEN}PASSED no directory specified test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should run correctly with no directory specified"
echo -e "=======================================================${NC}"
exit
fi
if ./scc processor > /dev/null ; then
echo -e "${GREEN}PASSED directory specified test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should run correctly with directory specified"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --avg-wage 10000 --binary --by-file --no-cocomo --no-size --size-unit si --include-symlinks --debug --exclude-dir .git -f tabular -i go -c -d -M something -s name -w processor > /dev/null ; then
echo -e "${GREEN}PASSED multiple options test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should run correctly with multiple options"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -i sh -M "vendor|examples|p.*" > /dev/null ; then
echo -e "${GREEN}PASSED regular expression ignore test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should run with regular expression ignore"
echo -e "=======================================================${NC}"
exit
fi
if ./scc "examples/shared_extension/" | grep -q "Coq"; then
echo -e "${GREEN}PASSED shared extension test 1"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to work with shared extension 1"
echo -e "=======================================================${NC}"
exit
fi
if ./scc "examples/shared_extension/" | grep -q "Verilog"; then
echo -e "${GREEN}PASSED shared extension test 2"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to work with shared extension 2"
echo -e "=======================================================${NC}"
exit
fi
if ./scc "examples/shared_extension/" | grep -q "V "; then
echo -e "${GREEN}PASSED shared extension test 3"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to work with shared extension 3"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --ci | grep -q "\-\-\-\-"; then
echo -e "${GREEN}PASSED ci param test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to work with ci flag"
echo -e "=======================================================${NC}"
exit
fi
if ./scc "examples/denylist/" | grep -q "Java"; then
echo -e "${RED}======================================================="
echo -e "FAILED Should hit default .git denylist "
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED denylist test"
fi
# Simple test to see if we get any concurrency issues
for i in {1..100}
do
if ./scc > /dev/null ; then
:
else
echo -e "${RED}======================================================="
echo -e "FAILED Should not have concurrency issue"
echo -e "=================================================${NC}"
exit
fi
done
echo -e "${GREEN}PASSED concurrency issue test"
if ./scc main.go > /dev/null ; then
echo -e "${GREEN}PASSED file specified test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should run correctly with a file is specified"
echo -e "=================================================${NC}"
exit
fi
# Multiple directory or file arguments
if ./scc main.go README.md | grep -q "Go " ; then
echo -e "${GREEN}PASSED multiple file argument test 1"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should work with multiple file arguments 1"
echo -e "=======================================================${NC}"
exit
fi
if ./scc main.go README.md | grep -q "Markdown " ; then
echo -e "${GREEN}PASSED multiple file argument test 2"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should work with multiple file arguments 2"
echo -e "=======================================================${NC}"
exit
fi
if ./scc processor scripts > /dev/null ; then
echo -e "${GREEN}PASSED multiple directory specified test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should run correctly with multiple directory specified"
echo -e "=================================================${NC}"
exit
fi
# Try out duplicates
for i in {1..100}
do
if ./scc -d "examples/duplicates/" | grep -e "Java" | grep -q -e " 1 "; then
:
else
echo -e "${RED}======================================================="
echo -e "FAILED Duplicates should be consistent"
echo -e "=======================================================${NC}"
exit
fi
done
echo -e "${GREEN}PASSED duplicates test"
# Ensure deterministic output
a=$(./scc .)
for i in {1..100}
do
b=$(./scc .)
if [ "$a" == "$b" ]; then
:
else
echo -e "${RED}======================================================="
echo -e "FAILED Runs should be deterministic"
echo -e "=======================================================${NC}"
exit
fi
done
echo -e "${GREEN}PASSED deterministic test"
# Check for multiple regex via https://github.com/andyfitzgerald
a=$(./scc --not-match="(.*\.hex|.*\.d|.*\.o|.*\.csv|^(./)?[0-9]{8}_.*)" . | grep Estimated | md5sum)
b=$(./scc --not-match=".*\.hex" --not-match=".*\.d" --not-match=".*\.o" --not-match=".*\.csv" --not-match="^(./)?[0-9]{8}_.*" . | grep Estimated | md5sum)
if [ "$a" == "$b" ]; then
echo -e "${GREEN}PASSED multiple regex test"
else
echo -e "${RED}======================================================="
echo -e "FAILED multiple regex test"
echo -e "=================================================${NC}"
exit
fi
# Regression issue https://github.com/boyter/scc/issues/82
a=$(./scc . | grep Total)
b=$(./scc ${PWD} | grep Total)
if [ "$a" == "$b" ]; then
echo -e "${GREEN}PASSED git filter"
else
echo -e "${RED}======================================================="
echo -e "FAILED git filter"
echo -e "=================================================${NC}"
exit
fi
# Turn off gitignore https://github.com/boyter/scc/issues/53
touch ignored.xml
a=$(./scc | grep Total)
b=$(./scc --no-gitignore | grep Total)
if [ "$a" == "$b" ]; then
echo -e "${RED}================================================="
echo -e "FAILED git ignore filter"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED git ignore filter"
fi
# Regression issue https://github.com/boyter/scc/issues/115
if ./scc "examples/issue115/.test/file" 2>&1 >/dev/null | grep -q "Perl" ; then
echo -e "${RED}======================================================="
echo -e "FAILED hidden directory issue"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED hidden directory${NC}"
fi
# Regression issue https://github.com/boyter/scc/issues/260
if ./scc -d "examples/issue260/" 2>&1 >/dev/null | grep -q "invalid memory address" ; then
echo -e "${RED}======================================================="
echo -e "FAILED duplicate empty crash"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED duplicate empty crash${NC}"
fi
a=$(./scc | grep Total)
b=$(./scc --no-ignore | grep Total)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED ignore filter"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED ignore filter"
fi
if ./scc "examples/ignore/" | grep -q "Java "; then
echo -e "${RED}======================================================="
echo -e "FAILED multiple gitignore"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED multiple gitignore"
fi
touch ./examples/ignore/ignorefile.txt
a=$(./scc --by-file --no-scc-ignore | grep ignorefile)
b=$(./scc --by-file --no-ignore --no-scc-ignore | grep ignorefile)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED ignore recursive filter"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED ignore recursive filter"
fi
touch ./examples/ignore/gitignorefile.txt
a=$(./scc --by-file --no-scc-ignore | grep gitignorefile)
b=$(./scc --by-file --no-gitignore --no-scc-ignore | grep gitignorefile)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED gitignore recursive filter"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED gitignore recursive filter"
fi
if ./scc "examples/language/" --include-ext go | grep -q "Java "; then
echo -e "${RED}======================================================="
echo -e "FAILED include-ext option"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED include-ext option"
fi
a=$(./scc -i js ./examples/minified/ --no-scc-ignore)
b=$(./scc -i js -z ./examples/minified/ --no-scc-ignore)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED Minified check"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED minified check"
fi
a=$(./scc -i js -z ./examples/minified/ --no-scc-ignore)
b=$(./scc -i js -z --no-min-gen ./examples/minified/ --no-scc-ignore)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED Minified ignored check"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED minified ignored check"
fi
a=$(./scc ./examples/symlink/ --no-scc-ignore)
b=$(./scc --include-symlinks ./examples/symlink/ --no-scc-ignore)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED symlink check"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED minified ignored check"
fi
if ./scc ./examples/minified/ --no-min-gen --no-scc-ignore | grep -q "\$0"; then
echo -e "${GREEN}PASSED removed min"
else
echo -e "${RED}======================================================="
echo -e "FAILED removed min"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/generated/ --no-min-gen --no-scc-ignore | grep -q "\$0"; then
echo -e "${GREEN}PASSED removed gen"
else
echo -e "${RED}======================================================="
echo -e "FAILED removed gen"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -z ./examples/generated/ --no-scc-ignore | grep -q "C Header (gen)"; then
echo -e "${GREEN}PASSED flagged as gen"
else
echo -e "${RED}======================================================="
echo -e "FAILED flagged as gen"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/minified/ -i js -z --no-scc-ignore | grep -q "JavaScript (min)"; then
echo -e "${GREEN}PASSED flagged as min"
else
echo -e "${RED}======================================================="
echo -e "FAILED flagged as min"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/issue120/ -i java | grep -q "Perl"; then
echo -e "${RED}======================================================="
echo -e "FAILED extension param should ignore #!"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED extension param should ignore #!"
fi
if ./scc -z --min-gen-line-length 1 --no-min-gen . | grep -q "\$0"; then
echo -e "${GREEN}PASSED min gen line length"
else
echo -e "${RED}======================================================="
echo -e "FAILED min gen line length"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --no-large --large-byte-count 0 ./examples/language | grep -q "\$0"; then
echo -e "${GREEN}PASSED no large byte test"
else
echo -e "${RED}======================================================="
echo -e "FAILED no large byte test"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --no-large --large-line-count 0 ./examples/language | grep -q "\$0"; then
echo -e "${GREEN}PASSED no large line test"
else
echo -e "${RED}======================================================="
echo -e "FAILED no large line test"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --format html | grep -q "html"; then
echo -e "${GREEN}PASSED html output test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to output to html"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --format html-table | grep -q "table"; then
echo -e "${GREEN}PASSED html-table output test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to output to html-table"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --format sql | grep -q "create table metadata"; then
echo -e "${GREEN}PASSED sql output test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to output to sql"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --format sql-insert | grep -q "insert into t values"; then
echo -e "${GREEN}PASSED sql-insert output test"
else
echo -e "${RED}======================================================="
echo -e "FAILED Should be able to output to sql-insert"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/countas/ --count-as jsp:html | grep -q "HTML"; then
echo -e "${GREEN}PASSED counted JSP as HTML"
else
echo -e "${RED}======================================================="
echo -e "FAILED counted JSP as HTML"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/countas/ --count-as JsP:html | grep -q "HTML"; then
echo -e "${GREEN}PASSED counted JSP as HTML case"
else
echo -e "${RED}======================================================="
echo -e "FAILED counted JSP as HTML case"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/countas/ --count-as jsp:j2 | grep -q "Jinja"; then
echo -e "${GREEN}PASSED counted JSP as Jinja"
else
echo -e "${RED}======================================================="
echo -e "FAILED counted JSP as Jinja"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/countas/ --count-as jsp:html,new:java | grep -q "Java"; then
echo -e "${GREEN}PASSED counted new as Java"
else
echo -e "${RED}======================================================="
echo -e "FAILED counted new as Java"
echo -e "=======================================================${NC}"
exit
fi
if ./scc ./examples/countas/ --count-as jsp:html,new:"C Header" | grep -q "C Header"; then
echo -e "${GREEN}PASSED counted new as C Header"
else
echo -e "${RED}======================================================="
echo -e "FAILED counted new as C Header"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -i css ./examples/issue152/ | grep -q "CSS"; then
echo -e "${GREEN}PASSED -i extension check"
else
echo -e "${RED}======================================================="
echo -e "FAILED -i extension check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --file-gc-count 10 ./examples/duplicates/ -v | grep -q "read file limit exceeded GC re-enabled"; then
echo -e "${GREEN}PASSED gc file count"
else
echo -e "${RED}======================================================="
echo -e "FAILED gc file count"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f csv | grep -q "Bytes"; then
echo -e "${GREEN}PASSED csv bytes check"
else
echo -e "${RED}======================================================="
echo -e "FAILED csv bytes check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f csv-stream | grep -q "Bytes"; then
echo -e "${GREEN}PASSED csv-stream bytes check"
else
echo -e "${RED}======================================================="
echo -e "FAILED csv-stream bytes check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f html | grep -q "Bytes"; then
echo -e "${GREEN}PASSED html bytes check"
else
echo -e "${RED}======================================================="
echo -e "FAILED html bytes check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f json | grep -q "Bytes"; then
echo -e "${GREEN}PASSED json bytes check"
else
echo -e "${RED}======================================================="
echo -e "FAILED json bytes check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f json -a | grep -q "ULOC"; then
echo -e "${GREEN}PASSED json uloc check"
else
echo -e "${RED}======================================================="
echo -e "FAILED json uloc check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f json2 | grep -q "Bytes"; then
echo -e "${GREEN}PASSED json2 bytes check"
else
echo -e "${RED}======================================================="
echo -e "FAILED json bytes check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc | grep -q "megabytes"; then
echo -e "${GREEN}PASSED bytes check"
else
echo -e "${RED}======================================================="
echo -e "FAILED bytes check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f csv | grep -q "Language,Lines,Code,Comments,Blanks,Complexity,Bytes,Files,ULOC"; then
echo -e "${GREEN}PASSED csv summary"
else
echo -e "${RED}======================================================="
echo -e "FAILED csv summary"
echo -e "=======================================================${NC}"
exit
fi
if ./scc -f csv --by-file | grep -q "Language,Provider,Filename,Lines,Code,Comments,Blanks,Complexity,Bytes"; then
echo -e "${GREEN}PASSED csv file"
else
echo -e "${RED}======================================================="
echo -e "FAILED csv file"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --by-file --format-multi "tabular:stdout,html:stdout,csv:stdout" | grep -q "Language,Provider"; then
echo -e "${GREEN}PASSED format multi check"
else
echo -e "${RED}======================================================="
echo -e "FAILED format multi check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --format-multi "tabular:stdout,html:stdout,csv:stdout,sql:stdout" | grep -q "meta charset"; then
echo -e "${GREEN}PASSED format multi check"
else
echo -e "${RED}======================================================="
echo -e "FAILED format multi check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --format-multi "tabular:stdout,html:stdout,csv:stdout,sql:stdout" | grep -q "insert into t values"; then
echo -e "${GREEN}PASSED format multi check"
else
echo -e "${RED}======================================================="
echo -e "FAILED format multi check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --remap-unknown "-*- C++ -*-":"C Header" ./examples/remap/unknown | grep -q "C Header"; then
echo -e "${GREEN}PASSED remap unknown"
else
echo -e "${RED}======================================================="
echo -e "FAILED remap unknown"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --remap-all "-*- C++ -*-":"C Header" ./examples/remap/java.java | grep -q "C Header"; then
echo -e "${GREEN}PASSED remap all"
else
echo -e "${RED}======================================================="
echo -e "FAILED remap all"
echo -e "=======================================================${NC}"
exit
fi
./scc --format-multi "tabular:output.tab,wide:output.wide,json:output.json,json2:output2.json,csv:output.csv,cloc-yaml:output.yaml,html:output.html,html-table:output.html2,sql:output.sql"
if test -f output.tab; then
echo -e "${GREEN}PASSED output.tab check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.tab check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output.wide; then
echo -e "${GREEN}PASSED output.wide check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.wide check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output.json; then
echo -e "${GREEN}PASSED output.json check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.json check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output2.json; then
echo -e "${GREEN}PASSED output2.json check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output2.json check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output.yaml; then
echo -e "${GREEN}PASSED output.yaml check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.yaml check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output.html; then
echo -e "${GREEN}PASSED output.html check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.html check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output.html2; then
echo -e "${GREEN}PASSED output.html2 check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.html2 check"
echo -e "=======================================================${NC}"
exit
fi
if test -f output.sql; then
echo -e "${GREEN}PASSED output.sql check"
else
echo -e "${RED}======================================================="
echo -e "FAILED output.sql check"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --cocomo-project-type organic | grep -q "organic"; then
echo -e "${GREEN}PASSED cocomo organic"
else
echo -e "${RED}======================================================="
echo -e "FAILED cocomo organic"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --cocomo-project-type doesnotexist | grep -q "organic"; then
echo -e "${GREEN}PASSED cocomo fallback"
else
echo -e "${RED}======================================================="
echo -e "FAILED cocomo fallback"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --cocomo-project-type semi-detached | grep -q "semi-detached"; then
echo -e "${GREEN}PASSED cocomo semi-detached"
else
echo -e "${RED}======================================================="
echo -e "FAILED cocomo semi-detached"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --cocomo-project-type embedded | grep -q "embedded"; then
echo -e "${GREEN}PASSED cocomo embedded"
else
echo -e "${RED}======================================================="
echo -e "FAILED cocomo embedded"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --cocomo-project-type custom,1,1,1,1 | grep -q "custom,1,1,1,1"; then
echo -e "${GREEN}PASSED cocomo custom,1,1,1,1"
else
echo -e "${RED}======================================================="
echo -e "FAILED cocomo custom,1,1,1,1"
echo -e "=======================================================${NC}"
exit
fi
if ./scc --cocomo-project-type custom,1,1,1 | grep -q "organic"; then
echo -e "${GREEN}PASSED cocomo custom fallback"
else
echo -e "${RED}======================================================="
echo -e "FAILED cocomo custom fallback"
echo -e "=======================================================${NC}"
exit
fi
a=$(./scc --exclude-dir examples/)
b=$(./scc --exclude-dir examples)
if [ "$a" != "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED examples exclude-dir check"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED examples exclude-dir check"
fi
a=$(./scc --exclude-ext go)
b=$(./scc)
if [ "$a" == "$b" ]; then
echo "$a"
echo "$b"
echo -e "${RED}======================================================="
echo -e "FAILED exclude-ext check"
echo -e "=================================================${NC}"
exit
else
echo -e "${GREEN}PASSED exclude-ext check"
fi
# Issue 457
if ./scc -M ".*" | grep -q "0.000 megabytes"; then
echo -e "${GREEN}PASSED issue 457"
else
echo -e "${RED}======================================================="
echo -e "FAILED issue 457"
echo -e "=======================================================${NC}"
exit
fi
# Line length support
if ./scc -m | grep -q "MaxLine / MeanLine"; then
echo -e "${GREEN}PASSED character option"
else
echo -e "${RED}======================================================="
echo -e "FAILED character option"
echo -e "=======================================================${NC}"
exit
fi
# Try out specific languages
specificLanguages=(
'ABNF '
'Alchemist '
'Alloy '
'Arturo '
'Astro '
'AWK '
'BASH '
'Bean '
'Bicep '
'Bitbucket Pipeline '
'Boo '
'Bosque '
'C Shell '
'C# '
'Cairo '
'Cangjie '
'Chapel '
'Circom '
'Clipper '
'Clojure '
'Cuda '
'DAML '
'DM '
'Docker ignore '
'Dockerfile '
'DOT '
'Elm '
'F# '
'Factor '
'Flow9 '
'FSL '
'Futhark '
'FXML '
'Gemfile '
'Gleam '
'Go '
'Godot Scene '
'GraphQL '
'Gwion '
'HAML '
'Hare '
'ignore '
'INI '
'Java '
'JSON5 '
'JSONC '
'jq '
'Korn Shell '
'LALRPOP '
'License '
'LiveScript '
'LLVM IR '
'Luna '
'Makefile '
'Monkey C '
'Moonbit '
'Nushell '
'OpenQASM '
'Pkl '
'Proto '
'Q# '
'R '
'Racket '
'Rakefile '
'Redscript '
'Shell '
'Sieve '
'Slang '
'Slint '
'Smalltalk '
'Snakemake '
'Stan '
'Teal '
'Tera '
'Templ '
'Terraform '
'TTCN-3 '
'TypeSpec '
'Typst '
'Web Services '
'wenyan '
'Wren '