generated from threeal/cmake-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for testing
setup_go
function
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.19) | ||
cmake_minimum_required(VERSION 3.29) | ||
|
||
project( | ||
SetupGo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Matches everything if not defined | ||
if(NOT TEST_MATCHES) | ||
set(TEST_MATCHES ".*") | ||
endif() | ||
|
||
set(TEST_COUNT 0) | ||
|
||
include(SetupGo) | ||
|
||
if("Set up the latest version of Go" MATCHES ${TEST_MATCHES}) | ||
math(EXPR TEST_COUNT "${TEST_COUNT} + 1") | ||
|
||
setup_go() | ||
|
||
if(NOT DEFINED GO_EXECUTABLE) | ||
message(FATAL_ERROR "The GO_EXECUTABLE variable should be defined") | ||
endif() | ||
|
||
if(NOT EXISTS ${GO_EXECUTABLE}) | ||
message(FATAL_ERROR "The Go executable at '${GO_EXECUTABLE}' should exist") | ||
endif() | ||
|
||
if(NOT IS_EXECUTABLE ${GO_EXECUTABLE}) | ||
message(FATAL_ERROR "The Go executable at '${GO_EXECUTABLE}' should be executable") | ||
endif() | ||
|
||
execute_process( | ||
COMMAND ${GO_EXECUTABLE} version | ||
RESULT_VARIABLE RES | ||
) | ||
if(NOT RES EQUAL 0) | ||
message(FATAL_ERROR "It should not fail to execute the Go executable") | ||
endif() | ||
endif() | ||
|
||
if(TEST_COUNT LESS_EQUAL 0) | ||
message(FATAL_ERROR "Nothing to test with: ${TEST_MATCHES}") | ||
endif() |