forked from pantsbuild/intellij-pants-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPantsOptionsTest.java
62 lines (50 loc) · 2.44 KB
/
PantsOptionsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
package com.twitter.intellij.pants.model;
import com.twitter.intellij.pants.PantsException;
import com.twitter.intellij.pants.util.PantsConstants;
import junit.framework.TestCase;
import java.util.Optional;
public class PantsOptionsTest extends TestCase {
public void testWorkdir() {
PantsOptions options = new PantsOptions("pants_workdir = /Users/abc/workspace/intellij-pants-plugin/.pants.d (from HARDCODED)");
Optional<String> workdirOption = options.get(PantsConstants.PANTS_OPTION_PANTS_WORKDIR);
assertTrue(workdirOption.isPresent());
assertEquals("/Users/abc/workspace/intellij-pants-plugin/.pants.d",
workdirOption.get());
}
public void testWorkdirWithSpace() {
PantsOptions options = new PantsOptions("pants_workdir = /Users/abc/workspace/intellij-pants-plugin/.pants.d (from HARDCODED)");
Optional<String> spaceOption = options.get(PantsConstants.PANTS_OPTION_PANTS_WORKDIR);
assertTrue(spaceOption.isPresent());
assertEquals("/Users/abc/workspace/intellij-pants-plugin/.pants.d",
spaceOption.get());
}
public void testInvalidWorkdir() {
PantsOptions options = new PantsOptions("/Users/abc/workspace/intellij-pants-plugin/.pants.d (from HARDCODED)");
assertFalse(options.get(PantsConstants.PANTS_OPTION_PANTS_WORKDIR).isPresent());
}
public void testStrictJvmVersion() {
PantsOptions options = new PantsOptions("test.junit.strict_jvm_version = False (from HARDCODED)");
Optional<String> strictJvmOption = options.get(PantsConstants.PANTS_OPTION_TEST_JUNIT_STRICT_JVM_VERSION);
assertTrue(strictJvmOption.isPresent());
assertEquals("False", strictJvmOption.get());
}
public void testOptionsCache() {
PantsOptions options_a = PantsOptions.getPantsOptions("./pants");
PantsOptions options_b = PantsOptions.getPantsOptions("./pants");
// option_b should be cached result, so identical to options_a
assertTrue( options_a == options_b);
PantsOptions.clearCache();
PantsOptions options_c = PantsOptions.getPantsOptions("./pants");
assertTrue( options_a != options_c);
}
public void testOptionsException() {
try {
PantsOptions.getPantsOptions("some_invalid_pants_path");
fail(String.format("%s should have been thrown.", PantsException.class));
}
catch (PantsException ignored) {
}
}
}