695
695
assert_equals " fail" " $( awk " NR == $( wc -l < $TEST_log ) " $TEST_log ) "
696
696
}
697
697
698
- function test_undeclared_outputs_are_zipped_and_manifest_exists () {
698
+ function setup_undeclared_outputs_test () {
699
699
mkdir -p dir
700
700
701
701
cat << 'EOF ' > dir/test.sh
@@ -714,36 +714,131 @@ sh_test(
714
714
srcs = [ "test.sh" ],
715
715
)
716
716
EOF
717
+ }
718
+
719
+ function test_undeclared_outputs_are_zipped() {
720
+ setup_undeclared_outputs_test
721
+
722
+ local -r outputs_dir=bazel-testlogs/dir/test/test.outputs
723
+ local -r outputs_zip=$outputs_dir /outputs.zip
724
+ local -r output_text=$outputs_dir /text.txt
725
+ local -r output_html=$outputs_dir /fake.html
717
726
718
727
bazel test -s //dir:test & > $TEST_log || fail " expected success"
719
728
720
729
# Newlines are useful around diffs. This helps us get them in bash strings.
721
730
N=$' \n '
722
731
723
732
# Check that the undeclared outputs zip file exists.
724
- outputs_zip=bazel-testlogs/dir/test/test.outputs/outputs.zip
725
733
[ -s $outputs_zip ] || fail " $outputs_zip was not present after test"
726
734
735
+ # Check that the original undeclared outputs no longer exist.
736
+ [ -e $output_text ] && fail " $output_text was present after test"
737
+ [ -e $output_text ] && fail " $output_text was present after test"
738
+
739
+
727
740
# Check the contents of the zip file.
728
741
unzip -q " $outputs_zip " -d unzipped_outputs || fail " failed to unzip $outputs_zip "
729
742
cat > expected_text << EOF
730
743
some text
731
744
EOF
732
- diff " unzipped_outputs/text.txt" expected_text > d || fail " unzipped_outputs/text.txt differs from expected:$N $( cat d) $N "
745
+ diff " unzipped_outputs/text.txt" expected_text > d || fail " unzipped_outputs/text.txt differs from expected:$N $( cat d) $N "
746
+ cat > expected_html << EOF
747
+ <!DOCTYPE html>
748
+ EOF
749
+ diff expected_html " unzipped_outputs/fake.html" > d || fail " unzipped_outputs/fake.html differs from expected:$N $( cat d) $N "
750
+ }
751
+
752
+ function test_undeclared_outputs_are_not_zipped() {
753
+ setup_undeclared_outputs_test
754
+
755
+ local -r outputs_dir=bazel-testlogs/dir/test/test.outputs
756
+ local -r outputs_zip=$outputs_dir /outputs.zip
757
+ local -r output_text=$outputs_dir /text.txt
758
+ local -r output_html=$outputs_dir /fake.html
759
+
760
+ bazel test -s --nozip_undeclared_test_outputs //dir:test & > $TEST_log || fail " expected success"
761
+
762
+ # Newlines are useful around diffs. This helps us get them in bash strings.
763
+ N=$' \n '
764
+
765
+ # Check that the undeclared outputs zip file does not exist.
766
+ [ -e $outputs_zip ] && fail " $outputs_zip was present after test"
767
+
768
+ # Check that the undeclared outputs exist.
769
+ [ -e $output_text ] || fail " $output_text was not present after test"
770
+ [ -e $output_text ] || fail " $output_text was not present after test"
771
+
772
+ # Check the contents of the undeclared outputs.
773
+ cat > expected_text << EOF
774
+ some text
775
+ EOF
776
+ diff " $outputs_dir /text.txt" expected_text > d || fail " $outputs_dir /text.txt differs from expected:$N $( cat d) $N "
733
777
cat > expected_html << EOF
734
778
<!DOCTYPE html>
735
779
EOF
736
- diff expected_html " unzipped_outputs/fake.html" > d || fail " unzipped_outputs/fake.html differs from expected:$N $( cat d) $N "
780
+ diff expected_html " $outputs_dir /fake.html" > d || fail " $outputs_dir /fake.html differs from expected:$N $( cat d) $N "
781
+ }
782
+
783
+ function test_undeclared_outputs_zipped_then_unzipped() {
784
+ setup_undeclared_outputs_test
785
+
786
+ local -r outputs_dir=bazel-testlogs/dir/test/test.outputs
787
+ local -r outputs_zip=$outputs_dir /outputs.zip
788
+ local -r output_text=$outputs_dir /text.txt
789
+ local -r output_html=$outputs_dir /fake.html
790
+
791
+ bazel test -s //dir:test & > $TEST_log || fail " expected success"
792
+
793
+ [ -s $output_text ] && fail " $output_text was present after test"
794
+ [ -s $output_html ] && fail " $output_html was present after test"
795
+ [ -s $outputs_zip ] || fail " $outputs_zip was not present after test"
796
+
797
+ bazel test -s --nozip_undeclared_test_outputs //dir:test & > $TEST_log || fail " expected success"
798
+
799
+ [ -s $outputs_zip ] && fail " $outputs_zip was present after test"
800
+ [ -s $output_text ] || fail " $output_text was not present after test"
801
+ [ -s $output_html ] || fail " $output_html was not present after test"
802
+ }
803
+
804
+ function test_undeclared_outputs_unzipped_then_zipped() {
805
+ setup_undeclared_outputs_test
806
+
807
+ local -r outputs_dir=bazel-testlogs/dir/test/test.outputs
808
+ local -r outputs_zip=$outputs_dir /outputs.zip
809
+ local -r output_text=$outputs_dir /text.txt
810
+ local -r output_html=$outputs_dir /fake.html
811
+
812
+ bazel test -s --nozip_undeclared_test_outputs //dir:test & > $TEST_log || fail " expected success"
813
+
814
+ [ -s $outputs_zip ] && fail " $outputs_zip was present after test"
815
+ [ -s $output_text ] || fail " $output_text was not present after test"
816
+ [ -s $output_html ] || fail " $output_html was not present after test"
817
+
818
+ bazel test -s //dir:test & > $TEST_log || fail " expected success"
819
+
820
+ [ -s $output_text ] && fail " $output_text was present after test"
821
+ [ -s $output_html ] && fail " $output_html was present after test"
822
+ [ -s $outputs_zip ] || fail " $outputs_zip was not present after test"
823
+ }
824
+
825
+ function test_undeclared_outputs_manifest_is_created() {
826
+ setup_undeclared_outputs_test
827
+
828
+ bazel test -s //dir:test & > $TEST_log || fail " expected success"
829
+
830
+ # Newlines are useful around diffs. This helps us get them in bash strings.
831
+ N=$' \n '
737
832
738
833
# Check that the undeclared outputs manifest exists and that it has the
739
834
# correct contents.
740
- outputs_manifest=bazel-testlogs/dir/test/test.outputs_manifest/MANIFEST
835
+ local -r outputs_manifest=bazel-testlogs/dir/test/test.outputs_manifest/MANIFEST
741
836
[ -s $outputs_manifest ] || fail " $outputs_manifest was not present after test"
742
837
cat > expected_manifest << EOF
743
838
fake.html 16 text/html
744
839
text.txt 10 text/plain
745
840
EOF
746
- diff expected_manifest " $outputs_manifest " > d || fail " $outputs_manifest differs from expected:$N $( cat d) $N "
841
+ diff expected_manifest " $outputs_manifest " > d || fail " $outputs_manifest differs from expected:$N $( cat d) $N "
747
842
}
748
843
749
844
function test_undeclared_outputs_annotations_are_added() {
0 commit comments