<commit_before>######################################################################
# Testing variables
######################################################################

ALL_TEST_INPUTS = $(wildcard $(S)src/test/*/*.rs   \
                              $(S)src/test/*/*/*.rs \
                              $(S)src/test/*/*.rc)

RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)

RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
BENCH_TESTS := $(BENCH_RS)
PRETTY_TESTS := $(PRETTY_RS)

FT := run_pass_stage2
FT_LIB := $(call CFG_LIB_NAME,$(FT))
FT_DRIVER := $(FT)_driver
GENERATED += test/$(FT).rc test/$(FT_DRIVER).rs

# The arguments to all test runners
ifdef TESTNAME
  TESTARGS += $(TESTNAME)
endif

ifdef CHECK_XFAILS
  TESTARGS += --ignored
endif

# Arguments to the cfail/rfail/rpass/bench tests
ifdef CFG_VALGRIND
  CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
endif

CTEST_TESTARGS := $(TESTARGS)

ifdef VERBOSE
  CTEST_TESTARGS += --verbose
endif

# The test runner that runs the cfail/rfail/rpass and bench tests
COMPILETEST_CRATE := $(S)src/test/compiletest/compiletest.rc
COMPILETEST_INPUTS := $(wildcard $(S)src/test/compiletest/*rs)

# The standard library test crate
STDTEST_CRATE := $(S)src/test/stdtest/stdtest.rc
STDTEST_INPUTS := $(wildcard $(S)src/test/stdtest/*rs)

# Run the compiletest runner itself under valgrind
ifdef CTEST_VALGRIND
  CFG_RUN_CTEST=$(call CFG_RUN_TEST,$(2))
else
  CFG_RUN_CTEST=$(call CFG_RUN,stage$(1)/lib,$(2))
endif

######################################################################
# Main test targets
######################################################################

check: tidy check-stage2 \

check-full: tidy check-stage1 check-stage2 check-stage3 \

check-fast: tidy \
	check-stage2-rustc check-stage2-std \
	test/$(FT_DRIVER).out \

tidy:
	@$(call E, check: formatting)
	$(Q)echo \
	  $(filter-out $(GENERATED) $(addprefix $(S)src/, $(GENERATED)) \
	    $(addprefix $(S)src/, $(RUSTLLVM_LIB_CS) $(RUSTLLVM_OBJS_CS) \
	      $(RUSTLLVM_HDR) $(PKG_3RDPARTY)) \
	    $(S)src/etc/%, $(PKG_FILES)) \
	  | xargs -n 10 python $(S)src/etc/tidy.py

# Cancel the implicit .out rule in GNU make
%.out: %

%.out: %.out.tmp
	$(Q)mv $< $@


######################################################################
# Rules for the test runners
######################################################################

# StageN template: to stay consistent with stageN.mk, arge 2 is the
# stage being tested, arg 1 is stage N-1

define TEST_STAGEN

# FIXME: These rules are complicated by a scheme to produce .out files
# for each test, with the idea that if the targets produce actual
# output, subsequent "make check's" will just exit successfully
# without re-running the tests. Unfortunately this scheme is currently
# broken and the tests rerun with every invocation of "make check"
# anyway. Nobody seems to have noticed, so it would be simpler to just
# remove all the code here involved with producing .out files.

check-stage$(2): tidy \
	check-stage$(2)-rustc \
	check-stage$(2)-std \
	check-stage$(2)-rpass \
	check-stage$(2)-rfail \
	check-stage$(2)-cfail \
	check-stage$(2)-bench \


# Rules for the standard library test runner

check-stage$(2)-std: test/stdtest.stage$(2).out \

test/stdtest.stage$(2)$$(X): $$(STDTEST_CRATE) $$(STDTEST_INPUTS) \
                             $$(SREQ$(2))
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(2)) -o $$@ $$< --test

test/stdtest.stage$(2).out.tmp: test/stdtest.stage$(2)$$(X)
	@$$(call E, run: $$<)
	$$(Q)$$(call CFG_RUN_TEST,$$<) $$(TESTARGS)<commit_msg>Run pretty-printer tests as part of make check. Issue #789<commit_after>######################################################################
# Testing variables
######################################################################

ALL_TEST_INPUTS = $(wildcard $(S)src/test/*/*.rs   \
                              $(S)src/test/*/*/*.rs \
                              $(S)src/test/*/*.rc)

RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)

RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
BENCH_TESTS := $(BENCH_RS)
PRETTY_TESTS := $(PRETTY_RS)

FT := run_pass_stage2
FT_LIB := $(call CFG_LIB_NAME,$(FT))
FT_DRIVER := $(FT)_driver
GENERATED += test/$(FT).rc test/$(FT_DRIVER).rs

# The arguments to all test runners
ifdef TESTNAME
  TESTARGS += $(TESTNAME)
endif

ifdef CHECK_XFAILS
  TESTARGS += --ignored
endif

# Arguments to the cfail/rfail/rpass/bench tests
ifdef CFG_VALGRIND
  CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
endif

CTEST_TESTARGS := $(TESTARGS)

ifdef VERBOSE
  CTEST_TESTARGS += --verbose
endif

# The test runner that runs the cfail/rfail/rpass and bench tests
COMPILETEST_CRATE := $(S)src/test/compiletest/compiletest.rc
COMPILETEST_INPUTS := $(wildcard $(S)src/test/compiletest/*rs)

# The standard library test crate
STDTEST_CRATE := $(S)src/test/stdtest/stdtest.rc
STDTEST_INPUTS := $(wildcard $(S)src/test/stdtest/*rs)

# Run the compiletest runner itself under valgrind
ifdef CTEST_VALGRIND
  CFG_RUN_CTEST=$(call CFG_RUN_TEST,$(2))
else
  CFG_RUN_CTEST=$(call CFG_RUN,stage$(1)/lib,$(2))
endif

######################################################################
# Main test targets
######################################################################

check: tidy check-stage2 \

check-full: tidy check-stage1 check-stage2 check-stage3 \

check-fast: tidy \
	check-stage2-rustc check-stage2-std \
	test/$(FT_DRIVER).out \

tidy:
	@$(call E, check: formatting)
	$(Q)echo \
	  $(filter-out $(GENERATED) $(addprefix $(S)src/, $(GENERATED)) \
	    $(addprefix $(S)src/, $(RUSTLLVM_LIB_CS) $(RUSTLLVM_OBJS_CS) \
	      $(RUSTLLVM_HDR) $(PKG_3RDPARTY)) \
	    $(S)src/etc/%, $(PKG_FILES)) \
	  | xargs -n 10 python $(S)src/etc/tidy.py

# Cancel the implicit .out rule in GNU make
%.out: %

%.out: %.out.tmp
	$(Q)mv $< $@


######################################################################
# Rules for the test runners
######################################################################

# StageN template: to stay consistent with stageN.mk, arge 2 is the
# stage being tested, arg 1 is stage N-1

define TEST_STAGEN

# FIXME: These rules are complicated by a scheme to produce .out files
# for each test, with the idea that if the targets produce actual
# output, subsequent "make check's" will just exit successfully
# without re-running the tests. Unfortunately this scheme is currently
# broken and the tests rerun with every invocation of "make check"
# anyway. Nobody seems to have noticed, so it would be simpler to just
# remove all the code here involved with producing .out files.

check-stage$(2): tidy \
	check-stage$(2)-rustc \
	check-stage$(2)-std \
	check-stage$(2)-rpass \
	check-stage$(2)-rfail \
	check-stage$(2)-cfail \
	check-stage$(2)-bench \
	check-stage$(2)-pretty \


# Rules for the standard library test runner

check-stage$(2)-std: test/stdtest.stage$(2).out \

test/stdtest.stage$(2)$$(X): $$(STDTEST_CRATE) $$(STDTEST_INPUTS) \
                             $$(SREQ$(2))
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(2)) -o $$@ $$< --test

test/stdtest.stage$(2).out.tmp: test/stdtest.stage$(2)$$(X)
	@$$(call E, run: $$<)
	$$(Q)$$(call CFG_RUN_TEST,$$<) $$(TESTARGS)
{'fraction_non_alphanumeric': 0.25536400843358553, 'fraction_numerical': 0.007937492248542725, 'mean_word_length': 4.441295546558704, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3159475', 'n_tokens_mistral': 2876, 'n_tokens_neox': 2746, 'n_words': 643}