Skip to content

Commit

Permalink
Fix default target directory
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Apr 6, 2017
1 parent 9b43020 commit ca3b4f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## Fixed

* Default target directory (when the CARGO_TARGET_DIR is not set)

## [0.12.0] - 2017-04-05

### Added
Expand Down
4 changes: 2 additions & 2 deletions lib/thermite/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ def rust_path(*path_components)

#
# Generate a path relative to the `CARGO_TARGET_DIR` environment variable, or
# {#rust_toplevel_dir} if that is not set.
# {#rust_toplevel_dir}/target if that is not set.
#
def cargo_target_path(target, *path_components)
target_base = ENV.fetch('CARGO_TARGET_DIR', rust_toplevel_dir)
target_base = ENV.fetch('CARGO_TARGET_DIR', File.join(rust_toplevel_dir, 'target'))
File.join(target_base, target, *path_components)
end

Expand Down
2 changes: 1 addition & 1 deletion test/lib/thermite/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_cargo_target_path_with_env_var
def test_cargo_target_path_without_env_var
FileUtils.stubs(:pwd).returns('/tmp/foobar')
ENV['CARGO_TARGET_DIR'] = nil
assert_equal File.join('/tmp/foobar', 'debug', 'bar'),
assert_equal File.join('/tmp/foobar', 'target', 'debug', 'bar'),
config.cargo_target_path('debug', 'bar')
end

Expand Down

0 comments on commit ca3b4f2

Please sign in to comment.