From 737f3973ff392c351da2744820a23a0521c6cc77 Mon Sep 17 00:00:00 2001 From: aidanchiu1112 <108113174+aidanchiu1112@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:51:14 -0700 Subject: [PATCH] CI Fix to Prevent Checks Dealing with Large Array Sizes (#459) * Fix spacing with comment * Updated code * Test: Added Assume catches for each failed tests * Added and implemented separate method to check if System CI is false * Added a null check to ensure assumingCIIsFalse() method runs locally as well * Changed assumeTrue to assumeFalse --- .../java/org/xerial/snappy/SnappyTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/xerial/snappy/SnappyTest.java b/src/test/java/org/xerial/snappy/SnappyTest.java index a9fa9ea0..30edf66c 100755 --- a/src/test/java/org/xerial/snappy/SnappyTest.java +++ b/src/test/java/org/xerial/snappy/SnappyTest.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import org.junit.Assume; import org.junit.Assert; import org.junit.Test; import org.xerial.util.log.Logger; @@ -415,31 +416,37 @@ public void isValidArrayInputLength() */ @Test(expected = SnappyError.class) public void isTooLargeDoubleArrayInputLength() throws Exception { + assumingCIIsFalse(); Snappy.compress(new double[Integer.MAX_VALUE / 8 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeCharArrayInputLength() throws Exception { + assumingCIIsFalse(); Snappy.compress(new char[Integer.MAX_VALUE / 2 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeFloatArrayInputLength() throws Exception { + assumingCIIsFalse(); Snappy.compress(new float[Integer.MAX_VALUE / 4 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeIntArrayInputLength() throws Exception { + assumingCIIsFalse(); Snappy.compress(new int[Integer.MAX_VALUE / 4 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeLongArrayInputLength() throws Exception { + assumingCIIsFalse(); Snappy.compress(new long[Integer.MAX_VALUE / 8 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeShortArrayInputLength() throws Exception { + assumingCIIsFalse(); Snappy.compress(new short[Integer.MAX_VALUE / 2 + 1]); } @@ -474,28 +481,37 @@ public void isValidArrayInputLengthForBitShuffleShuffle() */ @Test(expected = SnappyError.class) public void isTooLargeDoubleArrayInputLengthForBitShuffleShuffle() throws Exception { + assumingCIIsFalse(); BitShuffle.shuffle(new double[Integer.MAX_VALUE / 8 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeFloatArrayInputLengthForBitShuffleShuffle() throws Exception { + assumingCIIsFalse(); BitShuffle.shuffle(new float[Integer.MAX_VALUE / 4 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeIntArrayInputLengthForBitShuffleShuffle() throws Exception { + assumingCIIsFalse(); BitShuffle.shuffle(new float[Integer.MAX_VALUE / 4 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeLongArrayInputLengthForBitShuffleShuffle() throws Exception { + assumingCIIsFalse(); BitShuffle.shuffle(new long[Integer.MAX_VALUE / 8 + 1]); } @Test(expected = SnappyError.class) public void isTooLargeShortArrayInputLengthForBitShuffleShuffle() throws Exception { + assumingCIIsFalse(); BitShuffle.shuffle(new short[Integer.MAX_VALUE / 2 + 1]); + } - + private void assumingCIIsFalse() { + if (System.getenv("CI") == null) + return; + Assume.assumeFalse("Skipped on CI", System.getenv("CI").equals("true")); } }