summaryrefslogtreecommitdiff
path: root/t/flatpak.t
blob: b7b6edc080d98682ad6702d33a2599daa8895e41 (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/perl
use strict;
use warnings;

use FindBin '$Bin';
use Test::More 0.98;

my $path = "$Bin/data";
use Build;
use Build::Flatpak;

my $conf = Build::read_config('x86_64');

sub capture_stdout {
  my ($fn) = @_;
  local *STDOUT;
  open(STDOUT, '>', \my $cap) || die;
  $fn->();
  return $cap;
}

subtest parse => sub {
    my $expected = {
        name => 'org.gnome.Chess',
        version => 0,
        sources => [
            "phalanx-XXV-source.tgz",
            "stockfish-10-src.zip",
            "gnuchess-6.2.5.tar.gz",
            "gnome-chess-3.36.1.tar.xz",
        ],
        deps => [
            'org.gnome.Sdk-v3.36',
            'org.gnome.Platform-v3.36',
        ],
    };
    my $yaml = do { local $/; <DATA> };
    my $data = Build::Flatpak::parse($conf, \$yaml);
    is_deeply $data, $expected, 'parse() YAML flatpak content';

    $data = Build::Flatpak::parse($conf, "$path/flatpak.yaml");
    is_deeply $data, $expected, 'parse() YAML flatpak file';

    $data = Build::Flatpak::parse($conf, "$path/flatpak.json");
    is_deeply $data, $expected, 'parse() JSON flatpak file';
};

subtest show => sub {
    local @ARGV = ("$path/flatpak.yaml", 'name');
    my $data = capture_stdout(sub { Build::Flatpak::show() });
    is $data, "org.gnome.Chess\n", 'Build::Flatpak::show name';
};

done_testing;

__DATA__
{
    "app-id": "org.gnome.Chess",
    "runtime": "org.gnome.Platform",
    "runtime-version": "3.36",
    "sdk": "org.gnome.Sdk",
    "command": "gnome-chess",
    "finish-args": [
        "--share=ipc", "--socket=fallback-x11",
        "--socket=wayland",
        "--metadata=X-DConf=migrate-path=/org/gnome/Chess/"
    ],
    "cleanup": ["/share/gnuchess", "/share/info", "/share/man", "/include"],
    "modules": [
        {
            "name": "phalanx",
            "buildsystem": "simple",
            "build-commands": [
                "make",
                "install -D phalanx /app/bin/phalanx",
                "install -D pbook.phalanx /app/share/phalanx/pbook.phalanx",
                "install -D sbook.phalanx /app/share/phalanx/sbook.phalanx",
                "install -D eco.phalanx /app/share/phalanx/eco.phalanx"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "file:///usr/src/packages/SOURCES/phalanx-XXV-source.tgz",
                    "sha256": "b3874d5dcd22c64626b2c955b18b27bcba3aa727855361a91eab57a6324b22dd"
                },
                {
                    "type": "patch",
                    "path": "phalanx-books-path.patch"
                }
            ]
        },
        {
            "name": "stockfish",
            "buildsystem": "simple",
            "build-options" : {
                "arch": {
                    "x86_64": {
                        "env": {
                            "ARCH": "x86-64"
                        }
                    },
                    "arm": {
                        "env": {
                            "ARCH": "armv7"
                        }
                    },
                    "aarch64": {
                        "env": {
                            "ARCH": "armv7"
                        }
                    }
                }
            },
            "build-commands": [
                "make build",
                "install -D stockfish /app/bin/stockfish"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "file:///usr/src/packages/SOURCES/stockfish-10-src.zip",
                    "sha256": "29bd01e7407098aa9e851b82f6ea4bf2b46d26e9075a48a269cb1e40c582a073"
                }
            ]
        },
        {
            "name": "gnuchess",
            "sources": [
                {
                    "type": "archive",
                    "url": "file:///usr/src/packages/SOURCES/gnuchess-6.2.5.tar.gz",
                    "sha256": "9a99e963355706cab32099d140b698eda9de164ebce40a5420b1b9772dd04802"
                }
            ]
        },
        {
            "name": "gnome-chess",
            "buildsystem": "meson",
            "sources": [
                {
                    "type": "archive",
                    "url": "file:///usr/src/packages/SOURCES/gnome-chess-3.36.1.tar.xz",
                    "sha256": "b195c9f17a59d7fcc892ff55e6a6ebdd16e7329157bf37e3c2fe593b349aab98"
                }
            ]
        }
    ]
}