<commit_before>ChildProcess = require '../src/ChildProcess'
expect = require("chai").expect
log = require('loglevel')
log.setLevel "debug"
describe "TestRunner Test", ->
  @timeout 30000
  testRunnerChild = new ChildProcess()

  afterEach ->
    testRunnerChild.child.kill()

  it "Test run with a failing meteor app", (done)->
    args = [
      "--app_path"
      "tests/todos/"
      "--packages"
      ""
      "--timeout"
      "5000"
      "--port"
      "4060"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 2 # meteor app has errors
      done()

  it "Test run with a successful test", (done)->
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "success"
      "--timeout"
      "5000"
      "--port"
      "4070"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 4 # test succeeded
      done()

  it "Test run with a failing test", (done)->
    testRunnerChild = new ChildProcess()
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "failure"
      "--timeout"
      "5000"
      "--port"
      "4080"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 5 # test failed
      done()


  it "Test run with a test that never ends", (done)->
    testRunnerChild = new ChildProcess()
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "timeout"
      "--timeout"
      "5000"
      "--port"
      "4090"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 6 # test timed-out
      done()

  after -><commit_msg>Update tests<commit_after>ChildProcess = require '../src/ChildProcess'
expect = require("chai").expect
log = require('loglevel')
log.setLevel "debug"
describe "TestRunner Test", ->
  @timeout 30000
  testRunnerChild = new ChildProcess()

  afterEach ->
    testRunnerChild.kill()

  it "Test run with a successful test", (done)->
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "success"
      "--timeout"
      "5000"
      "--port"
      "7040"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 4 # test succeeded
      done()

  it "Test run with a failing test", (done)->
    testRunnerChild = new ChildProcess()
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "failure"
      "--timeout"
      "5000"
      "--port"
      "7050"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 5 # test failed
      done()


  it "Test run with a test that never ends", (done)->
    testRunnerChild = new ChildProcess()
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "timeout"
      "--timeout"
      "5000"
      "--port"
      "7060"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 6 # test timed-out
      done()

  it "Test run with more than one package", (done)->
    args = [
      "--app_path"
      "tests/leaderboard/"
      "--packages"
      "packages/success*"
      "--timeout"
      "5000"
      "--port"
      "7080"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 4 # test succeeded
      done()

  it "Test run with a failing meteor app", (done)->
    testRunnerChild = new ChildProcess()
    args = [
      "--app_path"
      "tests/todos/"
      "--packages"
      "appfails"
      "--timeout"
      "10000"
      "--port"
      "7070"
    ]
    testRunnerChild.spawn("bin/mctr",args)
    testRunnerChild.child.on "exit", (code) =>
      expect(code).to.equal 2 # meteor app has errors
      done()

{'fraction_non_alphanumeric': 0.15604068469362442, 'fraction_numerical': 0.02282312081369387, 'mean_word_length': 2.1087124132613724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '1525473', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1299, 'n_words': 299}