Skip to content

Commit

Permalink
Improve cleaning the project (#502)
Browse files Browse the repository at this point in the history
Co-authored-by: Werner Dietl <[email protected]>
  • Loading branch information
Ao-senXiong and wmdietl authored Aug 30, 2024
1 parent 304774a commit 304e999
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 57 deletions.
15 changes: 13 additions & 2 deletions checker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ artifacts {
}

clean {
delete "${projectDir}/dist"
delete 'tests/calledmethods-delomboked'
delete("${projectDir}/dist")
delete('tests/calledmethods-delomboked')
delete('tests/ainfer-testchecker/annotated')
delete('tests/ainfer-testchecker/inference-output')
delete('tests/ainfer-nullness/annotated')
Expand All @@ -246,6 +246,17 @@ clean {
delete('tests/ainfer-index/inference-output')
delete('tests/ainfer-resourceleak/annotated')
delete('tests/ainfer-resourceleak/inference-output')
delete('tests/build')
doLast {
exec {
workingDir = file('tests/command-line')
commandLine 'make', 'clean'
}
exec {
workingDir = file('tests/nullness-extra')
commandLine 'make', 'clean'
}
}
}

clean.doLast {
Expand Down
5 changes: 4 additions & 1 deletion checker/tests/command-line/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# All targets
.PHONY: all skipped issue618
.PHONY: all clean skipped issue618

# Tests that are currently passing
all: issue618
Expand All @@ -9,3 +9,6 @@ skipped:

issue618:
make -C issue618

clean:
make -C issue618 clean
6 changes: 5 additions & 1 deletion checker/tests/command-line/issue618/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.PHONY: all
.PHONY: all clean

all:
-$(JAVAC) -processor regex,org.checkerframework.checker.tainting.TaintingChecker TwoCheckers.java > out.txt 2>&1
diff -u expected.txt out.txt

clean:
rm -f out.txt
rm -f *.class
14 changes: 14 additions & 0 deletions checker/tests/nullness-extra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,17 @@ issue5174:

# All tests: passing and failing
.PHONY: all skipped ${PASSING_TESTS}

clean:
$(MAKE) -C compat clean
$(MAKE) -C issue265 clean
$(MAKE) -C issue309 clean
$(MAKE) -C issue502 clean
$(MAKE) -C issue559 clean
$(MAKE) -C issue594 clean
$(MAKE) -C multiple-errors clean
$(MAKE) -C package-anno clean
$(MAKE) -C shorthand clean
$(MAKE) -C issue607 clean
$(MAKE) -C issue3597 clean
$(MAKE) -C issue5174 clean
6 changes: 4 additions & 2 deletions checker/tests/nullness-extra/compat/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.PHONY: all
.PHONY: all clean

all:
rm -f Out.txt CompatTest.class lib/Lib.class javax/annotation/Nullable.class
-$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker lib/Lib.java javax/annotation/Nullable.java CompatTest.java > Out.txt 2>&1
diff -u Expected.txt Out.txt

clean:
rm -f Out.txt CompatTest.class lib/Lib.class javax/annotation/Nullable.class
4 changes: 3 additions & 1 deletion checker/tests/nullness-extra/issue265/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.PHONY: all
.PHONY: all clean

all:
mkdir -p bin
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker *.java -d bin/
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker Delta.java -cp bin/ -d bin/

clean:
rm bin/*.class
rmdir bin
9 changes: 5 additions & 4 deletions checker/tests/nullness-extra/issue309/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.PHONY: all
.PHONY: all clean

all:
rm -f Out.txt
mkdir -p bin
$(JAVAC) lib/*.java -d bin/
jar cvf lib.jar -C bin/ lib/Lib.class
Expand All @@ -10,5 +9,7 @@ all:
# Run again with stub file. (This used to cause a crash.)
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker -Anomsgtext Issue309.java -d bin/ -cp lib.jar -Astubs=Lib.astub > Out.txt 2>&1
diff -u Expected.txt Out.txt
rm Out.txt lib.jar bin/*.class bin/lib/*.class
rmdir bin/lib bin/

clean:
rm -f Out.txt lib.jar
rm -rf bin/
10 changes: 5 additions & 5 deletions checker/tests/nullness-extra/issue348/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.PHONY: all
.PHONY: all clean

all:
rm -f Out.txt
mkdir -p bin
$(JAVAC) lib/*.java -d bin/
rm -f bin/lib/Anno.class
jar cvf lib.jar -C bin/ lib/
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker -Anomsgtext Issue348.java -d bin/ -cp lib.jar > Out.txt 2>&1
diff -u Expected.txt Out.txt
rm Out.txt lib.jar bin/*.class bin/lib/*.class
rmdir bin/lib bin/

clean:
rm -f Out.txt lib.jar
rmdir bin/
4 changes: 2 additions & 2 deletions checker/tests/nullness-extra/issue3597/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
$(JAVAC) testpkg/Issue3597B.java
$(JAVAC) -Astubs=issue3597.astub -processor Nullness -sourcepath : -cp . testpkg/Issue3597A.java

Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness-extra/issue502/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker Issue502.java
# TODO: This test is rather unstable, as Expected.txt relies on
# @SideEffectFree being constant #12().
Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness-extra/issue5174/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker -Acfgviz=org.checkerframework.dataflow.cfg.visualize.StringCFGVisualizer -AassumeKeyFor Issue5174.java > Out.txt 2>&1 || true
diff -u Issue5174.out Out.txt

Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness-extra/issue559/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
-$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker -Astubs=myjdk.astub -AstubWarnIfOverwritesBytecode Issue559.java > Out.txt 2>&1
diff -u Expected.txt Out.txt

Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness-extra/issue594/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
-$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker Issue594.java > Out.txt 2>&1
diff -u Expected.txt Out.txt

Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness-extra/issue607/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
$(JAVAC) Issue607SuperClass.java Issue607Interface.java
$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker Issue607.java

Expand Down
6 changes: 4 additions & 2 deletions checker/tests/nullness-extra/multiple-errors/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.PHONY: all
.PHONY: all clean

all:
rm -f Out.txt
-$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker *.java > Out.txt 2>&1
diff -u Expected.txt Out.txt

clean:
rm -f Out.txt
7 changes: 5 additions & 2 deletions checker/tests/nullness-extra/package-anno/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.PHONY: all
.PHONY: all clean

all:
rm -f Out.txt
-$(JAVAC) -processor org.checkerframework.checker.nullness.NullnessChecker test/*.java > Out.txt 2>&1
diff -u Expected.txt Out.txt

clean:
rm -f Out.txt
rm -f test/*.class
10 changes: 5 additions & 5 deletions checker/tests/nullness-extra/shorthand/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.PHONY: all nullnessOnly nullnessRegex nullnessBad nonsense
.PHONY: all clean nullnessOnly nullnessRegex nullnessBad nonsense

all: nullnessOnly nullnessRegex nullnessBad nonsense

nullnessOnly:
rm -f Out.txt
-$(JAVAC) -processor NullnessChecker -XDrawDiagnostics -Anomsgtext -Awarns NullnessRegexWithErrors.java > Out.txt 2>&1
diff -u NullnessOnlyExpected.txt Out.txt

nullnessRegex:
rm -f Out.txt
-$(JAVAC) -processor NullnessChecker,RegexChecker -XDrawDiagnostics -Anomsgtext -Awarns NullnessRegexWithErrors.java > Out.txt 2>&1
diff -u NullnessRegexExpected.txt Out.txt

nullnessBad:
rm -f Out.txt
-$(JAVAC) -processor nullness.NullnessChecker -XDrawDiagnostics -Anomsgtext -Awarns NullnessRegexWithErrors.java > Out.txt 2>&1
diff -u NullnessBadExpected.txt Out.txt

nonsense:
rm -f Out.txt
-$(JAVAC) -processor NonsenseChecker -XDrawDiagnostics -Anomsgtext -Awarns NullnessRegexWithErrors.java > Out.txt 2>&1
diff -u NonsenseExpected.txt Out.txt

clean:
rm -f Out.txt
rm -f *.class
9 changes: 9 additions & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
clean {
delete('api/')
doLast {
exec {
workingDir = file('examples')
commandLine 'make', 'clean'
}
}
}
28 changes: 19 additions & 9 deletions docs/examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
JAVAC ?= $(realpath ../../checker/bin/javac)

.PHONY: all
.PHONY: all clean

all: compile

compile:
$(JAVAC) *.java
cd fenum-extension && $(MAKE)
cd subtyping-extension && $(MAKE)
cd units-extension && $(MAKE)
# The Maven example downloads a lot. Try twice in case of network lossage.
cd MavenExample && ($(MAKE) || (sleep 60 && echo "Trying again:" && $(MAKE)))
cd lombok && $(MAKE)
cd errorprone && $(MAKE)
cd BazelExample && $(MAKE)
$(MAKE) -C fenum-extension
$(MAKE) -C subtyping-extension
$(MAKE) -C units-extension
# The Maven example downloads a lot. Try twice in case of network lossage.
$(MAKE) -C MavenExample || (sleep 60 && echo "Trying again:" && $(MAKE) -C MavenExample)
$(MAKE) -C lombok
$(MAKE) -C errorprone
$(MAKE) -C BazelExample

# TODO: type check the different files with the right checker;
# some tests expect errors, compare against expected errors.

clean:
rm -f *.class
$(MAKE) -C fenum-extension clean
$(MAKE) -C subtyping-extension clean
$(MAKE) -C units-extension clean
$(MAKE) -C MavenExample clean
$(MAKE) -C lombok clean
$(MAKE) -C errorprone clean
$(MAKE) -C BazelExample clean
4 changes: 2 additions & 2 deletions docs/examples/MavenExample-framework-all/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all
.PHONY: all clean

all: clean
all:
mvn -fn compile > Out.txt 2>&1
grep -qF "MavenExample.java:[24,28] error: [assignment.type.incompatible] incompatible types in assignment." Out.txt

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/errorprone/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
JAVA_VER := $(shell java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 | sed 's/-ea//')

.PHONY: all
.PHONY: all clean

all: clean
all:
- ../../../gradlew build > Out.txt 2>&1
grep -qF "Demo.java:7: warning: [CollectionIncompatibleType] Argument 'i - 1' should not be passed to this method; its type int is not compatible with its collection's type argument Short" Out.txt
grep -qF "Demo.java:8: error: [argument.type.incompatible] incompatible argument for parameter arg0 of Set.add." Out.txt
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/fenum-extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ JAVAC?=../../../checker/bin/javac
# gets the full path to the directory of the make file, which is also the root dir of the qual folder
# for custom projects, it is best to encode the full root path as a variable
PROJECTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
.PHONY: all clean compile-for-test named-quals-test qual-folder-test

all: compile-for-test named-quals-test qual-folder-test clean
all: compile-for-test named-quals-test qual-folder-test

demo:
$(JAVAC) $(JAVAOPTS) $(FILES)
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/lombok/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
JAVA_VER := $(shell java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 | sed 's/-ea//')

.PHONY: all
.PHONY: all clean

# Delomboking seems to mess up line numbers. The actual error is on line 13, but the error appears on line 12.
# So check for both the error message and make sure it is for the right assignment.
Expand All @@ -9,7 +9,7 @@ ifeq (${JAVA_VER},22)
all:
@echo "Skipping test because lombok does not work under Java ${JAVA_VER}"
else
all: clean
all:
- ../../../gradlew build > Out.txt 2>&1
(grep -qF "User.java:9: error: [argument.type.incompatible] incompatible argument for parameter y of FooBuilder.y." Out.txt \
&& grep -qF "Foo.java:12: error: [assignment.type.incompatible] incompatible types in assignment." Out.txt \
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/subtyping-extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ JAVAC?=../../../checker/bin/javac
# gets the full path to the directory of the make file, which is also the root dir of the qual folder
# for custom projects, it is best to encode the full root path as a variable
PROJECTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
.PHONY: all clean compile-for-test named-quals-test qual-folder-test

all: compile-for-test named-quals-test qual-folder-test clean
all: compile-for-test named-quals-test qual-folder-test

demo:
$(JAVAC) $(JAVAOPTS) $(FILES)
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/units-extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ JAVAC?=../../../checker/bin/javac
# gets the full path to the directory of the make file, which is also the root dir of the qual folder
# for custom projects, it is best to encode the full root path as a variable
PROJECTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

all: compile-for-test named-quals-test qual-folder-test clean
.PHONY: all clean compile-for-test named-quals-test qual-folder-test
all: compile-for-test named-quals-test qual-folder-test

demo:
$(JAVAC) $(JAVAOPTS) $(FILES)
Expand Down
7 changes: 7 additions & 0 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ task loaderTests(dependsOn: 'shadowJar', group: 'Verification') {
clean {
delete('tests/returnsreceiverdelomboked')
delete('dist')
delete('tests/build')
doLast {
exec {
workingDir = file('tests/annotationclassloader')
commandLine 'make', 'clean'
}
}
}


Expand Down
5 changes: 4 additions & 1 deletion framework/tests/annotationclassloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ JAVACUTILBUILD := $(PROJECTDIR)/../../../javacutil/build/classes/java/main
FRAMEWORKBUILD := $(PROJECTDIR)/../../build/classes/java/main:$(PROJECTDIR)/../../build/resources/main/
CHECKERQUALBUILD := $(PROJECTDIR)/../../../checker-qual/build/classes/java/main

.PHONY: all clean demo1 demo2

all: load-from-dir-test load-from-jar-test

Expand Down Expand Up @@ -63,7 +64,6 @@ load-from-dir-test:
-AnoJreVersionCheck \
LoaderTest.java > Out.txt 2>&1
diff -u Expected.txt Out.txt
rm -f Out.txt

# loads from framework.jar
load-from-jar-test:
Expand All @@ -76,4 +76,7 @@ load-from-jar-test:
-AnoJreVersionCheck \
LoaderTest.java > Out.txt 2>&1
diff -u Expected.txt Out.txt

clean:
rm -f Out.txt

Loading

0 comments on commit 304e999

Please sign in to comment.