Summary: Making sure changed-only functionality works before I start to tweak it.master
parent
7f8282e046
commit
bdbc524f53
@ -0,0 +1,47 @@
|
|||||||
|
v1_files = glob([ '**/*.java.v1'])
|
||||||
|
v2_files = glob(['**/*.java.v2'])
|
||||||
|
normal_files = glob(['**/*.java'])
|
||||||
|
sources = v1_files + v2_files + normal_files
|
||||||
|
|
||||||
|
java_library(
|
||||||
|
name = 'changed_only_mode',
|
||||||
|
srcs = sources,
|
||||||
|
deps = [],
|
||||||
|
visibility = [
|
||||||
|
'PUBLIC'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def copy_files_strip_suffix_cmd(sfx, files):
|
||||||
|
return ' && '.join([' '.join(['cp', f, f.replace(sfx, '')]) for f in files])
|
||||||
|
|
||||||
|
out = 'out'
|
||||||
|
clean_cmd = ' '.join(['rm', '-rf', out])
|
||||||
|
stripped_suffix_files = map(lambda f: f.replace('.v1', ''), v1_files)
|
||||||
|
to_compile = ' '.join(set(normal_files + stripped_suffix_files))
|
||||||
|
infer_cmd = ' '.join([
|
||||||
|
'infer',
|
||||||
|
'-i',
|
||||||
|
'--changed-only',
|
||||||
|
'--absolute-paths',
|
||||||
|
'-o', out,
|
||||||
|
'-a', 'infer',
|
||||||
|
'--',
|
||||||
|
'javac',
|
||||||
|
to_compile
|
||||||
|
])
|
||||||
|
v1_copy_cmd = copy_files_strip_suffix_cmd('.v1', v1_files)
|
||||||
|
v2_copy_cmd = copy_files_strip_suffix_cmd('.v2', v2_files)
|
||||||
|
stats_copy_cmd = ' '.join(['cp', out + '/stats.json', '$OUT'])
|
||||||
|
command = ' && '.join([clean_cmd, v1_copy_cmd, infer_cmd, v2_copy_cmd, infer_cmd, stats_copy_cmd])
|
||||||
|
|
||||||
|
genrule(
|
||||||
|
name = 'analyze',
|
||||||
|
srcs = sources,
|
||||||
|
out = 'stats.json',
|
||||||
|
cmd = command,
|
||||||
|
deps = [':changed_only_mode'],
|
||||||
|
visibility = [
|
||||||
|
'PUBLIC',
|
||||||
|
]
|
||||||
|
)
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codetoanalyze.java.incremental.changed_only_mode;
|
||||||
|
|
||||||
|
class Child {
|
||||||
|
|
||||||
|
Object bar() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object dontReanalyze(Object o) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codetoanalyze.java.incremental.changed_only_mode;
|
||||||
|
|
||||||
|
class Child {
|
||||||
|
|
||||||
|
Object bar() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
|
||||||
|
Object dontReanalyze(Object o) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codetoanalyze.java.incremental.changed_only_mode;
|
||||||
|
|
||||||
|
class Child {
|
||||||
|
|
||||||
|
Object bar() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object dontReanalyze(Object o) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codetoanalyze.java.incremental.changed_only_mode;
|
||||||
|
|
||||||
|
class Parent {
|
||||||
|
|
||||||
|
Object foo() {
|
||||||
|
Child c = new Child();
|
||||||
|
Object o = c.bar();
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dontReanalyze() {
|
||||||
|
Object o1 = new Object();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package endtoend.java.incremental;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static utils.matchers.NumberOfFilesAnalyzed.numberOfFilesAnalyzed;
|
||||||
|
import static utils.matchers.NumberOfProceduresAnalyzed.numberOfProceduresAnalyzed;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import utils.InferException;
|
||||||
|
import utils.InferStats;
|
||||||
|
|
||||||
|
public class ChangedOnlyModeTest {
|
||||||
|
|
||||||
|
public static final String SOURCE_DIR =
|
||||||
|
"/infer/tests/codetoanalyze/java/incremental/changed_only_mode/";
|
||||||
|
|
||||||
|
private static InferStats inferStats;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void loadResults() throws InterruptedException, IOException {
|
||||||
|
inferStats = InferStats.loadInferStats(ChangedOnlyModeTest.class, SOURCE_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onlyChangedFileReanalyzedInChangedOnlyMode()
|
||||||
|
throws IOException, InterruptedException, InferException {
|
||||||
|
assertThat(
|
||||||
|
"After changing the child file, parent should not be re-analyzed in changed-only mode",
|
||||||
|
inferStats,
|
||||||
|
numberOfFilesAnalyzed(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onlyChangedProcsReanalyzedInIncrementalMode()
|
||||||
|
throws IOException, InterruptedException, InferException {
|
||||||
|
assertThat(
|
||||||
|
"After changing a procedure, its callers should not be re-analyzed in changed-only mode",
|
||||||
|
inferStats,
|
||||||
|
numberOfProceduresAnalyzed(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue