File: test_buildsystem_names.rs

package info (click to toggle)
debian-codemods 0.174
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,588 kB
  • sloc: makefile: 900; xml: 119; python: 80; sh: 71; javascript: 3
file content (49 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#[test]
fn test_ognibuild_buildsystem_names() {
    use std::fs;
    use tempfile::TempDir;

    // Test what build system names ognibuild returns
    let test_cases = vec![
        ("CMakeLists.txt", "cmake\nproject(test)\n"),
        ("configure.ac", "AC_INIT([test], [1.0])\n"),
        ("configure.in", "AC_INIT([test], [1.0])\n"),
        ("Makefile", "all:\n\techo 'test'\n"),
        (
            "setup.py",
            "from setuptools import setup\nsetup(name='test')\n",
        ),
        (
            "Cargo.toml",
            "[package]\nname = \"test\"\nversion = \"0.1.0\"\n",
        ),
        ("go.mod", "module test\n\ngo 1.20\n"),
        (
            "package.json",
            "{\"name\": \"test\", \"version\": \"1.0.0\"}\n",
        ),
        ("pom.xml", "<project></project>\n"),
        ("dist.ini", "name = Test\n"),
        ("META.json", "{\"name\": \"Test\"}\n"),
        ("Build.PL", "use Module::Build;\n"),
        ("Makefile.PL", "use ExtUtils::MakeMaker;\n"),
        ("DESCRIPTION", "Package: test\n"),
        ("DESCRIPTION.in", "Package: test\n"),
    ];

    println!("\nOgnibuild build system detection:");
    for (filename, content) in test_cases {
        let temp_dir = TempDir::new().unwrap();
        let file_path = temp_dir.path().join(filename);
        fs::write(&file_path, content).unwrap();

        let buildsystems = ognibuild::buildsystem::detect_buildsystems(temp_dir.path());
        let buildsystem = buildsystems.into_iter().next();

        if let Some(bs) = buildsystem {
            println!("{:20} -> {}", filename, bs.name());
        } else {
            println!("{:20} -> No build system detected", filename);
        }
    }
}