Split tests

parent 000beeb4
......@@ -33,28 +33,26 @@ masterJobLinux:
only:
- master
testJobLinux:
integrationMXNetJobLinux:
stage: linux
image: registry.git.rwth-aachen.de/monticore/embeddedmontiarc/generators/emadl2cpp/integrationtests/mxnet:v0.0.1
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml -Dtest=IntegrationMXNetTest
only:
- oneclick_nn_training
masterJobWindows:
stage: windows
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml -Dtest=!IntegrationMXNetTest
tags:
- Windows10
except:
- oneclick_nn_training
BranchJobLinux:
stage: linux
image: maven:3-jdk-8
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml -Dtest=!IntegrationMXNetTest
- cat target/site/jacoco/index.html
except:
- master
......@@ -41,28 +41,6 @@ import static org.junit.Assert.assertFalse;
public class GenerationTest extends AbstractSymtabTest {
private Path cifarTrainingHashFile = Paths.get("./target/generated-sources-emadl/cifar10/CifarNetwork.training_hash");
private void createHashFile() {
try {
cifarTrainingHashFile.toFile().getParentFile().mkdirs();
List<String> lines = Arrays.asList("AF9A637D700CB002266D20BF242F4A59#27150AFBB0093AE0914C701ECA0E0040#C4C23549E737A759721D6694C75D9771#5AF0CE68E408E8C1F000E49D72AC214A");
Files.write(cifarTrainingHashFile, lines, Charset.forName("UTF-8"));
}
catch(Exception e) {
assertFalse("Hash file could not be created", true);
}
}
private void deleteHashFile() {
try {
Files.delete(cifarTrainingHashFile);
}
catch(Exception e) {
assertFalse("Could not delete hash file", true);
}
}
@Before
public void setUp() {
// ensure an empty log
......@@ -192,57 +170,4 @@ public class GenerationTest extends AbstractSymtabTest {
} catch(IOException e){
}
}
@Test
public void testDontRetrain1() {
// The training hash is stored during the first training, so the second one is skipped
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty());
Log.getFindings().clear();
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
deleteHashFile();
}
@Test
public void testDontRetrain2() {
// The training hash is written manually, so even the first training should be skipped
Log.getFindings().clear();
createHashFile();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
deleteHashFile();
}
@Test
public void testDontRetrain3() {
// Multiple instances of the first NN are used. Only the first one should cause a training
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "instanceTestCifar.MainC", "-b", "MXNET"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
}
@Test
public void testForceRetrain() {
// The training hash is written manually, but training is forced
Log.getFindings().clear();
createHashFile();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET", "-f", "y"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty());
deleteHashFile();
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.monticar.emadl;
import de.monticore.lang.monticar.emadl.generator.Backend;
import de.monticore.lang.monticar.emadl.generator.EMADLGenerator;
import de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
public class IntegrationMXNetTest extends AbstractSymtabTest {
private Path cifarTrainingHashFile = Paths.get("./target/generated-sources-emadl/cifar10/CifarNetwork.training_hash");
private void createHashFile() {
try {
cifarTrainingHashFile.toFile().getParentFile().mkdirs();
List<String> lines = Arrays.asList("AF9A637D700CB002266D20BF242F4A59#27150AFBB0093AE0914C701ECA0E0040#C4C23549E737A759721D6694C75D9771#5AF0CE68E408E8C1F000E49D72AC214A");
Files.write(cifarTrainingHashFile, lines, Charset.forName("UTF-8"));
}
catch(Exception e) {
assertFalse("Hash file could not be created", true);
}
}
private void deleteHashFile() {
try {
Files.delete(cifarTrainingHashFile);
}
catch(Exception e) {
assertFalse("Could not delete hash file", true);
}
}
@Before
public void setUp() {
// ensure an empty log
Log.getFindings().clear();
Log.enableFailQuick(false);
}
@Test
public void testDontRetrain1() {
// The training hash is stored during the first training, so the second one is skipped
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty());
Log.getFindings().clear();
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
deleteHashFile();
}
@Test
public void testDontRetrain2() {
// The training hash is written manually, so even the first training should be skipped
Log.getFindings().clear();
createHashFile();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
deleteHashFile();
}
@Test
public void testDontRetrain3() {
// Multiple instances of the first NN are used. Only the first one should cause a training
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "instanceTestCifar.MainC", "-b", "MXNET"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
}
@Test
public void testForceRetrain() {
// The training hash is written manually, but training is forced
Log.getFindings().clear();
createHashFile();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET", "-f", "y"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty());
deleteHashFile();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment