<commit_before>require File.expand_path("../../teststrap", File.dirname(__FILE__))

context ReleasePackager::Builders::OsxApp do
  setup { ReleasePackager::Project.new }

  teardown do
    Rake::Task.clear
    Dir.chdir $original_path
  end

  hookup do
    Dir.chdir project_path

    topic.name = "Test"
    topic.version = "0.1"
    topic.files = source_files
    topic.readme = "README.txt"
    topic.osx_app_url = "org.frog.fish"
    # Just use the dev gems, but some won't work, so ignore them.
    topic.osx_app_gems = Gem.loaded_specs.values.reject {|g| %w[rake ocra].include? g.name }

    topic.add_output :osx_app
    topic.add_archive_format :tar_gz
  end

  context "no wrapper" do
    asserts(:generate_tasks).raises RuntimeError
  end

  context "invalid wrapper" do
    hookup { topic.osx_app_wrapper= "no file" }

    asserts(:generate_tasks).raises RuntimeError
  end

  context "valid wrapper" do
    hookup do
      topic.osx_app_wrapper = "osx_app/RubyGosu App.app"
      topic.generate_tasks
    end

    context "tasks" do
      tasks = [
          [ :Task, "package", %w[package:osx] ],
          [ :Task, "package:osx", %w[package:osx:app] ],
          [ :Task, "package:osx:app", %w[package:osx:app:tar_gz] ],
          [ :Task, "package:osx:app:tar_gz", %w[pkg/test_0_1_OSX.tar.gz] ],

          [ :Task, "build", %w[build:osx] ],
          [ :Task, "build:osx", %w[build:osx:app] ],
          [ :Task, "build:osx:app", %w[pkg/test_0_1_OSX] ],

          [ :FileCreationTask, "pkg", [] ], # byproduct of using #directory
          [ :FileCreationTask, "pkg/test_0_1_OSX", source_files + ["osx_app/RubyGosu App.app"]],
          [ :FileTask, "pkg/test_0_1_OSX.tar.gz", %w[pkg/test_0_1_OSX] ],
      ]

      test_tasks tasks
    end

    context "generate folder + tar.gz" do
      hookup { Rake::Task["package:osx:app:tar_gz"].invoke }

      asserts("files copied to folder") { source_files.all? {|f| File.read("pkg/test_0_1_OSX/Test.app/Contents/Resources/test/#{f}") == File.read(f) } }
      asserts("readme copied to folder") { File.read("pkg/test_0_1_OSX/README.txt") == File.read("README.txt") }
<commit_msg>Moved the location of the osx_app<commit_after>require File.expand_path("../../teststrap", File.dirname(__FILE__))

context ReleasePackager::Builders::OsxApp do
  setup { ReleasePackager::Project.new }

  teardown do
    Rake::Task.clear
    Dir.chdir $original_path
  end

  hookup do
    Dir.chdir project_path

    topic.name = "Test"
    topic.version = "0.1"
    topic.files = source_files
    topic.readme = "README.txt"
    topic.osx_app_url = "org.frog.fish"
    # Just use the dev gems, but some won't work, so ignore them.
    topic.osx_app_gems = Gem.loaded_specs.values.reject {|g| %w[rake ocra].include? g.name }

    topic.add_output :osx_app
    topic.add_archive_format :tar_gz
  end

  context "no wrapper" do
    asserts(:generate_tasks).raises RuntimeError
  end

  context "invalid wrapper" do
    hookup { topic.osx_app_wrapper= "no file" }

    asserts(:generate_tasks).raises RuntimeError
  end

  context "valid wrapper" do
    hookup do
      topic.osx_app_wrapper = "../../../osx_app/RubyGosu App.app"
      topic.generate_tasks
    end

    context "tasks" do
      tasks = [
          [ :Task, "package", %w[package:osx] ],
          [ :Task, "package:osx", %w[package:osx:app] ],
          [ :Task, "package:osx:app", %w[package:osx:app:tar_gz] ],
          [ :Task, "package:osx:app:tar_gz", %w[pkg/test_0_1_OSX.tar.gz] ],

          [ :Task, "build", %w[build:osx] ],
          [ :Task, "build:osx", %w[build:osx:app] ],
          [ :Task, "build:osx:app", %w[pkg/test_0_1_OSX] ],

          [ :FileCreationTask, "pkg", [] ], # byproduct of using #directory
          [ :FileCreationTask, "pkg/test_0_1_OSX", source_files + ["../../../osx_app/RubyGosu App.app"]],
          [ :FileTask, "pkg/test_0_1_OSX.tar.gz", %w[pkg/test_0_1_OSX] ],
      ]

      test_tasks tasks
    end

    context "generate folder + tar.gz" do
      hookup { Rake::Task["package:osx:app:tar_gz"].invoke }

      asserts("files copied to folder") { source_files.all? {|f| File.read("pkg/test_0_1_OSX/Test.app/Contents/Resources/test/#{f}") == File.read(f) } }
      asserts("readme copied to folder") { File.read("pkg/test_0_1_OSX/README.txt") == File.read("README.txt") }

{'fraction_non_alphanumeric': 0.15363257751041184, 'fraction_numerical': 0.007403979639055993, 'mean_word_length': 3.06296992481203, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1077062', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1593, 'n_words': 291}