In Version v4.1.5 truffle test will throw errors, If I downgrade the truffle version to v4.0.4 , it will work
TestMyContract
1) "before all" hook: prepare suite
0 passing (625ms)
1 failing
1) TestMyContract "before all" hook: prepare suite:
Error: Could not find artifacts for "path"
Truffle test
truffle version): v4.1.5Same issue for me solidity tests fails with 4.1.5 but works with v4.1.4 (Windows 7 x64).
@ismaelbej Are you seeing exactly the same error? Could you also show something of the solidity test file so we can try to figure out what's gone wrong here? Anything you can provide to help us reproduce errors is extremely helpful.
@woodenchalet If possible could you provide reproduction steps by linking to the tests you're trying to run, or creating minimized example of the problem? We have integration tests at Truffle that validate the solidity testing feature and they pass, so we need more than truffle test as a reproduction step to understand this bug.
I'll try to create a small reproducible example for now the stack trace output
1) TestRelay "before all" hook: prepare suite:
Error: Could not find artifacts for /D/test/contracts/Parser/Tx.sol from any sources
at Resolver.require (C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-resolver\index.js:37:1)
at TestResolver.require (C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\testresolver.js:17:1)
at TestResolver.require (C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\testresolver.js:17:1)
at C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\soliditytest.js:141:1
at Array.forEach (<anonymous>)
at C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\soliditytest.js:140:1
at C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-deployer\src\deferredchain.js:20:1
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
The file Parser/Tx.sol is a dependency of RelayTests but compilation and migration run fine. Also executing javascript test will run without issues.
And the solidity test, but I think the content doesn't matter too much because it is never run.
pragma solidity ^0.4.15;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/RelayTests.sol";
contract TestRelay {
function testFlip32Bytes() {
RelayTests dr = RelayTests(DeployedAddresses.RelayTests());
uint expected = 0x201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201;
Assert.equal(dr.flip32BytesPublic(0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20), expected, "flip32Bytes failed");
}
}
@ismaelbej Awesome, thank you. That's perfect - should be able to reproduce with what you've provided.
Thank you @ismaelbej this reproduce is similar to what I got.
@woodenchalet @ismaelbej I tried to reproduce this using the MetaCoin project but wasn't able (I'm on OSX). I'd like to figure out if this is Windows specific or if my model for the bug is wrong. My directory structure looked like this:
contracts /
Parser /
Tx.sol
Metacoin.sol
ConvertLib.sol
Migrations.sol
test /
TestMetacoin.sol
Imports at the top of MetaCoin.sol look like this:
pragma solidity ^0.4.18;
import "./ConvertLib.sol";
import "./Parser/Tx.sol";
contract MetaCoin is Tx {
...etc...
}
Imports at the top of TestMetaCoin.sol look like this:
pragma solidity ^0.4.2;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/MetaCoin.sol";
contract TestMetacoin {
... etc ...
}
Output is as expected:
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Parser/Tx.sol...
Compiling ./test/TestMetacoin.sol...
Compiling truffle/Assert.sol...
Compiling truffle/DeployedAddresses.sol...
Also tried running compile before test and everything worked. Should the project structure above trigger the error based on what you've seen in your own project?
@cgewecke Could be a PowerShell or Windows thing, I try to run the truffle test under Linux, they all passed.
Both under Truffle V4.1.5
Windows 10 PowerShell

Ubuntu 16.04

Truffle V4.1.4
Windows Powershell works

@woodenchalet Ok great, good to know. I'm going to modify the title of your issue to reflect that and look into why the paths aren't being made OS neutral correctly anymore.
Hi @cgewecke I am facing the exactly same issue here.
Could you please update what's happening ?
Hi @woodenchalet , @ismaelbej
Is there any workaround?
Thanks
I downgraded to truffle 4.1.14 and it works.
Btw, this is on Windows platform.
After some debugging compileContractsWithTestFilesIfNeeded in https://github.com/trufflesuite/truffle-core/blob/develop/lib/test.js#L103 will return dependencies in different format between v4.1.4 and v4.1.5 on windows
With v4.1.5
{
"paths": [
"/C/Users/daffyduck/develop/mud/contracts/ConvertLib.sol",
"/C/Users/daffyduck/develop/mud/contracts/MetaCoin.sol",
"/C/Users/daffyduck/develop/mud/test/TestMetacoin.sol",
"truffle/Assert.sol",
"truffle/DeployedAddresses.sol"
]
}
With v4.1.4
{
"paths": [
"C:\\Users\\daffyduck\\develop\\mud\\test\\TestMetacoin.sol",
"truffle/Assert.sol",
"truffle/DeployedAddresses.sol",
"C:\\Users\\daffyduck\\develop\\mud\\contracts\\MetaCoin.sol",
"C:\\Users\\daffyduck\\develop\\mud\\contracts\\ConvertLib.sol"
]
}
The contract I've used is Metacoin without any modification, running truffle test .\test\TestMetacoin.sol.
@ismaelbej Thanks! That's really helpful. We're going to spin up our windows box and get to the bottom this. . .hopefully fix this quickly.
I am also experiencing this problem with Windows using Powershell, even after I change to pragma solidity ^0.4.14; One difference I see is what is missing is ConvertLib (which seems to be different from what is mentioned above):
Error: Could not find artifacts for /C/Users/jeff/smartContracts/MetaCoin/contracts/ConvertLib.sol from any sources
at Resolver.require (C:\Users\jeff\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-resolver\index.js:37:1)
at TestResolver.require (C:\Users\jeff\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\libtestingtestresolver.js:17:1)
at TestResolver.require (C:\Users\jeff\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\libtestingtestresolver.js:17:1)
at C:\Users\jeff\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\libtesting\soliditytest.js:141:1
at Array.forEach (
at C:\Users\jeff\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\libtesting\soliditytest.js:140:1
at C:\Users\jeff\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-deployer\src\deferredchain.js:20:1
at
at process._tickCallback (internal/process/next_tick.js:188:7)
I installed Truffle within the past week. Finally, to be clear, the js test works; it is only the Solidity test that fails.
Oops, my bad for breaking this. ^ PR should fix, expect release early next week. Thanks!
This has been released in v4.1.6. Thanks!
Most helpful comment
@woodenchalet @ismaelbej I tried to reproduce this using the MetaCoin project but wasn't able (I'm on OSX). I'd like to figure out if this is Windows specific or if my model for the bug is wrong. My directory structure looked like this:
Imports at the top of
MetaCoin.sollook like this:Imports at the top of
TestMetaCoin.sollook like this:Output is as expected:
Also tried running
compilebeforetestand everything worked. Should the project structure above trigger the error based on what you've seen in your own project?