Refactor C++ frontend tests

Summary: @​public
Remove some of the duplicated code, move .dot files to new locations

Reviewed By: @dulmarod

Differential Revision: D2521709

fb-gh-sync-id: 0cc333d
master
Andrzej Kotulski 9 years ago committed by facebook-github-bot-7
parent d825302189
commit d4c3d39fb9

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class CastsTest { public class CastsTest {
@ -32,20 +26,8 @@ public class CastsTest {
@Test @Test
public void whenCaptureRunCommaThenDotFilesAreTheSame() public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String literal_src = String src =
"infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp"; "infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String literal_dotty =
"infer/tests/codetoanalyze/cpp/frontend/types/casts.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
literal_src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + literal_src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(literal_dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class ClassTest { public class ClassTest {
@ -32,20 +26,8 @@ public class ClassTest {
@Test @Test
public void whenCaptureRunCommaThenDotFilesAreTheSame() public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String literal_src = String src =
"infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp"; "infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String literal_dotty =
"infer/tests/codetoanalyze/cpp/frontend/types/struct.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
literal_src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + literal_src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(literal_dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class FunctionsTest { public class FunctionsTest {
@ -32,20 +26,8 @@ public class FunctionsTest {
@Test @Test
public void whenCaptureRunCommaThenDotFilesAreTheSame() public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String literal_src = String src =
"infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp"; "infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String literal_dotty =
"infer/tests/codetoanalyze/cpp/frontend/types/functions.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
literal_src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + literal_src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(literal_dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class InheritanceTest { public class InheritanceTest {
@ -34,18 +28,6 @@ public class InheritanceTest {
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String src = String src =
"infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp"; "infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String dotty =
"infer/tests/codetoanalyze/cpp/frontend/types/inheritance.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class LiteralsTest { public class LiteralsTest {
@ -32,20 +26,8 @@ public class LiteralsTest {
@Test @Test
public void whenCaptureRunCommaThenDotFilesAreTheSame() public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String literal_src = String src =
"infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp"; "infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String literal_dotty =
"infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
literal_src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + literal_src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(literal_dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class NamespaceTest { public class NamespaceTest {
@ -32,20 +26,8 @@ public class NamespaceTest {
@Test @Test
public void whenCaptureRunCommaThenDotFilesAreTheSame() public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String switch_src = String src =
"infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp"; "infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String switch_dotty =
"infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
switch_src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + switch_src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(switch_dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class NewTest { public class NewTest {
@ -34,18 +28,6 @@ public class NewTest {
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String src = String src =
"infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp"; "infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String dotty =
"infer/tests/codetoanalyze/cpp/frontend/builtin/new.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(dotty));
} }
} }

@ -9,20 +9,14 @@
package frontend.cpp; package frontend.cpp;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
import com.google.common.collect.ImmutableList;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import utils.DebuggableTemporaryFolder; import utils.DebuggableTemporaryFolder;
import utils.InferException; import utils.InferException;
import utils.InferRunner; import utils.ClangFrontendUtils;
public class SelfParameterTest { public class SelfParameterTest {
@ -34,18 +28,6 @@ public class SelfParameterTest {
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String src = String src =
"infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp"; "infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp";
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
String dotty =
"infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.dot";
ImmutableList<String> inferCmd =
InferRunner.createCPPInferCommandFrontend(
folder,
src);
File newDotFile = InferRunner.runInferFrontend(inferCmd);
assertThat(
"In the capture of " + src +
" the dotty files should be the same.",
newDotFile, dotFileEqualTo(dotty));
} }
} }

Loading…
Cancel
Save