Skip to content
Snippets Groups Projects
Commit 0e9a3ace authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

start broker

parent aa2399af
No related branches found
No related tags found
No related merge requests found
......@@ -49,3 +49,8 @@ endif()
if(BUILD_DOCS)
include(doxygen)
endif()
if (BUILD_BROKER)
add_subdirectory(broker)
endif()
\ No newline at end of file
#!/bin/bash
OUT_DIR=$1
HIDRA2_MINIMUM_COVERAGE=$2
echo $OUT_DIR
mapfile -t PACKAGES < <( find ./src -type d -not -path '*/\.*' )
echo "mode: count" > $OUT_DIR/coverage-all.out
for pkg in ${PACKAGES[@]}
do
# echo $pkg
go test -coverprofile=$OUT_DIR/coverage.out $pkg #>/dev/null 2>&1
tail -n +2 $OUT_DIR/coverage.out >> $OUT_DIR/coverage-all.out #2>/dev/null
done
coverage=`go tool cover -func=$OUT_DIR/coverage-all.out | grep total | cut -d ")" -f 2 | cut -d "." -f 1`
#firefox ./coverage.html &
go tool cover -html=$OUT_DIR/coverage-all.out -o ${OUT_DIR}/coverage.html
rm -rf ${OUT_DIR}/coverage-all.out ${OUT_DIR}/coverage.out
if (( coverage < HIDRA2_MINIMUM_COVERAGE )); then
exec >&2
echo
echo "*****"
echo
echo coverage is ${coverage}% - less than required ${HIDRA2_MINIMUM_COVERAGE}%
echo
echo "*****"
echo
exit 1
fi
if (BUILD_TESTS)
enable_testing()
endif ()
if (BUILD_TESTS)
set(HIDRA2_MINIMUM_COVERAGE 90)
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS
"--trace-children=yes --leak-check=full --error-exitcode=1 --suppressions=${CMAKE_SOURCE_DIR}/tests/valgrind.suppressions")
endif ()
function(gotest target test_source_files)
if (BUILD_TESTS)
add_test(NAME test-${target} COMMAND go test ${test_source_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_property(
TEST
test-${target}
PROPERTY
ENVIRONMENT GOPATH=${gopath})
message(STATUS "Added test 'test-${target}'")
add_test(NAME coveragetest-${target}
COMMAND ${CMAKE_MODULE_PATH}/coverage_go.sh
${CMAKE_CURRENT_BINARY_DIR} ${HIDRA2_MINIMUM_COVERAGE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()
endfunction()
set (TARGET_NAME hidra2-broker)
set (gopath $ENV{GOPATH}:${CMAKE_CURRENT_SOURCE_DIR})
include(testing_go)
message(STATUS ${gopath})
add_custom_target(hidra2-broker ALL
COMMAND GOPATH=${gopath} go build ${GO_OPTS} -o ${TARGET_NAME} main
VERBATIM)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} DESTINATION bin)
gotest(${TARGET_NAME} "./...")
\ No newline at end of file
package main
import (
"test"
"test2"
)
func main() {
test.Test_Hidra2()
test2.Test_Hidra2()
}
package test
import "fmt"
func Test_Hidra2() {
fmt.Println("aaa")
}
package test
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCreateRecord(t *testing.T) {
Test_Hidra2()
assert.Equal(t, "111", "111", "record created")
}
package test2
import "fmt"
func Test_Hidra2() {
fmt.Println("aaa")
a := new([100]int)
fmt.Println(a)
}
package test2
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCreateRecord(t *testing.T) {
Test_Hidra2()
assert.Equal(t, "111", "111", "record created")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment