Skip to content

Commit

Permalink
Refactor runner: runner/main -> runner/core
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Jul 23, 2017
1 parent d42b744 commit c7a0ce1
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 75 deletions.
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ set(INCLUDE
include/tcframe/os/OperatingSystem.hpp
include/tcframe/runner/logger.hpp
include/tcframe/runner/logger/RunnerLogger.hpp
include/tcframe/runner/main.hpp
include/tcframe/runner/main/Args.hpp
include/tcframe/runner/main/ArgsParser.hpp
include/tcframe/runner/main/RunnerMain.hpp
include/tcframe/runner/main/SlugParser.hpp
include/tcframe/runner/core.hpp
include/tcframe/runner/core/Args.hpp
include/tcframe/runner/core/ArgsParser.hpp
include/tcframe/runner/core/Runner.hpp
include/tcframe/runner/core/SlugParser.hpp
include/tcframe/spec.hpp
include/tcframe/spec/constraint.hpp
include/tcframe/spec/constraint/Constraint.hpp
Expand Down Expand Up @@ -189,12 +189,12 @@ set(TEST_UNIT
test/unit/tcframe/os/MockOperatingSystem.hpp
test/unit/tcframe/runner/logger/MockRunnerLogger.hpp
test/unit/tcframe/runner/logger/RunnerLoggerTests.cpp
test/unit/tcframe/runner/main/ArgsParserTests.cpp
test/unit/tcframe/runner/main/BatchRunnerMainTests.cpp
test/unit/tcframe/runner/main/BaseRunnerMainTests.hpp
test/unit/tcframe/runner/main/InteractiveRunnerMainTests.cpp
test/unit/tcframe/runner/main/RunnerMainTests.cpp
test/unit/tcframe/runner/main/SlugParserTests.cpp
test/unit/tcframe/runner/core/ArgsParserTests.cpp
test/unit/tcframe/runner/core/BatchRunnerTests.cpp
test/unit/tcframe/runner/core/BaseRunnerTests.hpp
test/unit/tcframe/runner/core/InteractiveRunnerTests.cpp
test/unit/tcframe/runner/core/RunnerTests.cpp
test/unit/tcframe/runner/core/SlugParserTests.cpp
test/unit/tcframe/spec/constraint/ConstraintSuiteTests.cpp
test/unit/tcframe/spec/constraint/ConstraintSuiteBuilderTests.cpp
test/unit/tcframe/spec/core/BaseTestSpecTests.cpp
Expand Down
4 changes: 4 additions & 0 deletions include/tcframe/runner.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#include "tcframe/runner/core.hpp"
#include "tcframe/runner/logger.hpp"
6 changes: 6 additions & 0 deletions include/tcframe/runner/core.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include "tcframe/runner/core/Args.hpp"
#include "tcframe/runner/core/ArgsParser.hpp"
#include "tcframe/runner/core/Runner.hpp"
#include "tcframe/runner/core/SlugParser.hpp"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct RunnerDefaults {
};

template<typename TProblemSpec>
class RunnerMain {
class Runner {
private:
string specPath_;

Expand All @@ -45,7 +45,7 @@ class RunnerMain {
AggregatorRegistry* aggregatorRegistry_;

public:
RunnerMain(
Runner(
const string& specPath,
BaseTestSpec<TProblemSpec>* testSpec,
LoggerEngine* loggerEngine,
Expand Down
File renamed without changes.
6 changes: 0 additions & 6 deletions include/tcframe/runner/main.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions src/tcframe/runner.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "tcframe/runner/main.hpp"
#include "tcframe/runner.hpp"

#include __TCFRAME_SPEC_FILE__

using tcframe::RunnerMain;
using tcframe::Runner;

int main(int argc, char* argv[]) {
RunnerMain<ProblemSpec> runner(
Runner<ProblemSpec> runner(
__TCFRAME_SPEC_FILE__,
new TestSpec(),
new SimpleLoggerEngine(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "gmock/gmock.h"

#include "tcframe/runner/main/ArgsParser.hpp"
#include "tcframe/runner/core/ArgsParser.hpp"

using ::testing::Eq;
using ::testing::StrEq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../../grader/MockGraderLoggerFactory.hpp"
#include "../../os/MockOperatingSystem.hpp"
#include "../logger/MockRunnerLogger.hpp"
#include "tcframe/runner/main/RunnerMain.hpp"
#include "tcframe/runner/core/Runner.hpp"

using ::testing::_;
using ::testing::Eq;
Expand All @@ -23,7 +23,7 @@ using ::testing::Truly;

namespace tcframe {

class BaseRunnerMainTests : public Test {
class BaseRunnerTests : public Test {
protected:
class ProblemSpec : public BaseProblemSpec {
protected:
Expand Down Expand Up @@ -63,8 +63,8 @@ class BaseRunnerMainTests : public Test {
}

template<typename TProblem>
RunnerMain<TProblem> createRunner(BaseTestSpec<TProblem>* testSpec) {
return RunnerMain<TProblem>(
Runner<TProblem> createRunner(BaseTestSpec<TProblem>* testSpec) {
return Runner<TProblem>(
specPath, testSpec, loggerEngine, &os,&runnerLoggerFactory, &graderLoggerFactory,
&generatorFactory, &graderFactory, &evaluatorRegistry, &aggregatorRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "BaseRunnerMainTests.hpp"
#include "BaseRunnerTests.hpp"

namespace tcframe {

class BatchRunnerMainTests : public BaseRunnerMainTests {
class BatchRunnerTests : public BaseRunnerTests {
protected:
class BatchProblemSpec : public ProblemSpec {
protected:
Expand All @@ -22,39 +22,39 @@ class BatchRunnerMainTests : public BaseRunnerMainTests {
class BatchTestSpec : public BaseTestSpec<BatchProblemSpec> {};
class BatchWithCustomScorerTestSpec : public BaseTestSpec<BatchWithCustomScorerProblemSpec> {};

RunnerMain<BatchProblemSpec> runner = createRunner(new BatchTestSpec());
RunnerMain<BatchWithCustomScorerProblemSpec> runnerWithCustomScorer = createRunner(new BatchWithCustomScorerTestSpec());
Runner<BatchProblemSpec> runner = createRunner(new BatchTestSpec());
Runner<BatchWithCustomScorerProblemSpec> runnerWithCustomScorer = createRunner(new BatchWithCustomScorerTestSpec());
};

TEST_F(BatchRunnerMainTests, Run_Generation_EvaluatorRegistry_NoCustomScorer) {
TEST_F(BatchRunnerTests, Run_Generation_EvaluatorRegistry_NoCustomScorer) {
EXPECT_CALL(evaluatorRegistry, get(EvaluationStyle::BATCH, _, Truly(HelperKeyIs("scorer", ""))));
runner.run(argc, argv);
}

TEST_F(BatchRunnerMainTests, Run_Generation_EvaluatorRegistry_CustomScorer_Default) {
TEST_F(BatchRunnerTests, Run_Generation_EvaluatorRegistry_CustomScorer_Default) {
EXPECT_CALL(evaluatorRegistry,
get(EvaluationStyle::BATCH, _, Truly(HelperKeyIs("scorer", string(RunnerDefaults::SCORER_COMMAND)))));

runnerWithCustomScorer.run(argc, argv);
}

TEST_F(BatchRunnerMainTests, Run_Generation_EvaluatorRegistry_CustomScorer_Args) {
TEST_F(BatchRunnerTests, Run_Generation_EvaluatorRegistry_CustomScorer_Args) {
EXPECT_CALL(evaluatorRegistry, get(EvaluationStyle::BATCH, _, Truly(HelperKeyIs("scorer", "\"java Scorer\""))));
runnerWithCustomScorer.run(2, new char*[3]{
(char*) "./runner",
(char*) "--scorer=\"java Scorer\"",
nullptr});
}

TEST_F(BatchRunnerMainTests, Run_Grading_EvaluatorRegistry_NoCustomScorer) {
TEST_F(BatchRunnerTests, Run_Grading_EvaluatorRegistry_NoCustomScorer) {
EXPECT_CALL(evaluatorRegistry, get(EvaluationStyle::BATCH, _, Truly(HelperKeyIs("scorer", ""))));
runner.run(2, new char*[3]{
(char*) "./runner",
(char*) "grade",
nullptr});
}

TEST_F(BatchRunnerMainTests, Run_Grading_EvaluatorRegistry_CustomScorer_Default) {
TEST_F(BatchRunnerTests, Run_Grading_EvaluatorRegistry_CustomScorer_Default) {
EXPECT_CALL(evaluatorRegistry,
get(EvaluationStyle::BATCH, _, Truly(HelperKeyIs("scorer", string(RunnerDefaults::SCORER_COMMAND)))));

Expand All @@ -64,7 +64,7 @@ TEST_F(BatchRunnerMainTests, Run_Grading_EvaluatorRegistry_CustomScorer_Default)
nullptr});
}

TEST_F(BatchRunnerMainTests, Run_Grading_EvaluatorRegistry_CustomScorer_Args) {
TEST_F(BatchRunnerTests, Run_Grading_EvaluatorRegistry_CustomScorer_Args) {
EXPECT_CALL(evaluatorRegistry, get(EvaluationStyle::BATCH, _, Truly(HelperKeyIs("scorer", "\"java Scorer\""))));
runnerWithCustomScorer.run(3, new char*[4]{
(char*) "./runner",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "BaseRunnerMainTests.hpp"
#include "BaseRunnerTests.hpp"

namespace tcframe {

class InteractiveRunnerMainTests : public BaseRunnerMainTests {
class InteractiveRunnerTests : public BaseRunnerTests {
protected:
class InteractiveProblemSpec : public ProblemSpec {
protected:
Expand All @@ -23,22 +23,22 @@ class InteractiveRunnerMainTests : public BaseRunnerMainTests {
class InteractiveWithRedundantNoOutputTestSpec :
public BaseTestSpec<InteractiveWithRedundantNoOutputProblemSpec> {};

RunnerMain<InteractiveProblemSpec> runner = createRunner(new InteractiveTestSpec());
RunnerMain<InteractiveWithRedundantNoOutputProblemSpec> runnerWithRedundantNoOutput =
Runner<InteractiveProblemSpec> runner = createRunner(new InteractiveTestSpec());
Runner<InteractiveWithRedundantNoOutputProblemSpec> runnerWithRedundantNoOutput =
createRunner(new InteractiveWithRedundantNoOutputTestSpec());
};

TEST_F(InteractiveRunnerMainTests, Run_Generation_NoOutput) {
TEST_F(InteractiveRunnerTests, Run_Generation_NoOutput) {
EXPECT_CALL(generator, generate(_, Property(&GenerationOptions::needsOutput, false)));
runner.run(argc, argv);
}

TEST_F(InteractiveRunnerMainTests, Run_Generation_NoOutput_Redundant) {
TEST_F(InteractiveRunnerTests, Run_Generation_NoOutput_Redundant) {
EXPECT_CALL(generator, generate(_, Property(&GenerationOptions::needsOutput, false)));
runnerWithRedundantNoOutput.run(argc, argv);
}

TEST_F(InteractiveRunnerMainTests, Run_Generation_EvaluatorRegistry_Communicator_Default) {
TEST_F(InteractiveRunnerTests, Run_Generation_EvaluatorRegistry_Communicator_Default) {
EXPECT_CALL(evaluatorRegistry, get(
EvaluationStyle::INTERACTIVE,
_,
Expand All @@ -47,7 +47,7 @@ TEST_F(InteractiveRunnerMainTests, Run_Generation_EvaluatorRegistry_Communicator
runner.run(argc, argv);
}

TEST_F(InteractiveRunnerMainTests, Run_Generation_EvaluatorRegistry_Communicator_Args) {
TEST_F(InteractiveRunnerTests, Run_Generation_EvaluatorRegistry_Communicator_Args) {
EXPECT_CALL(evaluatorRegistry, get(
EvaluationStyle::INTERACTIVE,
_,
Expand All @@ -59,7 +59,7 @@ TEST_F(InteractiveRunnerMainTests, Run_Generation_EvaluatorRegistry_Communicator
nullptr});
}

TEST_F(InteractiveRunnerMainTests, Run_Grading_EvaluatorRegistry_Communicator_Default) {
TEST_F(InteractiveRunnerTests, Run_Grading_EvaluatorRegistry_Communicator_Default) {
EXPECT_CALL(evaluatorRegistry, get(
EvaluationStyle::INTERACTIVE,
_,
Expand All @@ -71,7 +71,7 @@ TEST_F(InteractiveRunnerMainTests, Run_Grading_EvaluatorRegistry_Communicator_De
nullptr});
}

TEST_F(InteractiveRunnerMainTests, Run_Grading_EvaluatorRegistry_Communicator_Args) {
TEST_F(InteractiveRunnerTests, Run_Grading_EvaluatorRegistry_Communicator_Args) {
EXPECT_CALL(evaluatorRegistry, get(
EvaluationStyle::INTERACTIVE,
_,
Expand Down

0 comments on commit c7a0ce1

Please sign in to comment.