From 956002e7c3fec0eb40bafe07fc44b1e46b1fc253 Mon Sep 17 00:00:00 2001 From: vdemedes Date: Wed, 11 Nov 2015 19:45:21 +0100 Subject: [PATCH] fail when tests executed without cli --- index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.js b/index.js index 9b16b7bc2e..6b7459769d 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,24 @@ 'use strict'; var setImmediate = require('set-immediate-shim'); var hasFlag = require('has-flag'); +var relative = require('path').relative; var serializeError = require('serialize-error'); var Runner = require('./lib/runner'); +var log = require('./lib/logger'); var runner = new Runner(); +// check if the test is being run without AVA cli +var isForked = typeof process.send === 'function'; + +if (!isForked) { + var path = relative('.', process.argv[1]); + + log.write(); + log.error('Test files must be run with the AVA CLI:\n\n $ ava ' + path + '\n'); + + process.exit(1); +} + // if fail-fast is enabled, use this variable to detect, // that no more tests should be logged var isFailed = false;