@@ -774,6 +774,8 @@ def macro():
774
774
}
775
775
776
776
func TestNativeShBinaryWarning (t * testing.T ) {
777
+ defer setUpFileReader (nil )()
778
+
777
779
checkFindingsAndFix (t , "native-sh-binary" , `
778
780
"""My file"""
779
781
@@ -799,6 +801,8 @@ sh_binary()
799
801
}
800
802
801
803
func TestNativeShLibraryWarning (t * testing.T ) {
804
+ defer setUpFileReader (nil )()
805
+
802
806
checkFindingsAndFix (t , "native-sh-library" , `
803
807
"""My file"""
804
808
@@ -824,6 +828,8 @@ sh_library()
824
828
}
825
829
826
830
func TestNativeShTestWarning (t * testing.T ) {
831
+ defer setUpFileReader (nil )()
832
+
827
833
checkFindingsAndFix (t , "native-sh-test" , `
828
834
"""My file"""
829
835
@@ -848,6 +854,68 @@ sh_test()
848
854
scopeBzl | scopeBuild )
849
855
}
850
856
857
+ func TestNativeWarningLoadPlacedAfterFileDocstringWithComment (t * testing.T ) {
858
+ defer setUpFileReader (nil )()
859
+
860
+ checkFindingsAndFix (t , "native-sh-binary,native-java-binary" , `
861
+ # Copyright 2020 Google LLC
862
+ #
863
+ # Licensed under the Apache License, Version 2.0 (the "License");
864
+ # you may not use this file except in compliance with the License.
865
+ # You may obtain a copy of the License at
866
+ #
867
+ # https://www.apache.org/licenses/LICENSE-2.0
868
+ #
869
+ # Unless required by applicable law or agreed to in writing, software
870
+ # distributed under the License is distributed on an "AS IS" BASIS,
871
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
872
+ # See the License for the specific language governing permissions and
873
+ # limitations under the License.
874
+
875
+ """My file"""
876
+
877
+ def macro():
878
+ native.sh_binary()
879
+ native.java_binary()
880
+
881
+ java_binary()
882
+ sh_binary()
883
+ ` , `
884
+ # Copyright 2020 Google LLC
885
+ #
886
+ # Licensed under the Apache License, Version 2.0 (the "License");
887
+ # you may not use this file except in compliance with the License.
888
+ # You may obtain a copy of the License at
889
+ #
890
+ # https://www.apache.org/licenses/LICENSE-2.0
891
+ #
892
+ # Unless required by applicable law or agreed to in writing, software
893
+ # distributed under the License is distributed on an "AS IS" BASIS,
894
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
895
+ # See the License for the specific language governing permissions and
896
+ # limitations under the License.
897
+
898
+ """My file"""
899
+
900
+ load("@rules_java//java:java_binary.bzl", "java_binary")
901
+ load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
902
+
903
+ def macro():
904
+ sh_binary()
905
+ java_binary()
906
+
907
+ java_binary()
908
+ sh_binary()
909
+ ` ,
910
+ []string {
911
+ fmt .Sprintf (`:18: Function "sh_binary" is not global anymore and needs to be loaded from "@rules_shell//shell:sh_binary.bzl".` ),
912
+ fmt .Sprintf (`:19: Function "java_binary" is not global anymore and needs to be loaded from "@rules_java//java:java_binary.bzl".` ),
913
+ fmt .Sprintf (`:21: Function "java_binary" is not global anymore and needs to be loaded from "@rules_java//java:java_binary.bzl".` ),
914
+ fmt .Sprintf (`:22: Function "sh_binary" is not global anymore and needs to be loaded from "@rules_shell//shell:sh_binary.bzl".` ),
915
+ },
916
+ scopeBzl | scopeBuild )
917
+ }
918
+
851
919
func TestKeywordParameters (t * testing.T ) {
852
920
checkFindingsAndFix (t , "keyword-positional-params" , `
853
921
foo(key = value)
0 commit comments