Ejemplo n.º 1
0
        private static IEnumerable <BlockchainTest> LoadTestsFromDirectory(string testDir, string wildcard)
        {
            List <BlockchainTest> testsByName = new List <BlockchainTest>();
            List <string>         testFiles   = Directory.EnumerateFiles(testDir).ToList();

            foreach (string testFile in testFiles)
            {
                FileTestsSource fileTestsSource = new FileTestsSource(testFile, wildcard);
                try
                {
                    var tests = fileTestsSource.LoadTests().ToList();
                    foreach (BlockchainTest blockchainTest in tests)
                    {
                        blockchainTest.Category = testDir;
                    }

                    testsByName.AddRange(tests);
                }
                catch (Exception e)
                {
                    testsByName.Add(new BlockchainTest {
                        Name = testFile, LoadFailure = $"Failed to load: {e.Message}"
                    });
                }
            }

            return(testsByName);
        }
Ejemplo n.º 2
0
        public IEnumerable <IEthereumTest> Load(string testName, string wildcard = null)
        {
            //in case user wants to give test file other than the ones in ethereum tests submodule
            if (File.Exists(testName))
            {
                var fileTestsSource = new FileTestsSource(testName, wildcard);
                var tests           = fileTestsSource.LoadGeneralStateTests();

                return(tests);
            }

            string testsDirectory = GetGeneralStateTestsDirectory();

            IEnumerable <string> testFiles = Directory.EnumerateFiles(testsDirectory, testName, SearchOption.AllDirectories);

            List <GeneralStateTest> generalStateTests = new List <GeneralStateTest>();

            //load all tests from found test files in ethereum tests submodule
            foreach (string testFile in testFiles)
            {
                FileTestsSource fileTestsSource = new FileTestsSource(testFile, wildcard);
                try
                {
                    var tests = fileTestsSource.LoadGeneralStateTests();

                    generalStateTests.AddRange(tests);
                }
                catch (Exception e)
                {
                    generalStateTests.Add(new GeneralStateTest {
                        Name = testFile, LoadFailure = $"Failed to load: {e.Message}"
                    });
                }
            }

            return(generalStateTests);
        }