<commit_before>#Test that the testing tools run!
ADD_TEST(NAME SelfTest_verify10 COMMAND verify10)
set_tests_properties(SelfTest_verify10 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*verify10_DIFF I\\/O error, wrong no of lines\\!\\!\\?\\? line no *0")

ADD_TEST(NAME SelfTest_checkf10 COMMAND checkf10)
set_tests_properties(SelfTest_checkf10 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*checkf10_DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_compf10 COMMAND compf10)
set_tests_properties(SelfTest_compf10 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*compf10_DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_checkf110 COMMAND checkf110)
set_tests_properties(SelfTest_checkf110 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_checkf1014 COMMAND checkf1014)
set_tests_properties(SelfTest_checkf1014 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*checkf1014_DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_read90 COMMAND read90)
set_tests_properties(SelfTest_read90 PROPERTIES PASS_REGULAR_EXPRESSION "At line .* of file .*read90.f90 \\(unit = 190\\)\nFortran runtime error: Cannot open file 'fort.190': No such file or directory")

#SET(SIXTRACK_TESTS bbe51 bbe52 bbe571ib0 bb bb_ntwin1 crabamp dipedge distance dynk_globalvars elensidealthck4d elensidealthck6d elensidealthin4d elensidealthin6d_DYNK elensidealthin6d eric exact fma frs60 frs javier lostevery lost lostnotilt notilt prob1 prob3 s316 thick4 thick6dblocks thick6ddynk tilt ${SIXTRACK_TESTS})

##
## Needs checking: thick6dsingles (missing files)
## thick6dblocks elensidealthck6d dynk_globalvars thick6ddynk - empty fort.10
## Disabled: elensidealthin6d_DYNK
## "Totally untested": bnl
##

#List of tests which are STF compatible
SET(STF_TESTS bbe51 bbe52 bbe571ib0 bb_ntwin1 bb crabamp dipedge distance elensidealthck4d elensidealthin4d elensidealthin6d eric exact fma frs60 frs javier_bignpart javier lostevery lostnotilt lost notilt prob1 prob3 s316 thick4 tilt)

#only turn on the bnl test if we have BNLELENS enabled due to slight differences in the test
if(BNLELENS)
	SET(SIXTRACK_TESTS bnl ${SIXTRACK_TESTS})
endif(BNLELENS)

if(BIGNPART OR HUGENPART)
	SET(SIXTRACK_TESTS javier_bignpart ${SIXTRACK_TESTS})
endif()

if(NOT COLLIMAT)
	SET(SIXTRACK_TESTS bbe51 bbe52 bbe571ib0 bb bb_ntwin1 crabamp dipedge distance dynk_globalvars elensidealthin4d elensidealthin6d eric exact frs60 frs javier lostevery lost lostnumxv lostnotilt notilt prob1 prob3 s316 thick4 thick6dblocks tilt elensidealthck4d elensidealthck6d fma thick6ddynk ${SIXTRACK_TESTS})
endif(NOT COLLIMAT)

#For CR builds, test the CR functions, so kill/resume the test
if(CR)
	SET(CR_ENABLE 1)
	SET(CR_KILL_TIME "2,4,8,16,32,64,128,256,512,1024")
else()
	SET(CR_ENABLE 0)
	SET(CR_KILL_TIME 0)
endif(CR)

#Test commands
foreach(TST IN ITEMS ${SIXTRACK_TESTS})

	#determine what we need to do:
	#Check fort.10 by default
	SET(FORT10 1)
	#no fort.10 for the "exact" test
	if(TST MATCHES exact OR TST MATCHES thick6dblocks OR TST MATCHES elensidealthck6d OR TST MATCHES dynk_globalvars OR TST MATCHES thick6ddynk)
		SET(FORT10 0)
	endif()

	#check fort.90 by default
	SET(FORT90 1)
	# if(TST MATCHES lostnumxv )
	# 	SET(FORT90 0)
	# endif()

	#if STF, we need to use the STF flag on read90
	if(STF)
		LIST(FIND STF_TESTS ${TST} IS_STF)
		if(NOT ${IS_STF} MATCHES -1)
			SET(STF_ENABLE 1)
		else()
			SET(STF_ENABLE 0)
		endif()
		##Disable checking fort.90
		SET(FORT90 0)
	else()
		SET(STF_ENABLE 0)
	endif(STF)

	ADD_TEST(NAME ${TST} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/SixTest/${TST} COMMAND SixTestWrapper $<TARGET_FILE:SixTrack> ${FORT10} ${FORT90} ${STF_ENABLE} ${CR_ENABLE} ${CR_KILL_TIME})

	#some tests take a very long time (set a 2 day timeout)
	set_tests_properties(${TST} PROPERTIES TIMEOUT "172800")

endforeach()

#test files
foreach(TST IN ITEMS ${SIXTRACK_TESTS})
	add_custom_target(test_copy_${TST})
	add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/SixTest/${TST}/)

	#link in the test tools
	add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:read90> ${CMAKE_BINARY_DIR}/SixTest/${TST}/read90)
	add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:checkf10> ${CMAKE_BINARY_DIR}/SixTest/${TST}/checkf10)

	file(GLOB TEST_INPUTS LIST_DIRECTORIES FALSE ${CMAKE_SOURCE_DIR}/SixTest/${TST}/*)
	#message(STATUS "${CMAKE_SOURCE_DIR}/../SixTest/${TST}/")

	if(NOT BOINC)
		foreach(TSFILE IN ITEMS ${TEST_INPUTS})
			get_filename_component(TFILE ${TSFILE} NAME)

			#create_symlink old new
			add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${TSFILE} ${CMAKE_BINARY_DIR}/SixTest/${TST}/${TFILE})
		endforeach()
	else()
		add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink Sixin.zip ${CMAKE_BINARY_DIR}/SixTest/${TST}/Sixin.zip)
	endif(NOT BOINC)

	add_dependencies( SixTrack test_copy_${TST})
endforeach()

#add labels to tests
#Lets say fast tests take <60 seconds to run<commit_msg>Fix linking in files for BOINC testing builds.<commit_after>#Test that the testing tools run!
ADD_TEST(NAME SelfTest_verify10 COMMAND verify10)
set_tests_properties(SelfTest_verify10 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*verify10_DIFF I\\/O error, wrong no of lines\\!\\!\\?\\? line no *0")

ADD_TEST(NAME SelfTest_checkf10 COMMAND checkf10)
set_tests_properties(SelfTest_checkf10 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*checkf10_DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_compf10 COMMAND compf10)
set_tests_properties(SelfTest_compf10 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*compf10_DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_checkf110 COMMAND checkf110)
set_tests_properties(SelfTest_checkf110 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_checkf1014 COMMAND checkf1014)
set_tests_properties(SelfTest_checkf1014 PROPERTIES PASS_REGULAR_EXPRESSION "Comparing VERSION    0.0000000000000000 *to *0.0000000000000000.*\n.*checkf1014_DIFF I\\/O error, wrong no of lines\\!\\! line no *0")

ADD_TEST(NAME SelfTest_read90 COMMAND read90)
set_tests_properties(SelfTest_read90 PROPERTIES PASS_REGULAR_EXPRESSION "At line .* of file .*read90.f90 \\(unit = 190\\)\nFortran runtime error: Cannot open file 'fort.190': No such file or directory")

#SET(SIXTRACK_TESTS bbe51 bbe52 bbe571ib0 bb bb_ntwin1 crabamp dipedge distance dynk_globalvars elensidealthck4d elensidealthck6d elensidealthin4d elensidealthin6d_DYNK elensidealthin6d eric exact fma frs60 frs javier lostevery lost lostnotilt notilt prob1 prob3 s316 thick4 thick6dblocks thick6ddynk tilt ${SIXTRACK_TESTS})

##
## Needs checking: thick6dsingles (missing files)
## thick6dblocks elensidealthck6d dynk_globalvars thick6ddynk - empty fort.10
## Disabled: elensidealthin6d_DYNK
## "Totally untested": bnl
##

#List of tests which are STF compatible
SET(STF_TESTS bbe51 bbe52 bbe571ib0 bb_ntwin1 bb crabamp dipedge distance elensidealthck4d elensidealthin4d elensidealthin6d eric exact fma frs60 frs javier_bignpart javier lostevery lostnotilt lost notilt prob1 prob3 s316 thick4 tilt)

#only turn on the bnl test if we have BNLELENS enabled due to slight differences in the test
if(BNLELENS)
	SET(SIXTRACK_TESTS bnl ${SIXTRACK_TESTS})
endif(BNLELENS)

if(BIGNPART OR HUGENPART)
	SET(SIXTRACK_TESTS javier_bignpart ${SIXTRACK_TESTS})
endif()

if(NOT COLLIMAT)
	SET(SIXTRACK_TESTS bbe51 bbe52 bbe571ib0 bb bb_ntwin1 crabamp dipedge distance dynk_globalvars elensidealthin4d elensidealthin6d eric exact frs60 frs javier lostevery lost lostnumxv lostnotilt notilt prob1 prob3 s316 thick4 thick6dblocks tilt elensidealthck4d elensidealthck6d fma thick6ddynk ${SIXTRACK_TESTS})
endif(NOT COLLIMAT)

#For CR builds, test the CR functions, so kill/resume the test
if(CR)
	SET(CR_ENABLE 1)
	SET(CR_KILL_TIME "2,4,8,16,32,64,128,256,512,1024")
else()
	SET(CR_ENABLE 0)
	SET(CR_KILL_TIME 0)
endif(CR)

#Test commands
foreach(TST IN ITEMS ${SIXTRACK_TESTS})

	#determine what we need to do:
	#Check fort.10 by default
	SET(FORT10 1)
	#no fort.10 for the "exact" test
	if(TST MATCHES exact OR TST MATCHES thick6dblocks OR TST MATCHES elensidealthck6d OR TST MATCHES dynk_globalvars OR TST MATCHES thick6ddynk)
		SET(FORT10 0)
	endif()

	#check fort.90 by default
	SET(FORT90 1)
	# if(TST MATCHES lostnumxv )
	# 	SET(FORT90 0)
	# endif()

	#if STF, we need to use the STF flag on read90
	if(STF)
		LIST(FIND STF_TESTS ${TST} IS_STF)
		if(NOT ${IS_STF} MATCHES -1)
			SET(STF_ENABLE 1)
		else()
			SET(STF_ENABLE 0)
		endif()
		##Disable checking fort.90
		SET(FORT90 0)
	else()
		SET(STF_ENABLE 0)
	endif(STF)

	ADD_TEST(NAME ${TST} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/SixTest/${TST} COMMAND SixTestWrapper $<TARGET_FILE:SixTrack> ${FORT10} ${FORT90} ${STF_ENABLE} ${CR_ENABLE} ${CR_KILL_TIME})

	#some tests take a very long time (set a 2 day timeout)
	set_tests_properties(${TST} PROPERTIES TIMEOUT "172800")

endforeach()

#test files
foreach(TST IN ITEMS ${SIXTRACK_TESTS})
	add_custom_target(test_copy_${TST})
	add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/SixTest/${TST}/)

	#link in the test tools
	add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:read90> ${CMAKE_BINARY_DIR}/SixTest/${TST}/read90)
	add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:checkf10> ${CMAKE_BINARY_DIR}/SixTest/${TST}/checkf10)

	file(GLOB TEST_INPUTS LIST_DIRECTORIES FALSE ${CMAKE_SOURCE_DIR}/SixTest/${TST}/*)
	#message(STATUS "${CMAKE_SOURCE_DIR}/../SixTest/${TST}/")

	if(NOT BOINC)
		foreach(TSFILE IN ITEMS ${TEST_INPUTS})
			get_filename_component(TFILE ${TSFILE} NAME)

			#create_symlink old new
			add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${TSFILE} ${CMAKE_BINARY_DIR}/SixTest/${TST}/${TFILE})
		endforeach()
	else()
		add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/SixTest/${TST}/Sixin.zip ${CMAKE_BINARY_DIR}/SixTest/${TST}/Sixin.zip)

		#Also need the canonicals
		file(GLOB TEST_INPUT_CANONICAL LIST_DIRECTORIES FALSE ${CMAKE_SOURCE_DIR}/SixTest/${TST}/*canonical)
		foreach(CANONICAL_FILES IN ITEMS ${TEST_INPUT_CANONICAL})
			get_filename_component(CANONICAL_FILE ${CANONICAL_FILES} NAME)
			add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${CANONICAL_FILES} ${CMAKE_BINARY_DIR}/SixTest/${TST}/${CANONICAL_FILE})
		endforeach()

		#And extra_checks.txt
		file(GLOB TEST_INPUT_EXTRAS LIST_DIRECTORIES FALSE ${CMAKE_SOURCE_DIR}/SixTest/${TST}/extra_checks.txt)
		foreach(EXTRA_FILES IN ITEMS ${TEST_INPUT_EXTRAS})
			get_filename_component(EXTRA_FILE ${EXTRA_FILES} NAME)
			add_custom_command(TARGET test_copy_${TST} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${EXTRA_FILES} ${CMAKE_BINARY_DIR}/SixTest/${TST}/${EXTRA_FILE})
		endforeach()

	endif(NOT BOINC)

	add_dependencies( SixTrack test_copy_${TST})
endforeach()

#add labels to tests
#Lets say fast tests take <60 seconds to run
{'fraction_non_alphanumeric': 0.0985682363651411, 'fraction_numerical': 0.06488454853927005, 'mean_word_length': 6.345896656534954, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 20, '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': '1421159', 'n_tokens_mistral': 5288, 'n_tokens_neox': 4528, 'n_words': 1112}