<commit_before>#!/usr/bin/env bats
load test-util

eventually() {
  for try in $(seq 1 50); do
    if eval ${@}; then
      return 0
    fi
    sleep 0.2
  done

  return 1
}

setup() {
  load_fixture typical-project

  if [[ "$BATS_TEST_NUMBER" -eq 1 ]]; then
    kill -9 $(cat ez-build.pid) || true

    ${EZ_BUILD_BIN} --interactive 2>&1 > build.log &
    EZPID=$!
    disown ${EZPID}
    echo ${EZPID} > ez-build.pid
  fi
}

teardown() {
  if [[ "$BATS_TEST_NUMBER" -eq "${#BATS_TEST_NAMES[@]}" ]]; then
    kill -9 $(cat ez-build.pid)
    rm *.log *.pid
  fi

  unload_fixture typical-project
}

@test "should wait for changes" {
  eventually 'assert_equal "Watching source files for changes..." "$(tail -1 build.log)"'
}

@test "should rebuild files when they are modified" {
  touch src/a.js
  eventually 'assert_equal "js – src/a.js -> lib/a.js,lib/a.js.map" "$(tail -1 build.log)"'
}

@test "should build files when they are added" {
  refute_exists src/added.js
  touch src/added.js
  eventually 'assert_exists lib/added.js'
  eventually 'assert_exists lib/added.js.map'
}<commit_msg>Remove *.log and *.pid files when done with the last test<commit_after>#!/usr/bin/env bats
load test-util

eventually() {
  for try in $(seq 1 50); do
    if eval ${@}; then
      return 0
    fi
    sleep 0.2
  done

  return 1
}

setup() {
  load_fixture typical-project

  if [[ "$BATS_TEST_NUMBER" -eq 1 ]]; then
    kill -9 $(cat ez-build.pid) || true

    ${EZ_BUILD_BIN} --interactive 2>&1 > build.log &
    EZPID=$!
    disown ${EZPID}
    echo ${EZPID} > ez-build.pid
  fi
}

teardown() {
  if [[ "$BATS_TEST_NUMBER" -eq "${#BATS_TEST_NAMES[@]}" ]]; then
    kill -9 $(cat ez-build.pid) || true
    rm *.{pid,log}
  fi

  unload_fixture typical-project
}

@test "should wait for changes" {
  eventually 'assert_equal "Watching source files for changes..." "$(tail -1 build.log)"'
}

@test "should rebuild files when they are modified" {
  touch src/a.js
  eventually 'assert_equal "js – src/a.js -> lib/a.js,lib/a.js.map" "$(tail -1 build.log)"'
}

@test "should build files when they are added" {
  refute_exists src/added.js
  touch src/added.js
  eventually 'assert_exists lib/added.js'
  eventually 'assert_exists lib/added.js.map'
}
{'fraction_non_alphanumeric': 0.1513392857142857, 'fraction_numerical': 0.0125, 'mean_word_length': 3.023339317773788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3069729', 'n_tokens_mistral': 884, 'n_tokens_neox': 839, 'n_words': 240}