diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdbfa61d..b164777b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,7 @@ name: ci on: - push - pull_request + - workflow_dispatch permissions: contents: read jobs: @@ -18,17 +19,25 @@ jobs: - "2.7" - "3.0" - "3.1" - - "head" + - "3.2" + - "3.3" + - "3.4" + include: + - { ruby: "head", allow-failure: true } env: BUNDLE_WITHOUT: development + BUNDLER_NO_OLD_RUBYGEMS_WARNING: true steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - rubygems: latest # runs 'gem update --system' - name: Run test + continue-on-error: ${{ matrix.allow-failure || false }} + id: tests run: bundle exec rake spec + - name: "Test outcome: ${{ steps.tests.outcome }}" + run: "" diff --git a/.gitignore b/.gitignore index 02160624..4134644e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /pkg/ /vendor Gemfile.lock +/*.gem diff --git a/Changelog.md b/Changelog.md index 728699fb..c1cf4048 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,34 @@ +## 0.88.1 (2024-04-12) + +* update master to main [David Dollar] + +## 0.88.0 (2024-04-12) + +* use actions/checkout@v4 [David Dollar] +* remove Gemfile.lock from repo because it's too strict [David Dollar] +* update for ci [David Dollar] +* handle empty procfile exception in cli [David Dollar] +* Update man page to reflect recent changes in systemd export [Lukáš Konarovský] +* [engine/cli.rb] Handle nil name_padding [Nick LaMuro] +* [Foreman::Procfile#load] Fail when empty [Nick LaMuro] +* spec_helper: don't try to remove /tmp [Antonio Terceiro] +* Fix misleading comment at the top of procfile.rb that indicates that hyphens "-" are not allowed in process names. [Ben Wilber] +* Rename usage of Dir/File.exists to exist [Qiu Chaofan] +* remove codeclimate [David Dollar] +* clean up and autoformat [David Dollar] +* Add GitHub token permissions for workflow [mishina] +* Migrate from Travis CI to GitHub Actions [mishina] +* Pass a block rather than an argument to `expect` [mishina] +* Replace `File.exists?` with `File.exist?` [mishina] +* Use the latest fakefs [mishina] +* Remove and ignore Gemfile.lock [mishina] +* Add GitHub Actions workflow [mishina] +* GitHub is HTTPS by default [Akira Matsuda] + +## 0.87.2 (2020-08-07) + +* update json for CVE-2020-10663 [David Dollar] + ## 0.87.1 (2020-04-02) * update rake for CVE-2020-8130 [David Dollar] diff --git a/Gemfile b/Gemfile index 1316ac79..462036bc 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ end group :development do gem 'aws-s3' - gem 'ronn' + gem 'ronn-ng' gem 'yard', '~> 0.9.11' gem 'automatiek' end diff --git a/README.md b/README.md index 92fab56a..77df1fcf 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# Foreman +# Overman (`ddollar/foreman` fork) -[![CI](https://github.com/ddollar/foreman/actions/workflows/ci.yml/badge.svg)](https://github.com/ddollar/foreman/actions/workflows/ci.yml) +[![CI](https://github.com/spinels/overman/actions/workflows/ci.yml/badge.svg)](https://github.com/spinels/overman/actions/workflows/ci.yml) Manage Procfile-based applications ## Installation - $ gem install foreman + $ gem install overman -Ruby users should take care *not* to install foreman in their project's `Gemfile`. See this [wiki article](https://github.com/ddollar/foreman/wiki/Don't-Bundle-Foreman) for more details. +Ruby users should take care _not_ to install foreman in their project's `Gemfile`. See this [wiki article](https://github.com/ddollar/foreman/wiki/Don't-Bundle-Foreman) for more details. ## Getting Started -* http://blog.daviddollar.org/2011/05/06/introducing-foreman.html +- http://blog.daviddollar.org/2011/05/06/introducing-foreman.html ## Supported Ruby versions @@ -20,29 +20,31 @@ See [ci.yml](.github/workflows/ci.yml) for a list of Ruby versions against which ## Documentation -* [man page](http://ddollar.github.io/foreman/) -* [wiki](https://github.com/ddollar/foreman/wiki) -* [changelog](https://github.com/ddollar/foreman/blob/master/Changelog.md) +- [man page](http://ddollar.github.io/foreman/) +- [wiki](https://github.com/ddollar/foreman/wiki) +- [changelog](https://github.com/ddollar/foreman/blob/main/Changelog.md) ## Ports -* [forego](https://github.com/ddollar/forego) - Go -* [node-foreman](https://github.com/strongloop/node-foreman) - Node.js -* [gaffer](https://github.com/jingweno/gaffer) - Java/JVM -* [goreman](https://github.com/mattn/goreman) - Go -* [honcho](https://github.com/nickstenning/honcho) - python -* [proclet](https://github.com/kazeburo/Proclet) - Perl -* [shoreman](https://github.com/chrismytton/shoreman) - shell -* [crank](https://github.com/arktisklada/crank) - Crystal -* [houseman](https://github.com/fujimura/houseman) - Haskell -* [spm](https://github.com/bytegust/spm) - Go +- [forego](https://github.com/ddollar/forego) - Go +- [node-foreman](https://github.com/strongloop/node-foreman) - Node.js +- [gaffer](https://github.com/jingweno/gaffer) - Java/JVM +- [goreman](https://github.com/mattn/goreman) - Go +- [honcho](https://github.com/nickstenning/honcho) - python +- [proclet](https://github.com/kazeburo/Proclet) - Perl +- [shoreman](https://github.com/chrismytton/shoreman) - shell +- [crank](https://github.com/arktisklada/crank) - Crystal +- [houseman](https://github.com/fujimura/houseman) - Haskell +- [spm](https://github.com/bytegust/spm) - Go ## Authors #### Created and maintained by + David Dollar #### Patches contributed by + [Contributor List](https://github.com/ddollar/foreman/contributors) ## License diff --git a/bin/foreman b/bin/overman similarity index 100% rename from bin/foreman rename to bin/overman diff --git a/lib/foreman/cli.rb b/lib/foreman/cli.rb index 67d697ab..f0affefb 100644 --- a/lib/foreman/cli.rb +++ b/lib/foreman/cli.rb @@ -40,6 +40,8 @@ def start(process=nil) engine.load_procfile(procfile) engine.options[:formation] = "#{process}=1" if process engine.start + rescue Foreman::Procfile::EmptyFileError + error "no processes defined" end desc "export FORMAT LOCATION", "Export the application to another process management format" @@ -60,7 +62,7 @@ def export(format, location=nil) engine.load_procfile(procfile) formatter = Foreman::Export.formatter(format) formatter.new(location, engine, options).export - rescue Foreman::Export::Exception => ex + rescue Foreman::Export::Exception, Foreman::Procfile::EmptyFileError => ex error ex.message end @@ -69,8 +71,9 @@ def export(format, location=nil) def check check_procfile! engine.load_procfile(procfile) - error "no processes defined" unless engine.processes.length > 0 puts "valid procfile detected (#{engine.process_names.join(', ')})" + rescue Foreman::Procfile::EmptyFileError + error "no processes defined" end desc "run COMMAND [ARGS...]", "Run a command using your application's environment" @@ -105,6 +108,8 @@ def run(*args) Process.wait(pid) exit $?.exitstatus || 0 rescue Interrupt + rescue Foreman::Procfile::EmptyFileError + error "no processes defined" end desc "version", "Display Foreman gem version" diff --git a/lib/foreman/engine.rb b/lib/foreman/engine.rb index a1316593..3b2c32b7 100644 --- a/lib/foreman/engine.rb +++ b/lib/foreman/engine.rb @@ -191,14 +191,14 @@ def kill_children(signal="SIGTERM") @running.each do |pid, (process, index)| system "sending #{signal} to #{name_for(pid)} at pid #{pid}" begin - Process.kill(signal, pid) + Process.kill("-#{signal}", pid) rescue Errno::ESRCH, Errno::EPERM end end else begin pids = @running.keys.compact - Process.kill signal, *pids unless pids.empty? + Process.kill("-#{signal}", *pids) unless pids.empty? rescue Errno::ESRCH, Errno::EPERM end end diff --git a/lib/foreman/engine/cli.rb b/lib/foreman/engine/cli.rb index 7ea71375..1cbc66f4 100644 --- a/lib/foreman/engine/cli.rb +++ b/lib/foreman/engine/cli.rb @@ -49,7 +49,7 @@ def color(name) def startup @colors = map_colors - proctitle "foreman: master" unless Foreman.windows? + proctitle "foreman: main" unless Foreman.windows? Color.enable($stdout, options[:color]) end @@ -77,7 +77,7 @@ def name_padding @name_padding ||= begin index_padding = @names.values.map { |n| formation[n] }.max.to_s.length + 1 name_padding = @names.values.map { |n| n.length + index_padding }.sort.last - [ 6, name_padding ].max + [ 6, name_padding.to_i ].max end end diff --git a/lib/foreman/export/base.rb b/lib/foreman/export/base.rb index 094555a8..010529e6 100644 --- a/lib/foreman/export/base.rb +++ b/lib/foreman/export/base.rb @@ -74,8 +74,8 @@ def self.warn_deprecation! puts "WARNING: Using deprecated exporter interface. Please update your exporter" puts "the interface shown in the upstart exporter:" puts - puts "https://github.com/ddollar/foreman/blob/master/lib/foreman/export/upstart.rb" - puts "https://github.com/ddollar/foreman/blob/master/data/export/upstart/process.conf.erb" + puts "https://github.com/ddollar/foreman/blob/main/lib/foreman/export/upstart.rb" + puts "https://github.com/ddollar/foreman/blob/main/data/export/upstart/process.conf.erb" puts @@deprecation_warned = true end @@ -83,7 +83,7 @@ def self.warn_deprecation! def chown user, dir FileUtils.chown user, nil, dir rescue - error("Could not chown #{dir} to #{user}") unless File.writable?(dir) || ! File.exists?(dir) + error("Could not chown #{dir} to #{user}") unless File.writable?(dir) || ! File.exist?(dir) end def error(message) @@ -95,13 +95,13 @@ def say(message) end def clean(filename) - return unless File.exists?(filename) + return unless File.exist?(filename) say "cleaning up: #{filename}" FileUtils.rm(filename) end def clean_dir(dirname) - return unless File.exists?(dirname) + return unless File.exist?(dirname) say "cleaning up directory: #{dirname}" FileUtils.rm_r(dirname) end @@ -130,7 +130,7 @@ def export_template(name, file=nil, template_root=nil) matchers << File.join(options[:template], name_without_first) if options[:template] matchers << File.expand_path("~/.foreman/templates/#{name}") matchers << File.expand_path("../../../../data/export/#{name}", __FILE__) - File.read(matchers.detect { |m| File.exists?(m) }) + File.read(matchers.detect { |m| File.exist?(m) }) end end diff --git a/lib/foreman/process.rb b/lib/foreman/process.rb index ee3de948..2a681d5e 100644 --- a/lib/foreman/process.rb +++ b/lib/foreman/process.rb @@ -49,9 +49,10 @@ def run(options={}) env = @options[:env].merge(options[:env] || {}) output = options[:output] || $stdout runner = "#{Foreman.runner}".shellescape - + pgroup = Foreman.windows? ? :new_pgroup : :pgroup + Dir.chdir(cwd) do - Process.spawn env, expanded_command(env), :out => output, :err => output + Process.spawn env, expanded_command(env), :out => output, :err => output, pgroup => true end end diff --git a/lib/foreman/procfile.rb b/lib/foreman/procfile.rb index b9bd191e..74887212 100644 --- a/lib/foreman/procfile.rb +++ b/lib/foreman/procfile.rb @@ -4,12 +4,14 @@ # # A valid Procfile entry is captured by this regex: # -# /^([A-Za-z0-9_]+):\s*(.+)$/ +# /^([A-Za-z0-9_-]+):\s*(.+)$/ # # All other lines are ignored. # class Foreman::Procfile + EmptyFileError = Class.new(StandardError) + # Initialize a Procfile # # @param [String] filename (nil) An optional filename to read from @@ -60,7 +62,11 @@ def delete(name) # @param [String] filename The filename of the +Procfile+ to load # def load(filename) - @entries.replace parse(filename) + parse_data = parse(filename) + + raise EmptyFileError if parse_data.empty? + + @entries.replace parse_data end # Save a Procfile to a file diff --git a/lib/foreman/version.rb b/lib/foreman/version.rb index b69da8c6..326c530b 100644 --- a/lib/foreman/version.rb +++ b/lib/foreman/version.rb @@ -1,5 +1,5 @@ module Foreman - VERSION = "0.87.2" + VERSION = "0.88.1" end diff --git a/man/foreman.1 b/man/overman.1 similarity index 86% rename from man/foreman.1 rename to man/overman.1 index 2ff95557..d3e19858 100644 --- a/man/foreman.1 +++ b/man/overman.1 @@ -1,284 +1,181 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "FOREMAN" "1" "April 2020" "Foreman 0.87.2" "Foreman Manual" -. +.\" generated with Ronn-NG/v0.10.1 +.\" http://github.com/apjanke/ronn-ng/tree/0.10.1 +.TH "FOREMAN" "1" "April 2024" "Foreman 0.88.1" "Foreman Manual" .SH "NAME" \fBforeman\fR \- manage Procfile\-based applications -. .SH "SYNOPSIS" \fBforeman start [process]\fR -. .br \fBforeman run \fR -. .br \fBforeman export [location]\fR -. .SH "DESCRIPTION" Foreman is a manager for Procfile\-based applications\. Its aim is to abstract away the details of the Procfile format, and allow you to either run your application directly or export it to some other process management format\. -. .SH "RUNNING" \fBforeman start\fR is used to run your application directly from the command line\. -. .P If no additional parameters are passed, foreman will run one instance of each type of process defined in your Procfile\. -. .P If a parameter is passed, foreman will run one instance of the specified application type\. -. .P The following options control how the application is run: -. .TP \fB\-m\fR, \fB\-\-formation\fR Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR -. .TP \fB\-e\fR, \fB\-\-env\fR Specify one or more \.env files to load -. .TP \fB\-f\fR, \fB\-\-procfile\fR Specify an alternate Procfile to load, implies \fB\-d\fR at the Procfile root\. -. .TP \fB\-p\fR, \fB\-\-port\fR Specify which port to use as the base for this application\. Should be a multiple of 1000\. -. .TP \fB\-t\fR, \fB\-\-timeout\fR Specify the amount of time (in seconds) processes have to shutdown gracefully before receiving a SIGKILL, defaults to 5\. -. .P \fBforeman run\fR is used to run one\-off commands using the same environment as your defined processes\. -. .SH "EXPORTING" \fBforeman export\fR is used to export your application to another process management format\. -. .P A location to export can be passed as an argument\. This argument may be either required or optional depending on the export format\. -. .P The following options control how the application is run: -. .TP \fB\-a\fR, \fB\-\-app\fR -Use this name rather than the application\'s root directory name as the name of the application when exporting\. -. +Use this name rather than the application's root directory name as the name of the application when exporting\. .TP \fB\-m\fR, \fB\-\-formation\fR Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR -. .TP \fB\-l\fR, \fB\-\-log\fR Specify the directory to place process logs in\. -. .TP \fB\-p\fR, \fB\-\-port\fR Specify which port to use as the base for this application\. Should be a multiple of 1000\. -. .TP \fB\-t\fR, \fB\-\-template\fR Specify an alternate template to use for creating export files\. See \fIhttps://github\.com/ddollar/foreman/tree/master/data/export\fR for examples\. -. .TP \fB\-u\fR, \fB\-\-user\fR Specify the user the application should be run as\. Defaults to the app name -. .SH "GLOBAL OPTIONS" -These options control all modes of foreman\'s operation\. -. +These options control all modes of foreman's operation\. .TP \fB\-d\fR, \fB\-\-root\fR Specify an alternate application root\. This defaults to the directory containing the Procfile\. -. .TP \fB\-e\fR, \fB\-\-env\fR Specify an alternate environment file\. You can specify more than one file by using: \fB\-\-env file1,file2\fR\. -. .TP \fB\-f\fR, \fB\-\-procfile\fR -Specify an alternate location for the application\'s Procfile\. This file\'s containing directory will be assumed to be the root directory of the application\. -. +Specify an alternate location for the application's Procfile\. This file's containing directory will be assumed to be the root directory of the application\. .SH "EXPORT FORMATS" foreman currently supports the following output formats: -. .IP "\(bu" 4 bluepill -. .IP "\(bu" 4 inittab -. .IP "\(bu" 4 launchd -. .IP "\(bu" 4 runit -. .IP "\(bu" 4 supervisord -. .IP "\(bu" 4 systemd -. .IP "\(bu" 4 upstart -. .IP "" 0 -. .SH "INITTAB EXPORT" Will export a chunk of inittab\-compatible configuration: -. .IP "" 4 -. .nf - # \-\-\-\-\- foreman example processes \-\-\-\-\- -EX01:4:respawn:/bin/su \- example \-c \'PORT=5000 bundle exec thin start >> /var/log/web\-1\.log 2>&1\' -EX02:4:respawn:/bin/su \- example \-c \'PORT=5100 bundle exec rake jobs:work >> /var/log/job\-1\.log 2>&1\' +EX01:4:respawn:/bin/su \- example \-c 'PORT=5000 bundle exec thin start >> /var/log/web\-1\.log 2>&1' +EX02:4:respawn:/bin/su \- example \-c 'PORT=5100 bundle exec rake jobs:work >> /var/log/job\-1\.log 2>&1' # \-\-\-\-\- end foreman example processes \-\-\-\-\- -. .fi -. .IP "" 0 -. .SH "SYSTEMD EXPORT" Will create a series of systemd scripts in the location you specify\. Scripts will be structured to make the following commands valid: -. .P \fBsystemctl start appname\.target\fR -. .P \fBsystemctl stop appname\-processname\.target\fR -. .P \fBsystemctl restart appname\-processname\-3\.service\fR -. .SH "UPSTART EXPORT" Will create a series of upstart scripts in the location you specify\. Scripts will be structured to make the following commands valid: -. .P \fBstart appname\fR -. .P \fBstop appname\-processname\fR -. .P \fBrestart appname\-processname\-3\fR -. .SH "PROCFILE" A Procfile should contain both a name for the process and the command used to run it\. -. .IP "" 4 -. .nf - web: bundle exec thin start job: bundle exec rake jobs:work -. .fi -. .IP "" 0 -. .P A process name may contain letters, numbers and the underscore character\. You can validate your Procfile format using the \fBcheck\fR command: -. .IP "" 4 -. .nf - $ foreman check -. .fi -. .IP "" 0 -. .P The special environment variables \fB$PORT\fR and \fB$PS\fR are available within the Procfile\. \fB$PORT\fR is the port selected for that process\. \fB$PS\fR is the name of the process for the line\. -. .P The \fB$PORT\fR value starts as the base port as specified by \fB\-p\fR, then increments by 100 for each new process line\. Multiple instances of the same process are assigned \fB$PORT\fR values that increment by 1\. -. .SH "ENVIRONMENT" If a \fB\.env\fR file exists in the current directory, the default environment will be read from it\. This file should contain key/value pairs, separated by \fB=\fR, with one key/value pair per line\. -. .IP "" 4 -. .nf - FOO=bar BAZ=qux -. .fi -. .IP "" 0 -. .SH "DEFAULT OPTIONS" If a \fB\.foreman\fR file exists in the current directory, default options will be read from it\. This file should be in YAML format with the long option name as keys\. Example: -. .IP "" 4 -. .nf - formation: alpha=0,bravo=1 port: 15000 -. .fi -. .IP "" 0 -. .SH "EXAMPLES" Start one instance of each process type, interleave the output on stdout: -. .IP "" 4 -. .nf - $ foreman start -. .fi -. .IP "" 0 -. .P Export the application in upstart format: -. .IP "" 4 -. .nf - $ foreman export upstart /etc/init -. .fi -. .IP "" 0 -. .P Run one process type from the application defined in a specific Procfile: -. .IP "" 4 -. .nf - $ foreman start alpha \-f ~/myapp/Procfile -. .fi -. .IP "" 0 -. .P Start all processes except the one named worker: -. .IP "" 4 -. .nf - $ foreman start \-m all=1,worker=0 -. .fi -. .IP "" 0 -. .SH "COPYRIGHT" Foreman is Copyright (C) 2010 David Dollar \fIhttp://daviddollar\.org\fR diff --git a/man/foreman.1.ronn b/man/overman.ronn similarity index 100% rename from man/foreman.1.ronn rename to man/overman.ronn diff --git a/foreman.gemspec b/overman.gemspec similarity index 67% rename from foreman.gemspec rename to overman.gemspec index 708bd112..a81f8454 100644 --- a/foreman.gemspec +++ b/overman.gemspec @@ -2,18 +2,19 @@ $:.unshift File.expand_path("../lib", __FILE__) require "foreman/version" Gem::Specification.new do |gem| - gem.name = "foreman" + gem.name = "overman" gem.license = "MIT" gem.version = Foreman::VERSION gem.author = "David Dollar" gem.email = "ddollar@gmail.com" - gem.homepage = "https://github.com/ddollar/foreman" - gem.summary = "Process manager for applications with multiple components" + gem.homepage = "https://github.com/spinels/overman" + gem.summary = "Process manager for applications with multiple components, " \ + "fork of ddollar/foreman" gem.description = gem.summary - gem.executables = "foreman" + gem.executables = "overman" gem.files = Dir["**/*"].select { |d| d =~ %r{^(README|bin/|data/|ext/|lib/|spec/|test/)} } - gem.files << "man/foreman.1" + gem.files << "man/overman.1" end diff --git a/spec/foreman/cli_spec.rb b/spec/foreman/cli_spec.rb index b8c3cfee..4995a481 100644 --- a/spec/foreman/cli_spec.rb +++ b/spec/foreman/cli_spec.rb @@ -77,15 +77,15 @@ describe "run" do it "can run a command" do - expect(forked_foreman("run echo 1")).to eq("1\n") + expect(forked_foreman("run -f #{resource_path("Procfile")} echo 1")).to eq("1\n") end it "doesn't parse options for the command" do - expect(forked_foreman("run grep -e FOO #{resource_path(".env")}")).to eq("FOO=bar\n") + expect(forked_foreman("run -f #{resource_path("Procfile")} grep -e FOO #{resource_path(".env")}")).to eq("FOO=bar\n") end it "includes the environment" do - expect(forked_foreman("run -e #{resource_path(".env")} #{resource_path("bin/env FOO")}")).to eq("bar\n") + expect(forked_foreman("run -f #{resource_path("Procfile")} -e #{resource_path(".env")} #{resource_path("bin/env FOO")}")).to eq("bar\n") end it "can run a command from the Procfile" do @@ -93,8 +93,8 @@ end it "exits with the same exit code as the command" do - expect(fork_and_get_exitstatus("run echo 1")).to eq(0) - expect(fork_and_get_exitstatus("run date 'invalid_date'")).to eq(1) + expect(fork_and_get_exitstatus("run -f #{resource_path("Procfile")} echo 1")).to eq(0) + expect(fork_and_get_exitstatus("run -f #{resource_path("Procfile")} date 'invalid_date'")).to eq(1) end end diff --git a/spec/foreman/export/daemon_spec.rb b/spec/foreman/export/daemon_spec.rb index fe40dd28..112784a0 100644 --- a/spec/foreman/export/daemon_spec.rb +++ b/spec/foreman/export/daemon_spec.rb @@ -60,7 +60,7 @@ expect(File.read("/tmp/init/app-alpha.conf")).to eq(example_export_file("daemon/app-alpha.conf")) expect(File.read("/tmp/init/app-alpha-1.conf")).to eq(example_export_file("daemon/app-alpha-1.conf")) expect(File.read("/tmp/init/app-alpha-2.conf")).to eq(example_export_file("daemon/app-alpha-2.conf")) - expect(File.exists?("/tmp/init/app-bravo-1.conf")).to eq(false) + expect(File.exist?("/tmp/init/app-bravo-1.conf")).to eq(false) end end diff --git a/spec/foreman/export/upstart_spec.rb b/spec/foreman/export/upstart_spec.rb index 2151f74e..5c734978 100644 --- a/spec/foreman/export/upstart_spec.rb +++ b/spec/foreman/export/upstart_spec.rb @@ -81,7 +81,7 @@ expect(File.read("/tmp/init/app-alpha.conf")).to eq(example_export_file("upstart/app-alpha.conf")) expect(File.read("/tmp/init/app-alpha-1.conf")).to eq(example_export_file("upstart/app-alpha-1.conf")) expect(File.read("/tmp/init/app-alpha-2.conf")).to eq(example_export_file("upstart/app-alpha-2.conf")) - expect(File.exists?("/tmp/init/app-bravo-1.conf")).to eq(false) + expect(File.exist?("/tmp/init/app-bravo-1.conf")).to eq(false) end end diff --git a/spec/foreman/procfile_spec.rb b/spec/foreman/procfile_spec.rb index 71c15ea9..ae604245 100644 --- a/spec/foreman/procfile_spec.rb +++ b/spec/foreman/procfile_spec.rb @@ -22,6 +22,14 @@ expect(procfile["foo_bar"]).to eq("./foo_bar") end + it "raises an error if Procfile is empty" do + write_file "Procfile" do |procfile| + procfile.puts + end + + expect { Foreman::Procfile.new("Procfile") }.to raise_error described_class::EmptyFileError + end + it 'only creates Procfile entries for lines matching regex' do write_procfile procfile = Foreman::Procfile.new("Procfile") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2934458a..bad817e6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,7 +37,7 @@ def foreman(args) def forked_foreman(args) rd, wr = make_pipe - Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr) + Process.spawn("bundle exec bin/overman #{args}", :out => wr, :err => wr) wr.close rd.read end @@ -62,7 +62,7 @@ def fork_and_capture(&blk) end def fork_and_get_exitstatus(args) - pid = Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null") + pid = Process.spawn("bundle exec bin/overman #{args}", :out => "/dev/null", :err => "/dev/null") Process.wait(pid) $?.exitstatus end @@ -171,7 +171,4 @@ def capture_stdout config.before(:each) do FileUtils.mkdir_p('/tmp') end - config.after(:each) do - FileUtils.rm_rf('/tmp') - end end diff --git a/tasks/dist.rake b/tasks/dist.rake index b4c381e3..84bfab8e 100644 --- a/tasks/dist.rake +++ b/tasks/dist.rake @@ -40,7 +40,7 @@ def beta? end def clean(file) - rm file if File.exists?(file) + rm file if File.exist?(file) end def distribution_files(type=nil) diff --git a/tasks/release.rake b/tasks/release.rake index bc02c8c1..eefc1917 100644 --- a/tasks/release.rake +++ b/tasks/release.rake @@ -24,7 +24,7 @@ task :pages => "man:commit" do git add -u index.html git commit -m "saving man page to github docs" git push origin -f gh-pages - git checkout master + git checkout main } end