Skip to content

Add test case and fix for annotation processor option with space #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
.idea/
target/
/.apt_generated/
/.apt_generated_tests/

# Eclipse
.classpath
.project
.factorypath
/.settings/
7 changes: 1 addition & 6 deletions java/com/google/turbine/options/TurbineOptionsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.turbine.options.TurbineOptions.ReducedClasspathMode;
import java.io.IOException;
Expand Down Expand Up @@ -159,9 +157,6 @@ private static void parse(TurbineOptions.Builder builder, Deque<String> argument
}
}

private static final Splitter ARG_SPLITTER =
Splitter.on(CharMatcher.breakingWhitespace()).omitEmptyStrings().trimResults();

/**
* Pre-processes an argument list, expanding arguments of the form {@code @filename} by reading
* the content of the file and appending whitespace-delimited options to {@code argumentDeque}.
Expand All @@ -186,7 +181,7 @@ private static void expandParamsFiles(Deque<String> argumentDeque, Iterable<Stri
if (!Files.exists(paramsPath)) {
throw new AssertionError("params file does not exist: " + paramsPath);
}
expandParamsFiles(argumentDeque, ARG_SPLITTER.split(Files.readString(paramsPath)));
expandParamsFiles(argumentDeque, Files.readAllLines(paramsPath));
} else {
argumentDeque.addLast(arg);
}
Expand Down
12 changes: 7 additions & 5 deletions javatests/com/google/turbine/options/TurbineOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.turbine.options.TurbineOptions.ReducedClasspathMode;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.turbine.options.TurbineOptions.ReducedClasspathMode;

@RunWith(JUnit4.class)
public class TurbineOptionsTest {

Expand Down Expand Up @@ -193,7 +195,7 @@ public void optionalTargetLabel() throws Exception {
public void paramsFile() throws Exception {
Iterable<String> paramsArgs =
Iterables.concat(
BASE_ARGS, Arrays.asList("--javacopts", "-source", "8", "-target", "8", "--"));
BASE_ARGS, Arrays.asList("--javacopts", "-source", "8", "-target", "8","-Aconnector.opt=with,space, here", "--"));
Path params = tmpFolder.newFile("params.txt").toPath();
Files.write(params, paramsArgs, StandardCharsets.UTF_8);

Expand All @@ -206,7 +208,7 @@ public void paramsFile() throws Exception {
TurbineOptions options = TurbineOptionsParser.parse(Arrays.asList(lines));

// assert that options were read from params file
assertThat(options.javacOpts()).containsExactly("-source", "8", "-target", "8").inOrder();
assertThat(options.javacOpts()).containsExactly("-source", "8", "-target", "8", "-Aconnector.opt=with,space, here").inOrder();
// ... and directly from the command line
assertThat(options.targetLabel()).hasValue("//custom/label");
}
Expand Down