blob: 9fdbfcc31ee2bf52b536b3e5c0d06c61fedc8bd3 [file] [log] [blame]
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package testing
import (
// verifier is a global singleton to check if AddTest() is used as designed.
var verifier = newCallerVerifier(
// RegistrationErrors returns errors generated by calls to AddTest.
func RegistrationErrors() []error {
return testing.GlobalRegistry().Errors()
// AddTest adds test t to the global registry.
// This should be called only once in a test main file's init(),
// and it should be the top level statement of the init()'s body.
// The argument of AddTest() in the case should be a pointer to a
// composite literal of testing.Test.
func AddTest(t *Test) {
if err := verifier.verifyAndRegister(caller.Func(2)); err != nil {
// AddService adds service s to the global registry.
// This should be called only once in a service main file's init().
func AddService(s *Service) {
// AddFixture adds fixture f to the global registry.
func AddFixture(f *Fixture) {
pkg, _ := packages.SplitFuncName(caller.Get(2))
testing.GlobalRegistry().AddFixture(f, pkg)