tokenika / eosfactory

Python-based EOS smart-contract development & testing framework
http://eosfactory.io/
Other
243 stars 62 forks source link

Can have no source code in target directory, causing cryptic error msg #73

Closed vt102 closed 5 years ago

vt102 commented 5 years ago

Pointing at a build directory instead of a source directory, you can get in a situation where eosfactory find "source" files:

srcs = config.getContractSourceFiles(contract_dir)

However, what is has found is just the .abi file. As it proceeds, it tries to compile the sources:

    objectFileList = []
    extensions = [".h", ".hpp", ".hxx", ".c", ".cpp",".cxx", ".c++"]
:
    for file in srcs:
        if not os.path.splitext(file)[1].lower() in extensions:
            continue

The .abi file is not is srcs, so it is skipped, and this line is never reached:

        objectFileList.append(output)

Thus, the following command_line has an empty element:

    if not compile_only:
        command_line = [
            config.getEOSIO_WASM_LLVM_LINK(),
            "-only-needed",
            "-o",  workdir + "/linked.bc",
            " ".join(objectFileList),
            config.getSourceDir() + "/build/contracts/musl/libc.bc",
            config.getSourceDir() + "/build/contracts/libc++/libc++.bc",
            config.getSourceDir() + "/build/contracts/eosiolib/eosiolib.bc"
        ]

That missing element causes the following cryptic error:

###  setUpClass:
Load eosio.token contract into nesha account:

NOTE:
An ABI exists in the source directory. Cannot overwrite it:
/home/eos-v1.0/eos/build/contracts/eosio.token/eosio.token.abi
Just copying it to the target directory.
######## /home/ubuntu/opt/wasm/bin/llvm-link:
/home/ubuntu/opt/wasm/bin/llvm-link -only-needed -o /home/eos-v1.0/eos/build/contracts/eosio.token/working_dir/linked.bc  /home/eos-v1.0/eos//build/contracts/musl/libc.bc /home/eos-v1.0/eos//build/contracts/libc++/libc++.bc /home/eos-v1.0/eos//build/contracts/eosiolib/eosiolib.bc
E
======================================================================
ERROR: setUpClass (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/src/eosfactory/pyteos/core/teos.py", line 186, in WAST
    process(command_line)
  File "/home/ubuntu/src/eosfactory/pyteos/core/teos.py", line 409, in process
    raise errors.Error(out_err)
core.errors.Error: ERROR:
/home/ubuntu/opt/wasm/bin/llvm-link: error: Could not open input file: No such file or directory
/home/ubuntu/opt/wasm/bin/llvm-link: error loading file ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "nesha_tests/nesha_tests.py", line 38, in setUpClass
    contract.build()
  File "/home/ubuntu/src/eosfactory/pyteos/shell/contract.py", line 68, in build
    self.build_wast()
  File "/home/ubuntu/src/eosfactory/pyteos/shell/contract.py", line 60, in build_wast
    teos.WAST(self.contract_dir)
  File "/home/ubuntu/src/eosfactory/pyteos/core/teos.py", line 193, in WAST
    raise errors.Error(str(e))
core.errors.Error: ERROR:
ERROR:
/home/ubuntu/opt/wasm/bin/llvm-link: error: Could not open input file: No such file or directory
/home/ubuntu/opt/wasm/bin/llvm-link: error loading file ''

----------------------------------------------------------------------
Ran 0 tests in 6.144s

FAILED (errors=1)
ubuntu@ip-10-0-2-230:~/src/eosfactory$ 
stefanzarembinski commented 5 years ago

Thank you for the precise note.

SZ