Split unit tests into separate directories (#1761)

The unit tests should follow the component structure, so this patch
moves all `jerry-core` unit tests under `tests/unit-core` and the
`jerry-libm` unit tests under `tests/unit-libm`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
This commit is contained in:
Akos Kiss authored and yichoi committed 2017-04-22 10:57:45 +09:00
1 parent 66ade0d81c
commit 6ca8319aea
20 files changed
+60 -15

No files matched your search

+4 -1
View File
@@ -239,5 +239,8 @@ endif()
# Unittests # Unittests
if(UNITTESTS) if(UNITTESTS)
add_subdirectory(tests/unit) add_subdirectory(tests/unit-core)
if(JERRY_LIBM)
add_subdirectory(tests/unit-libm)
endif()
endif() endif()
@@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
cmake_minimum_required (VERSION 2.8.12) cmake_minimum_required (VERSION 2.8.12)
project (Unittest C) project (unit-core C)
if (NOT IS_ABSOLUTE ${FEATURE_PROFILE}) if (NOT IS_ABSOLUTE ${FEATURE_PROFILE})
set(FEATURE_PROFILE "${CMAKE_SOURCE_DIR}/jerry-core/profiles/${FEATURE_PROFILE}.profile") set(FEATURE_PROFILE "${CMAKE_SOURCE_DIR}/jerry-core/profiles/${FEATURE_PROFILE}.profile")
@@ -27,7 +27,7 @@ endif()
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES *.c) file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES *.c)
# Unit tests declaration # Unit tests declaration
add_custom_target(unittests) add_custom_target(unittests-core)
foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES}) foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE) get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
@@ -41,5 +41,5 @@ foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
target_link_libraries(${TARGET_NAME} jerry-core) target_link_libraries(${TARGET_NAME} jerry-core)
add_dependencies(unittests ${TARGET_NAME}) add_dependencies(unittests-core ${TARGET_NAME})
endforeach() endforeach()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+41
View File
@@ -0,0 +1,41 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required (VERSION 2.8.12)
project (unit-libm C)
# Unit tests main modules
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES *.c)
# Unit tests declaration
add_custom_target(unittests-libm)
foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
set(TARGET_NAME unit-${TARGET_NAME})
add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON}")
link_directories(${CMAKE_BINARY_DIR})
set(TARGET_LIBS jerry-libm)
if(JERRY_LIBC)
set(TARGET_LIBS ${TARGET_LIBS} jerry-libc)
endif()
target_link_libraries(${TARGET_NAME} ${TARGET_LIBS})
add_dependencies(unittests-libm ${TARGET_NAME})
endforeach()
@@ -17,7 +17,10 @@
* Unit test for jerry-libm * Unit test for jerry-libm
*/ */
#include "test-common.h" #include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
static bool passed = true; static bool passed = true;
@@ -13,10 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
/* /* This file is automatically generated by the gen-test-libm.sh script.
* Generated by tools/gen-test-libm.sh * Do not edit! */
* DO NOT EDIT!!!
*/
check_double ("acos (0.0)", acos (0.0), 1.57079632679489655800E+00); check_double ("acos (0.0)", acos (0.0), 1.57079632679489655800E+00);
check_double ("acos (-0.0)", acos (-0.0), 1.57079632679489655800E+00); check_double ("acos (-0.0)", acos (-0.0), 1.57079632679489655800E+00);
check_double ("acos (1.0)", acos (1.0), 0.00000000000000000000E+00); check_double ("acos (1.0)", acos (1.0), 0.00000000000000000000E+00);
+1 -1
View File
@@ -15,5 +15,5 @@
# limitations under the License. # limitations under the License.
make -C tools/unit-tests build make -C tools/unit-tests build
tools/unit-tests/gen-test-libm >tests/unit/test-libm.inc.h tools/unit-tests/gen-test-libm >tests/unit-libm/test-libm.inc.h
make -C tools/unit-tests clean make -C tools/unit-tests clean
+4 -5
View File
@@ -32,7 +32,7 @@
int int
main (int argc, char **args) main (int argc, char **args)
{ {
printf ("/* Copyright JS Foundation and other contributors, http://js.foundation printf ("/* Copyright JS Foundation and other contributors, http://js.foundation\n"
" *\n" " *\n"
" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" " * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
" * you may not use this file except in compliance with the License.\n" " * you may not use this file except in compliance with the License.\n"
@@ -47,10 +47,9 @@ main (int argc, char **args)
" * limitations under the License.\n" " * limitations under the License.\n"
" */\n" " */\n"
"\n" "\n"
"/*\n" "/* This file is automatically generated by the gen-test-libm.sh script.\n"
" * Generated by tools/gen-test-libm.sh\n" " * Do not edit! */\n"
" * DO NOT EDIT!!!\n" "\n");
" */\n");
/* acos tests */ /* acos tests */
GEN_DBL_TEST (acos (0.0)); GEN_DBL_TEST (acos (0.0));