From dc74631f31099dec6f91d437991192ab8858cea2 Mon Sep 17 00:00:00 2001 From: Julian Godesa Date: Sun, 25 Feb 2018 19:22:41 +0100 Subject: [PATCH] #94 - Rename connectBench helper files Importing the testing package in a file, which is used by the main binary, will pollute the flags package with testing help usage messages. This hinders the usage of the neoism package in a cli application. The file benchmark_test*.go are loading the testing package and are therefore responsible for the flag pollution. To exclude the benchmark_connect helpers one can suffix the files with _test. This will ensure that the benchmark_connect helpers are only loaded during testing and do not pollute the main binary. Another solution would be to introduce a neoism_test package, which would result a massive code reorganization. --- benchmark_gae_test.go | 30 ++++++++++++++++++++++++++++++ benchmark_standalone_test.go | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 benchmark_gae_test.go create mode 100644 benchmark_standalone_test.go diff --git a/benchmark_gae_test.go b/benchmark_gae_test.go new file mode 100644 index 0000000..6ef4e11 --- /dev/null +++ b/benchmark_gae_test.go @@ -0,0 +1,30 @@ +// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under +// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. +// Resist intellectual serfdom - the ownership of ideas is akin to slavery. + +// +build appengine + +package neoism + +import ( + "log" + "testing" + + "appengine/aetest" +) + +func connectBench(b *testing.B) *Database { + gaeContext, err := aetest.NewContext(nil) + if err != nil { + b.Fatal(err) + } + defer gaeContext.Close() + + log.SetFlags(log.Ltime | log.Lshortfile) + db, err := Connect("http://localhost:7474/db/data", gaeContext) + + if err != nil { + b.Fatal(err) + } + return db +} diff --git a/benchmark_standalone_test.go b/benchmark_standalone_test.go new file mode 100644 index 0000000..24ffa97 --- /dev/null +++ b/benchmark_standalone_test.go @@ -0,0 +1,21 @@ +// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under +// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details. +// Resist intellectual serfdom - the ownership of ideas is akin to slavery. + +// +build !appengine + +package neoism + +import ( + "log" + "testing" +) + +func connectBench(b *testing.B) *Database { + log.SetFlags(log.Ltime | log.Lshortfile) + db, err := Connect("http://localhost:7474/db/data") + if err != nil { + b.Fatal(err) + } + return db +}