Skip to content

Commit

Permalink
removed config file dependencies, (#146)
Browse files Browse the repository at this point in the history
finished cli config updates,
fixed missing default resource dir manipulation,
separating arguments via space (instead of =),
fixed tmp path issue when run via neko munit/run.n
  • Loading branch information
dobrusev authored and elsassph committed Dec 22, 2017
1 parent f84433b commit aa3b360
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 27 deletions.
Binary file modified src/index.n
Binary file not shown.
4 changes: 2 additions & 2 deletions src/resource/tests-complete.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/run.n
Binary file not shown.
36 changes: 18 additions & 18 deletions test/TestSuite.hx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import massive.munit.TestSuite;

import massive.munit.AssertionExceptionTest;
import massive.munit.AssertTest;
import massive.munit.async.AsyncDelegateTest;
import massive.munit.TestSuiteTest;
import massive.munit.util.TimerTest;
import massive.munit.util.MathUtilTest;
import massive.munit.MUnitExceptionTest;
import massive.munit.UnhandledExceptionTest;
import massive.munit.async.AsyncFactoryTest;
import massive.munit.async.AsyncTimeoutExceptionTest;
import massive.munit.async.MissingAsyncDelegateExceptionTest;
import massive.munit.client.URLRequestTest;
import massive.munit.MUnitExceptionTest;
import massive.munit.TestClassHelperTest;
import massive.munit.async.AsyncDelegateTest;
import massive.munit.AssertionExceptionTest;
import massive.munit.TestResultTest;
import massive.munit.TestRunnerTest;
import massive.munit.TestSuiteTest;
import massive.munit.UnhandledExceptionTest;
import massive.munit.util.MathUtilTest;
import massive.munit.util.TimerTest;
import massive.munit.client.URLRequestTest;
import massive.munit.TestClassHelperTest;

/**
* Auto generated Test Suite for MassiveUnit.
Expand All @@ -26,20 +26,20 @@ class TestSuite extends massive.munit.TestSuite
{
super();

add(massive.munit.AssertionExceptionTest);
add(massive.munit.AssertTest);
add(massive.munit.async.AsyncDelegateTest);
add(massive.munit.TestSuiteTest);
add(massive.munit.util.TimerTest);
add(massive.munit.util.MathUtilTest);
add(massive.munit.MUnitExceptionTest);
add(massive.munit.UnhandledExceptionTest);
add(massive.munit.async.AsyncFactoryTest);
add(massive.munit.async.AsyncTimeoutExceptionTest);
add(massive.munit.async.MissingAsyncDelegateExceptionTest);
add(massive.munit.client.URLRequestTest);
add(massive.munit.MUnitExceptionTest);
add(massive.munit.TestClassHelperTest);
add(massive.munit.async.AsyncDelegateTest);
add(massive.munit.AssertionExceptionTest);
add(massive.munit.TestResultTest);
add(massive.munit.TestRunnerTest);
add(massive.munit.TestSuiteTest);
add(massive.munit.UnhandledExceptionTest);
add(massive.munit.util.MathUtilTest);
add(massive.munit.util.TimerTest);
add(massive.munit.client.URLRequestTest);
add(massive.munit.TestClassHelperTest);
}
}
103 changes: 100 additions & 3 deletions tool/src/massive/munit/Config.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
* or implied, of Massive Interactive.
*/
package massive.munit;

import massive.sys.io.File;
import massive.munit.Target;

class Config
{
inline public static var CLI_CONFIG:String = "cliconfig";

public var currentVersion(default, null):String;
public var configVersion(default, null):String;
public var dir(default, null):File;
Expand All @@ -54,9 +57,103 @@ class Config
this.dir = dir;
this.currentVersion = currentVersion;
targetTypes = defaultTargetTypes;
configFile = dir.resolveFile(".munit");
exists = configFile.exists;
if(exists) load();
if(!parseCommandLineConfig())
{
configFile = dir.resolveFile(".munit");
exists = configFile.exists;
if(exists) load();
}
}

private function parseCommandLineConfig():Bool
{
var args = Sys.args();
if(args[1] != CLI_CONFIG)
return false;

src = File.create(args[2], dir);
bin = File.create(args[3], dir, true);
report = File.create(args[4], dir, true);
hxml = null;

configVersion = getCommandLineConfigValue("version");

var resources = getCommandLineConfigValue("resources");
this.resources = resources != null ? File.create(resources, dir) : null;

var templates = getCommandLineConfigValue("templates");
this.templates = templates != null ? File.create(templates, dir) : null;

var classPaths = getCommandLineConfigValues("classPath");
this.classPaths = [];
if(classPaths != null)
for(classPath in classPaths)
this.classPaths.push(File.create(classPath, dir));

coveragePackages = getCommandLineConfigValues("coveragePackage");
coverageIgnoredClasses = getCommandLineConfigValues("coverageIgnoredClass");

targets.push(getCommandLineTarget());
return true;
}

private function getCommandLineConfigValue(name:String):String
{
var result = getCommandLineConfigValues(name);
return result == null ? null : result[0];
}

private function getCommandLineConfigValues(name:String):Array<String>
{
var args = Sys.args();
var result:Array<String> = [];
var length = args.length;
for(i in 0...length)
{
if(args[i] == ("config:" + name) && length > i)
result.push(args[i + 1]);
}
return result.length > 0 ? result : null;
}

private function getCommandLineTarget():Target
{
var hxml = "";
var flag = "target:";
var args = Sys.args();
var type:TargetType = null;
var file:File = null;
var length = args.length;
for(i in 0...length)
{
var arg = args[i];
if(StringTools.startsWith(arg, flag) && length > i)
{
var command = arg.substr(flag.length);
var value = args[i + 1];
hxml += command + " " + value + "\n";
switch(command)
{
case "-as3":
type = TargetType.as3;
file = File.create(value, dir, true);
case "-js":
type = TargetType.js;
file = File.create(value, dir, true);
case "-neko":
type = TargetType.neko;
file = File.create(value, dir, true);
case "-cpp":
type = TargetType.cpp;
file = File.create(value, dir, true);
}
}
}
var result = new Target();
result.hxml = hxml;
result.type = type;
result.file = file;
return result;
}

public function load(?file:File)
Expand Down
3 changes: 3 additions & 0 deletions tool/src/massive/munit/command/MUnitTargetCommandBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class MUnitTargetCommandBase extends MUnitCommand
var hxml:File = null;
var hxmlPath:String = null;
if (checkConsole) hxmlPath = console.getNextArg();
if (hxmlPath == Config.CLI_CONFIG || hxmlPath == null)
return;

if (hxmlPath != null)
{
hxml = File.create(hxmlPath, console.dir);
Expand Down
9 changes: 6 additions & 3 deletions tool/src/massive/munit/command/RunCommand.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
* or implied, of Massive Interactive.
*/
package massive.munit.command;

import haxe.ds.StringMap;
import haxe.io.Eof;
import massive.haxe.log.Log;
import massive.haxe.util.RegExpUtil;
import massive.munit.ServerMain;
import massive.munit.client.HTTPClient;
import massive.munit.ServerMain;
import massive.munit.util.MathUtil;
import massive.sys.io.File;
import massive.sys.io.FileSys;
import neko.vm.Module;
import neko.vm.Thread;
import sys.FileSystem;
import sys.io.Process;
Expand Down Expand Up @@ -230,7 +232,7 @@ class RunCommand extends MUnitTargetCommandBase
indexPage = reportRunnerDir.resolvePath("index.html");
indexPage.writeString(pageContent, true);
var commonResourceDir:File = console.originalDir.resolveDirectory("resource");
commonResourceDir.copyTo(reportRunnerDir);
if(commonResourceDir.exists) commonResourceDir.copyTo(reportRunnerDir);
if (config.resources != null) config.resources.copyTo(reportRunnerDir);
for (target in targets)
{
Expand Down Expand Up @@ -267,7 +269,8 @@ class RunCommand extends MUnitTargetCommandBase
//Windows has issue releasing port registries reliably.
//To prevent possibility of nekotools server failing, on
//windows the tmp directory is always located inside the munit install
FileSys.setCwd(console.originalDir.nativePath);
var nekoLocalDirectory = haxe.io.Path.directory(Module.local().name);
FileSys.setCwd(nekoLocalDirectory != "" ? nekoLocalDirectory : console.originalDir.nativePath);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion tool/src/massive/munit/command/TestCommand.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TestCommand extends MUnitTargetCommandBase
{
super.initialise();
initialiseTargets(true);
if (invalidHxmlFormat())
if (config.hxml != null && invalidHxmlFormat())
{
testsAborted = true;
return;
Expand Down

0 comments on commit aa3b360

Please sign in to comment.