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;
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class CastsTest {
@ -32,20 +26,8 @@ public class CastsTest {
@Test
public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException {
String literal_src =
String src =
"infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class ClassTest {
@ -32,20 +26,8 @@ public class ClassTest {
@Test
public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException {
String literal_src =
String src =
"infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class FunctionsTest {
@ -32,20 +26,8 @@ public class FunctionsTest {
@Test
public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException {
String literal_src =
String src =
"infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class InheritanceTest {
@ -34,18 +28,6 @@ public class InheritanceTest {
throws InterruptedException, IOException, InferException {
String src =
"infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class LiteralsTest {
@ -32,20 +26,8 @@ public class LiteralsTest {
@Test
public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException {
String literal_src =
String src =
"infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class NamespaceTest {
@ -32,20 +26,8 @@ public class NamespaceTest {
@Test
public void whenCaptureRunCommaThenDotFilesAreTheSame()
throws InterruptedException, IOException, InferException {
String switch_src =
String src =
"infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class NewTest {
@ -34,18 +28,6 @@ public class NewTest {
throws InterruptedException, IOException, InferException {
String src =
"infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

@ -9,20 +9,14 @@
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.Test;
import java.io.File;
import java.io.IOException;
import utils.DebuggableTemporaryFolder;
import utils.InferException;
import utils.InferRunner;
import utils.ClangFrontendUtils;
public class SelfParameterTest {
@ -34,18 +28,6 @@ public class SelfParameterTest {
throws InterruptedException, IOException, InferException {
String src =
"infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp";
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));
ClangFrontendUtils.createAndCompareCppDotFiles(folder, src);
}
}

Loading…
Cancel
Save