Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.9.0
5.9.1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object IteratorUtilities {

private val logger = LoggerFactory.getLogger(this.getClass)

private val ALLOW_DUPLICATE_COLUMNS = System.getProperty("gor.iterators.allowDuplicateColumns", "true").toBoolean
val ALLOW_DUPLICATE_COLUMNS_KEY = "gor.iterators.allowDuplicateColumns"

def getHeader(filename: String, gorRoot: String, context: GorContext): String = {
val gm: GorMonitor = null
Expand Down Expand Up @@ -89,7 +89,7 @@ object IteratorUtilities {
//just appending x to used columns
var colToUp = column.toUpperCase
while (usedCols.contains(colToUp)) {
if (ALLOW_DUPLICATE_COLUMNS || allowDuplicates) {
if (System.getProperty(ALLOW_DUPLICATE_COLUMNS_KEY, "false").toBoolean || allowDuplicates) {
column = column + "x"
colToUp = column.toUpperCase
if (!allowDuplicates) {
Expand Down
2 changes: 1 addition & 1 deletion gortools/src/test/java/gorsat/UTestHeaderFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public void testValidHeaderUsedKeywordsWithDupAllowingDup() {
Assert.assertFalse(systemErrRule.getLog().contains("Duplicate column name 'order'"));
}

@Ignore("Only works if run alone, as the property is read only on class load")
@Test
public void testValidHeaderUsedKeywordsWithDupNotAllowingDup() {
System.setProperty("gor.iterators.allowDuplicateColumns", "false");
Expand All @@ -94,6 +93,7 @@ public void testValidHeaderUsedKeywordsWithDupNotAllowingDup() {

@Test
public void testValidHeaderUsedKeywordsWithDupAllowingDupOnlyGlobal() {
System.setProperty("gor.iterators.allowDuplicateColumns", "true");
String testHeader = "#abc\tstart\tfrom\tselect\tmax\tmin\tfrom\tgroup\trange\torder\trank\torder";
String resultingHeader = IteratorUtilities.validHeader(testHeader, false);
Assert.assertEquals("#abc\tstart\tfrom\tselect\tmax\tmin\tfromx\tgroup\trange\torder\trank\torderx", resultingHeader);
Expand Down
9 changes: 7 additions & 2 deletions gortools/src/test/java/gorsat/UTestRename.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@
import org.gorpipe.exceptions.GorDataException;
import org.gorpipe.exceptions.GorParsingException;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;

import java.io.IOException;
import java.nio.file.Files;

public class UTestRename {

@Rule
public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();

@Test
public void testSimpleRename() {
String query = "gorrow chr1,1,1 | calc Foo_0001 0 | rename Foo_0001 Bar_CAR | top 0";
Expand Down Expand Up @@ -141,12 +146,12 @@ public void renameStrictWithNoMatch() {

@Test
public void renameToExistingAllowDup() {
System.setProperty("gor.iterators.allowDuplicateColumns", "true");
String query = "gorrow chr1,1 | calc Foo 0 | calc Bar 1 | rename Foo Bar | top 0";
String result = TestUtils.runGorPipe(query);
Assert.assertEquals("chrom\tpos\tBar\tBarx\n", result);
}

@Ignore("Only works if run alone, as the property is read only on class load")
@Test
public void renameToExistingNotAllowDup() {
System.setProperty("gor.iterators.allowDuplicateColumns", "false");
Expand Down
2 changes: 0 additions & 2 deletions gortools/src/test/java/gorsat/parser/UTestCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ public void addsNewColumn() {
Assert.assertEquals(expected, result);
}

@Ignore("Only works if run alone, as the property is read only on class load")
@Test
public void addsNewExistingColumn() {
System.setProperty("gor.iterators.allowDuplicateColumns", "false");
Assert.assertThrows(GorDataException.class, () -> TestUtils.runGorPipe("gorrow 1,1 | calc pos 42"));
}

@Ignore("Only works if run alone, as the property is read only on class load")
@Test
public void addsNewColumnWithSuffixWhenItExists() {
System.setProperty("gor.iterators.allowDuplicateColumns", "false");
Expand Down
Loading