From 304e999c7c3ca727f9e1eec7349cb42cf79fe862 Mon Sep 17 00:00:00 2001 From: Aosen Xiong <82676488+Ao-senXiong@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:18:31 -0400 Subject: [PATCH] Improve cleaning the project (#502) Co-authored-by: Werner Dietl --- checker/build.gradle | 15 ++++++++-- checker/tests/command-line/Makefile | 5 +++- checker/tests/command-line/issue618/Makefile | 6 +++- checker/tests/nullness-extra/Makefile | 14 ++++++++++ checker/tests/nullness-extra/compat/Makefile | 6 ++-- .../tests/nullness-extra/issue265/Makefile | 4 ++- .../tests/nullness-extra/issue309/Makefile | 9 +++--- .../tests/nullness-extra/issue348/Makefile | 10 +++---- .../tests/nullness-extra/issue3597/Makefile | 4 +-- .../tests/nullness-extra/issue502/Makefile | 4 +-- .../tests/nullness-extra/issue5174/Makefile | 4 +-- .../tests/nullness-extra/issue559/Makefile | 4 +-- .../tests/nullness-extra/issue594/Makefile | 4 +-- .../tests/nullness-extra/issue607/Makefile | 4 +-- .../nullness-extra/multiple-errors/Makefile | 6 ++-- .../nullness-extra/package-anno/Makefile | 7 +++-- .../tests/nullness-extra/shorthand/Makefile | 10 +++---- docs/build.gradle | 9 ++++++ docs/examples/Makefile | 28 +++++++++++++------ .../MavenExample-framework-all/Makefile | 4 +-- docs/examples/errorprone/Makefile | 4 +-- docs/examples/fenum-extension/Makefile | 3 +- docs/examples/lombok/Makefile | 4 +-- docs/examples/subtyping-extension/Makefile | 3 +- docs/examples/units-extension/Makefile | 4 +-- framework/build.gradle | 7 +++++ .../tests/annotationclassloader/Makefile | 5 +++- settings.gradle | 1 + 28 files changed, 131 insertions(+), 57 deletions(-) create mode 100644 docs/build.gradle diff --git a/checker/build.gradle b/checker/build.gradle index ef5b2799584..c5ebe9216cc 100644 --- a/checker/build.gradle +++ b/checker/build.gradle @@ -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') @@ -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 { diff --git a/checker/tests/command-line/Makefile b/checker/tests/command-line/Makefile index 46228ebf2c6..f8089d595c3 100644 --- a/checker/tests/command-line/Makefile +++ b/checker/tests/command-line/Makefile @@ -1,5 +1,5 @@ # All targets -.PHONY: all skipped issue618 +.PHONY: all clean skipped issue618 # Tests that are currently passing all: issue618 @@ -9,3 +9,6 @@ skipped: issue618: make -C issue618 + +clean: + make -C issue618 clean diff --git a/checker/tests/command-line/issue618/Makefile b/checker/tests/command-line/issue618/Makefile index 20613fed57a..bad38b512aa 100644 --- a/checker/tests/command-line/issue618/Makefile +++ b/checker/tests/command-line/issue618/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/Makefile b/checker/tests/nullness-extra/Makefile index 6f493a631f2..78578ef4e61 100644 --- a/checker/tests/nullness-extra/Makefile +++ b/checker/tests/nullness-extra/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/compat/Makefile b/checker/tests/nullness-extra/compat/Makefile index d2dd485bfc3..f3029032d67 100644 --- a/checker/tests/nullness-extra/compat/Makefile +++ b/checker/tests/nullness-extra/compat/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/issue265/Makefile b/checker/tests/nullness-extra/issue265/Makefile index c9f7bffec50..117806bff93 100644 --- a/checker/tests/nullness-extra/issue265/Makefile +++ b/checker/tests/nullness-extra/issue265/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/issue309/Makefile b/checker/tests/nullness-extra/issue309/Makefile index a7318e83772..c4b38f0bcdf 100644 --- a/checker/tests/nullness-extra/issue309/Makefile +++ b/checker/tests/nullness-extra/issue309/Makefile @@ -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 @@ -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/ diff --git a/checker/tests/nullness-extra/issue348/Makefile b/checker/tests/nullness-extra/issue348/Makefile index 5ed3eb15430..dd30f5a77ed 100644 --- a/checker/tests/nullness-extra/issue348/Makefile +++ b/checker/tests/nullness-extra/issue348/Makefile @@ -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/ diff --git a/checker/tests/nullness-extra/issue3597/Makefile b/checker/tests/nullness-extra/issue3597/Makefile index a25e91b8725..4ba40c483ee 100644 --- a/checker/tests/nullness-extra/issue3597/Makefile +++ b/checker/tests/nullness-extra/issue3597/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/issue502/Makefile b/checker/tests/nullness-extra/issue502/Makefile index 5f2aa257c6f..f3331beca86 100644 --- a/checker/tests/nullness-extra/issue502/Makefile +++ b/checker/tests/nullness-extra/issue502/Makefile @@ -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(). diff --git a/checker/tests/nullness-extra/issue5174/Makefile b/checker/tests/nullness-extra/issue5174/Makefile index b046ecc2bc2..3fc35342c81 100644 --- a/checker/tests/nullness-extra/issue5174/Makefile +++ b/checker/tests/nullness-extra/issue5174/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/issue559/Makefile b/checker/tests/nullness-extra/issue559/Makefile index f7f60ad4e2e..1f0cff54a47 100644 --- a/checker/tests/nullness-extra/issue559/Makefile +++ b/checker/tests/nullness-extra/issue559/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/issue594/Makefile b/checker/tests/nullness-extra/issue594/Makefile index f142dc3a13f..9c16d34a30f 100644 --- a/checker/tests/nullness-extra/issue594/Makefile +++ b/checker/tests/nullness-extra/issue594/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/issue607/Makefile b/checker/tests/nullness-extra/issue607/Makefile index 08fb457d27f..a3eb9ef4382 100644 --- a/checker/tests/nullness-extra/issue607/Makefile +++ b/checker/tests/nullness-extra/issue607/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/multiple-errors/Makefile b/checker/tests/nullness-extra/multiple-errors/Makefile index 859a673b192..50878ed5048 100644 --- a/checker/tests/nullness-extra/multiple-errors/Makefile +++ b/checker/tests/nullness-extra/multiple-errors/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/package-anno/Makefile b/checker/tests/nullness-extra/package-anno/Makefile index ca64ef71722..26596d90963 100644 --- a/checker/tests/nullness-extra/package-anno/Makefile +++ b/checker/tests/nullness-extra/package-anno/Makefile @@ -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 diff --git a/checker/tests/nullness-extra/shorthand/Makefile b/checker/tests/nullness-extra/shorthand/Makefile index 3d6808e427e..665c025ad61 100644 --- a/checker/tests/nullness-extra/shorthand/Makefile +++ b/checker/tests/nullness-extra/shorthand/Makefile @@ -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 diff --git a/docs/build.gradle b/docs/build.gradle new file mode 100644 index 00000000000..2433732f023 --- /dev/null +++ b/docs/build.gradle @@ -0,0 +1,9 @@ +clean { + delete('api/') + doLast { + exec { + workingDir = file('examples') + commandLine 'make', 'clean' + } + } +} diff --git a/docs/examples/Makefile b/docs/examples/Makefile index 47209ce1790..f511696fd9d 100644 --- a/docs/examples/Makefile +++ b/docs/examples/Makefile @@ -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 diff --git a/docs/examples/MavenExample-framework-all/Makefile b/docs/examples/MavenExample-framework-all/Makefile index dfd00dad120..752b8cd6a3b 100644 --- a/docs/examples/MavenExample-framework-all/Makefile +++ b/docs/examples/MavenExample-framework-all/Makefile @@ -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 diff --git a/docs/examples/errorprone/Makefile b/docs/examples/errorprone/Makefile index b05432f1dfa..392ab070cb1 100644 --- a/docs/examples/errorprone/Makefile +++ b/docs/examples/errorprone/Makefile @@ -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 diff --git a/docs/examples/fenum-extension/Makefile b/docs/examples/fenum-extension/Makefile index d0bf388a649..31767ffe415 100644 --- a/docs/examples/fenum-extension/Makefile +++ b/docs/examples/fenum-extension/Makefile @@ -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) diff --git a/docs/examples/lombok/Makefile b/docs/examples/lombok/Makefile index 1312849bb72..fad2c712390 100644 --- a/docs/examples/lombok/Makefile +++ b/docs/examples/lombok/Makefile @@ -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. @@ -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 \ diff --git a/docs/examples/subtyping-extension/Makefile b/docs/examples/subtyping-extension/Makefile index e36c6a648d5..fa7a3564e3d 100644 --- a/docs/examples/subtyping-extension/Makefile +++ b/docs/examples/subtyping-extension/Makefile @@ -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) diff --git a/docs/examples/units-extension/Makefile b/docs/examples/units-extension/Makefile index d21016dc9a3..82e0e120c14 100644 --- a/docs/examples/units-extension/Makefile +++ b/docs/examples/units-extension/Makefile @@ -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) diff --git a/framework/build.gradle b/framework/build.gradle index 68233f95179..45805fe490b 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -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' + } + } } diff --git a/framework/tests/annotationclassloader/Makefile b/framework/tests/annotationclassloader/Makefile index 014277e2281..708ca0abf01 100644 --- a/framework/tests/annotationclassloader/Makefile +++ b/framework/tests/annotationclassloader/Makefile @@ -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 @@ -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: @@ -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 + diff --git a/settings.gradle b/settings.gradle index 6484db86fca..3a4a82a3276 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,6 +7,7 @@ include 'checker-qual' include 'checker-qual-android' include 'checker-util' include 'framework-test' +include 'docs' /* NO-AFU includeBuild ('../annotation-tools/annotation-file-utilities') {