在Docker中查找Makefile的路径-shell脚本

问题描述 投票:0回答:1

我有一个具有以下目录的码头工人:〜/ specs / scripts。那里我有file.c和对应的Makefile。另外,我在同一目录中添加了C_util.sh:

set -e
make -f Makefile

我想通过拥有〜/ specs / helpers / shared_endpoints / Cutil.rb文件来进行Ruby测试。

我写的是:

    describe 'the script' do
        include Rspec::Bash

        let(:stubbed_env) { create_stubbed_env }

        it 'runs the script' do
            stdout, stderr, status = stubbed_env.execute(
                '${PWD}/specs/scripts/C_util.sh',

但是在正确的目录中找不到Makefile,并且我有退出代码2。我的问题是如何导航到Makefile?

ruby-on-rails ruby docker makefile rspec
1个回答
0
投票

可能有几个原因。

1)您的字符串插值错误,字符串插值在Ruby中与#{}一起使用,但最好使用File.join

File.join(Dir.pwd, "scripts", "C_util.sh")

2)要进行更多调试,建议使用以下命令打印控制台的路径:>

puts File.join(Dir.pwd, "scripts", "C_util.sh")
    
© www.soinside.com 2019 - 2024. All rights reserved.