Skip to content

Commit

Permalink
Merge 4c3b4b9 into 819ada7
Browse files Browse the repository at this point in the history
  • Loading branch information
berryzplus authored May 10, 2020
2 parents 819ada7 + 4c3b4b9 commit 00f221c
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/compiletests.run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
setlocal
set BUILD_BASE_DIR=%~dp1
set SOURCE_DIR=%~dp0compiletests

:: find generic tools
if not defined CMD_VSWHERE call %~dp0..\tools\find-tools.bat

set /a NUM_VSVERSION_NEXT=NUM_VSVERSION + 1

if not exist "%CMD_CMAKE%" (
echo "no cmake found."
exit /b 1
)

if not exist "%CMD_NINJA%" (
set GENERATOR="%CMAKE_G_PARAM%"
set GENERATOR_OPTS=-A %PLATFORM% "-DCMAKE_CONFIGURATION_TYPES=Debug;Release"
set "MAKE_PROGRAM=%CMD_MSBUILD%"
set "BUILD_DIR=%BUILD_BASE_DIR%compiletests\%platform%"
) else (
set GENERATOR=Ninja
set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION%
set "MAKE_PROGRAM=%CMD_NINJA%"
set "BUILD_DIR=%BUILD_BASE_DIR%compiletests\%platform%\%configuration%"
)

mkdir %BUILD_DIR% > NUL 2>&1
pushd %BUILD_DIR%

call :run_cmake_configure || endlocal && exit /b 1

endlocal && exit /b 0

:run_cmake_configure
call :find_cl_compiler

:: replace back-slash to slash in the path.
set CL_COMPILER=%CMD_CL:\=/%

:: run cmake configuration.
"%CMD_CMAKE%" -G %GENERATOR% ^
"-DCMAKE_MAKE_PROGRAM=%MAKE_PROGRAM%" ^
"-DCMAKE_C_COMPILER=%CL_COMPILER%" ^
"-DCMAKE_CXX_COMPILER=%CL_COMPILER%" ^
%GENERATOR_OPTS% ^
%SOURCE_DIR% ^
|| endlocal && exit /b 1
goto :EOF

:find_cl_compiler
for /f "usebackq delims=" %%a in (`where cl.exe`) do (
set "CMD_CL=%%a"
goto :EOF
)
goto :EOF
12 changes: 12 additions & 0 deletions tests/compiletests.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This target depends on googletest.targets -->
<Target Name="RunCompileTests" DependsOnTargets="MakeGoogleTestBuildDir;BuildGoogleTest" BeforeTargets="ClCompile">
<PropertyGroup>
<VsVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1'))</VsVersion>
</PropertyGroup>
<SetEnv name="platform" value="$(Platform)" prefix="false" />
<SetEnv name="configuration" value="$(Configuration)" prefix="false" />
<SetEnv name="NUM_VSVERSION" value="$(VsVersion)" prefix="false" />
<Exec Command="$(MSBuildThisFileDirectory)compiletests.run.cmd &quot;$(GoogleTestBuildDir)&quot;" ConsoleToMSBuild="true" />
</Target>
</Project>
20 changes: 20 additions & 0 deletions tests/compiletests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.12)

enable_language(CXX)

message( STATUS "Checking clayoutint_can_not_be_assigned_from_clogicint" )

try_compile(FAILED_TO_TEST001 ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/clayoutint_can_not_be_assigned_from_clogicint.cpp
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CMAKE_CURRENT_SOURCE_DIR}/../../sakura_core"
COMPILE_DEFINITIONS -D_DEBUG -D_UNICODE -DUNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN7
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)

if (NOT FAILED_TO_TEST001)
message( STATUS "Checking clayoutint_can_not_be_assigned_from_clogicint - done" )
else()
message( FATAL_ERROR "Checking clayoutint_can_not_be_assigned_from_clogicint - Failed." )
endif (NOT FAILED_TO_TEST001)
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*! @file */
/*
Copyright (C) 2018-2020 Sakura Editor Organization
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef NOMINMAX
#define NOMINMAX
#endif /* #ifndef NOMINMAX */

#include <tchar.h>
#include <Windows.h>

#ifndef USE_STRICT_INT
#define USE_STRICT_INT
#endif /* #ifndef USE_STRICT_INT */

#include "basis/SakuraBasis.h"

/*!
* @brief テンプレートのテスト
* このファイルはビルドエラーになる
*/
void main()
{
CLayoutInt a( 1 );
CLogicInt b( 2 );

//CLayoutInt に CLogicIntを代入することはできない
a = b;
}
1 change: 1 addition & 0 deletions tests/unittests/tests1.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(ProjectDir)..\googletest.targets" />
<Import Project="$(ProjectDir)..\compiletests.targets" />
<ItemDefinitionGroup Label="tests1.common">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)sakura_core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand Down

0 comments on commit 00f221c

Please sign in to comment.