|
10 | 10 |
|
11 | 11 |
|
12 | 12 | class TestRustListDependencies(unittest.TestCase):
|
13 |
| - def test_success(self) -> None: |
| 13 | + def test_separate_crates(self) -> None: |
14 | 14 | files = {
|
15 | 15 | pathlib.Path('rust-toolchain'): textwrap.dedent("""\
|
16 | 16 | 1.42.0
|
@@ -60,6 +60,40 @@ def test_success(self) -> None:
|
60 | 60 | actual = sorted(RustLanguage(config=None).list_dependencies(tempdir / 'crates' / 'a' / 'src' / 'lib.rs', basedir=tempdir))
|
61 | 61 | self.assertEqual(actual, expected)
|
62 | 62 |
|
| 63 | + def test_mono_crate(self) -> None: |
| 64 | + files = { |
| 65 | + pathlib.Path('rust-toolchain'): textwrap.dedent("""\ |
| 66 | + 1.42.0 |
| 67 | + """).encode(), |
| 68 | + pathlib.Path('Cargo.toml'): textwrap.dedent("""\ |
| 69 | + [package] |
| 70 | + name = "my_competitive_library" |
| 71 | + version = "0.0.0" |
| 72 | + edition = "2018" |
| 73 | + """).encode(), |
| 74 | + pathlib.Path('src', 'lib.rs'): textwrap.dedent("""\ |
| 75 | + pub mod a; |
| 76 | + pub mod b; |
| 77 | + pub mod c; |
| 78 | + """).encode(), |
| 79 | + pathlib.Path('src', 'a.rs'): textwrap.dedent("""\ |
| 80 | + pub struct A; |
| 81 | + """).encode(), |
| 82 | + pathlib.Path('src', 'b.rs'): textwrap.dedent("""\ |
| 83 | + pub struct B; |
| 84 | + """).encode(), |
| 85 | + pathlib.Path('src', 'c.rs'): textwrap.dedent("""\ |
| 86 | + pub struct C; |
| 87 | + """).encode(), |
| 88 | + } |
| 89 | + |
| 90 | + with tests.utils.load_files_pathlib(files) as tempdir: |
| 91 | + expected = [tempdir / 'src' / f'{stem}.rs' for stem in ['a', 'b', 'c', 'lib']] |
| 92 | + |
| 93 | + for file_stem in ['a', 'b', 'c', 'lib']: |
| 94 | + actual = sorted(RustLanguage(config=None).list_dependencies(tempdir / 'src' / f'{file_stem}.rs', basedir=tempdir)) |
| 95 | + self.assertEqual(actual, expected) |
| 96 | + |
63 | 97 |
|
64 | 98 | class TestRustVerification(unittest.TestCase):
|
65 | 99 | def test_success(self) -> None:
|
|
0 commit comments