Skip to content

Commit

Permalink
fix tests for github
Browse files Browse the repository at this point in the history
  • Loading branch information
Largo committed Feb 14, 2024
1 parent 6e48ba7 commit a27664a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- '*'
jobs:
build-and-release:
run-tests:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 12 additions & 2 deletions test/test_ocra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,27 @@ def with_tmpdir(files = [], path = nil)
end
end

def relative_or_absolute_path(from_path, to_path)
begin
# Attempt to generate a relative path
Pathname.new(to_path).relative_path_from(Pathname.new(from_path)).to_s
rescue ArgumentError
# If a relative path cannot be computed, return the absolute path
Pathname.new(to_path).realpath.to_s
end
end

def each_path_combo(*files)
# In same directory as first file
basedir = Pathname.new(files[0]).realpath.parent
args = files.map{|p|Pathname.new(p).realpath.relative_path_from(basedir).to_s}
args = files.map{|p| relative_or_absolute_path(basedir, p) }
cd basedir do
yield(*args)
end

# In parent directory of first file
basedir = basedir.parent
args = files.map{|p|Pathname.new(p).realpath.relative_path_from(basedir).to_s}
args = files.map{|p| relative_or_absolute_path(basedir, p) }
cd basedir do
yield(*args)
end
Expand Down

0 comments on commit a27664a

Please sign in to comment.