<commit_before>testConfig = require '../../test-config'
coreModule = require testConfig.project_root + '/src/core'

describe 'Core - env.pluginsEngine module', () ->
	env = {}
	beforeEach () ->
		env = {}
		coreModule(env).initEnv()
		coreModule(env).initConfig()
		coreModule(env).initUtilities()
		coreModule(env).initPluginsEngine(process.cwd() + '/tests')

	it 'env.pluginsEngine.init outside of the \'instance_test\' folder should failed', (done) ->
		logs = []
		env.debug = () ->
			logs.push arguments
		env.pluginsEngine.init process.cwd(), (err) ->
			expect(err).toBe(true)
			expect(logs[0][0]).toBe("An error occured: Error: ENOENT, open \'" + process.cwd() + "/plugins.json\'")
			done()

	it 'env.pluginsEngine.init inside of the \'instance_test\' folder should fail on requiring \'plugin_test\' entry point', (done) ->
		logs = []
		env.debug = () ->
			logs.push arguments
		command = 'rm -rf ' + process.cwd() + '/tests/instance_test/plugins/plugin_test/bin'
		exec = require('child_process').exec
		exec command, (error, stdout, stderr) ->
			expect(error).toBeNull()
			env.pluginsEngine.init process.cwd() + '/tests/instance_test', (err) ->
				expect(err).toBe(false)
				expect(logs[0][0]).toBe("Loading \'plugin_test\'.")
				expect(logs[1][0]).toBe("Error requiring plugin \'plugin_test\' entry point.")
				done()

	it 'env.pluginsEngine.init inside of the \'instance_test\' folder should succeed after grunt in the folder', (done) ->
		logs = []
		env.debug = () ->
			logs.push arguments
		command = 'cd ' + process.cwd() + '/tests/instance_test/plugins/plugin_test && npm install && grunt'
		exec = require('child_process').exec
		exec command, (error, stdout, stderr) ->
			expect(error).toBeNull()
			if not error
				env.pluginsEngine.init process.cwd() + '/tests/instance_test', (err) ->
					expect(err).toBe(false)
					expect(logs[0][0]).toBe("Loading \'plugin_test\'.")
					command = 'rm -rf ' + process.cwd() + '/tests/instance_test/plugins/plugin_test/bin'
					exec = require('child_process').exec
					exec command, (error, stdout, stderr) ->
						expect(error).toBeNull()
					done()

	it 'env.pluginsEngine.load should throw an exception when loading unexisting \'undefined_plugin\'.', (done) ->
		logs = []
		env.debug = () ->
     		logs.push arguments
		try
			expect(env.pluginsEngine.load 'undefined_plugin')
		catch e
			console.log "err", e
		finally
			expect(logs[0][0]).toBe("Loading \'undefined_plugin\'.")
			expect(logs[1][0]).toBe("Absent plugin.json for plugin \'undefined_plugin\'.")
			expect(logs[2][0]).toBe("Error requiring plugin \'undefined_plugin\' entry point.")
			expect(env.pluginsEngine.plugin['undefined_plugin']).toBeUndefined()
			expect(env.plugins['undefined_plugin']).toBeUndefined()
			expect(env.plugins.undefined_plugin).toBeUndefined()
			done()










<commit_msg>check getMyName function of plugin_test<commit_after>testConfig = require '../../test-config'
coreModule = require testConfig.project_root + '/src/core'

describe 'Core - env.pluginsEngine module', () ->
	env = {}
	beforeEach () ->
		env = {}
		coreModule(env).initEnv()
		coreModule(env).initConfig()
		coreModule(env).initUtilities()
		coreModule(env).initPluginsEngine(process.cwd() + '/tests')

	it 'env.pluginsEngine.init outside of the \'instance_test\' folder should failed', (done) ->
		logs = []
		env.debug = () ->
			logs.push arguments
		env.pluginsEngine.init process.cwd(), (err) ->
			expect(err).toBe(true)
			expect(logs[0][0]).toBe("An error occured: Error: ENOENT, open \'" + process.cwd() + "/plugins.json\'")
			done()

	it 'env.pluginsEngine.init inside of the \'instance_test\' folder should fail on requiring \'plugin_test\' entry point', (done) ->
		logs = []
		env.debug = () ->
			logs.push arguments
		command = 'rm -rf ' + process.cwd() + '/tests/instance_test/plugins/plugin_test/bin'
		exec = require('child_process').exec
		exec command, (error, stdout, stderr) ->
			expect(error).toBeNull()
			env.pluginsEngine.init process.cwd() + '/tests/instance_test', (err) ->
				expect(err).toBe(false)
				expect(logs[0][0]).toBe("Loading \'plugin_test\'.")
				expect(logs[1][0]).toBe("Error requiring plugin \'plugin_test\' entry point.")
				done()

	it 'env.pluginsEngine.init inside of the \'instance_test\' folder should succeed after grunt in the folder', (done) ->
		logs = []
		env.debug = () ->
			logs.push arguments
		command = 'cd ' + process.cwd() + '/tests/instance_test/plugins/plugin_test && npm install && grunt'
		exec = require('child_process').exec
		exec command, (error, stdout, stderr) ->
			expect(error).toBeNull()
			if not error
				env.pluginsEngine.init process.cwd() + '/tests/instance_test', (err) ->
					expect(err).toBe(false)
					expect(logs[0][0]).toBe("Loading \'plugin_test\'.")
					expect(env.pluginsEngine.plugin['plugin_test']).toBeDefined()
					expect(env.pluginsEngine.plugin['plugin_test'].getMyName()).toBe("plugin_test")
					command = 'rm -rf ' + process.cwd() + '/tests/instance_test/plugins/plugin_test/bin'
					exec = require('child_process').exec
					exec command, (error, stdout, stderr) ->
						expect(error).toBeNull()
						done()

	it 'env.pluginsEngine.load should throw an exception when loading unexisting \'undefined_plugin\'.', (done) ->
		logs = []
		env.debug = () ->
     		logs.push arguments
		try
			expect(env.pluginsEngine.load 'undefined_plugin')
		catch e
			console.log "err", e
		finally
			expect(logs[0][0]).toBe("Loading \'undefined_plugin\'.")
			expect(logs[1][0]).toBe("Absent plugin.json for plugin \'undefined_plugin\'.")
			expect(logs[2][0]).toBe("Error requiring plugin \'undefined_plugin\' entry point.")
			expect(env.pluginsEngine.plugin['undefined_plugin']).toBeUndefined()
			expect(env.plugins['undefined_plugin']).toBeUndefined()
			expect(env.plugins.undefined_plugin).toBeUndefined()
			done()











{'fraction_non_alphanumeric': 0.1719095391940146, 'fraction_numerical': 0.004761095051861928, 'mean_word_length': 3.9057547956630527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2004349', 'n_tokens_mistral': 2087, 'n_tokens_neox': 1833, 'n_words': 388}