<commit_before>/*******************************************************************************
 * Copyright (c) 2017 Inria and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Inria - initial API and implementation
 *******************************************************************************/
package fr.inria.diverse.melange.tests.eclipse

import com.google.inject.Inject
import fr.inria.diverse.melange.ui.tests.MelangeUiInjectorProvider
import fr.inria.diverse.melange.tests.eclipse.shared.WorkspaceTestHelper
import org.eclipse.core.resources.IProject
import org.eclipse.xtext.junit4.AbstractXtextTests
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.junit.After
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.Test
import org.eclipse.jdt.core.JavaCore
import java.nio.file.Files
import java.nio.file.Paths

@RunWith(XtextRunner)
@InjectWith(MelangeUiInjectorProvider)
@FixMethodOrder(MethodSorters::NAME_ASCENDING)
public class MiniFsmTest extends AbstractXtextTests
{
	@Inject WorkspaceTestHelper helper
	IProject melangeProject
	static final String PROJECT_NAME = "fr.inria.diverse.melange.fsm"
	static final String MELANGE_FILE = PROJECT_NAME+"/src/fr/inria/diverse/melanger/Main.melange"
	
	@Before
	override setUp() {
		helper.setTargetPlatform
		if (!helper.projectExists(PROJECT_NAME)) {
			super.setUp
			helper.init
			IResourcesSetupUtil::cleanWorkspace
			
			helper.deployMelangeProject("fr.inria.diverse.minifsm","tests-inputs/minifsm/fr.inria.diverse.minifsm.zip")
			helper.deployMelangeProject("fr.inria.diverse.minifsm.interpreter","tests-inputs/minifsm/fr.inria.diverse.minifsm.interpreter.zip")
			helper.deployMelangeProject("fr.inria.diverse.minilang","tests-inputs/minifsm/fr.inria.diverse.minilang.zip")
			helper.deployMelangeProject("fr.inria.diverse.minilang.interpreter","tests-inputs/minifsm/fr.inria.diverse.minilang.interpreter.zip")
			melangeProject = helper.deployMelangeProject(PROJECT_NAME,"tests-inputs/minifsm/fr.inria.diverse.melange.fsm.zip")
			
			IResourcesSetupUtil::reallyWaitForAutoBuild
			helper.cleanAll(MELANGE_FILE)
			IResourcesSetupUtil::reallyWaitForAutoBuild
			helper.openEditor(MELANGE_FILE)
		} else {
			melangeProject = helper.getProject(PROJECT_NAME)
		}
	}

	@After
	override tearDown() {
		// Nope
	}
	
	@Test
	def void test0NoErrorsInWorkspace() {
		helper.generateAll(MELANGE_FILE)
		IResourcesSetupUtil::reallyWaitForAutoBuild
		helper.assertNoMarkers
		
		helper.assertProjectExists(PROJECT_NAME)<commit_msg>perform full build before generating using melange<commit_after>/*******************************************************************************
 * Copyright (c) 2017 Inria and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Inria - initial API and implementation
 *******************************************************************************/
package fr.inria.diverse.melange.tests.eclipse

import com.google.inject.Inject
import fr.inria.diverse.melange.ui.tests.MelangeUiInjectorProvider
import fr.inria.diverse.melange.tests.eclipse.shared.WorkspaceTestHelper
import org.eclipse.core.resources.IProject
import org.eclipse.xtext.junit4.AbstractXtextTests
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.junit.After
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.Test
import org.eclipse.jdt.core.JavaCore
import java.nio.file.Files
import java.nio.file.Paths

@RunWith(XtextRunner)
@InjectWith(MelangeUiInjectorProvider)
@FixMethodOrder(MethodSorters::NAME_ASCENDING)
public class MiniFsmTest extends AbstractXtextTests
{
	@Inject WorkspaceTestHelper helper
	IProject melangeProject
	static final String PROJECT_NAME = "fr.inria.diverse.melange.fsm"
	static final String MELANGE_FILE = PROJECT_NAME+"/src/fr/inria/diverse/melanger/Main.melange"
	
	@Before
	override setUp() {
		helper.setTargetPlatform
		if (!helper.projectExists(PROJECT_NAME)) {
			super.setUp
			helper.init
			IResourcesSetupUtil::cleanWorkspace
			
			helper.deployMelangeProject("fr.inria.diverse.minifsm","tests-inputs/minifsm/fr.inria.diverse.minifsm.zip")
			helper.deployMelangeProject("fr.inria.diverse.minifsm.interpreter","tests-inputs/minifsm/fr.inria.diverse.minifsm.interpreter.zip")
			helper.deployMelangeProject("fr.inria.diverse.minilang","tests-inputs/minifsm/fr.inria.diverse.minilang.zip")
			helper.deployMelangeProject("fr.inria.diverse.minilang.interpreter","tests-inputs/minifsm/fr.inria.diverse.minilang.interpreter.zip")
			melangeProject = helper.deployMelangeProject(PROJECT_NAME,"tests-inputs/minifsm/fr.inria.diverse.melange.fsm.zip")
			
			IResourcesSetupUtil::reallyWaitForAutoBuild
			helper.cleanAll(MELANGE_FILE)
			IResourcesSetupUtil::reallyWaitForAutoBuild
			helper.openEditor(MELANGE_FILE)
		} else {
			melangeProject = helper.getProject(PROJECT_NAME)
		}
	}

	@After
	override tearDown() {
		// Nope
	}
	
	@Test
	def void test0NoErrorsInWorkspace() {
		IResourcesSetupUtil::fullBuild
		IResourcesSetupUtil::reallyWaitForAutoBuild
		helper.generateAll(MELANGE_FILE)
		IResourcesSetupUtil::reallyWaitForAutoBuild
		helper.assertNoMarkers
		
		helper.assertProjectExists(PROJECT_NAME)
{'fraction_non_alphanumeric': 0.14515588333892054, 'fraction_numerical': 0.003352329869259135, 'mean_word_length': 5.978947368421053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '425825', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1849, 'n_words': 279}