forked from uyuni-project/tetra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_all_subcommand_spec.rb
More file actions
141 lines (106 loc) · 5.93 KB
/
Copy pathgenerate_all_subcommand_spec.rb
File metadata and controls
141 lines (106 loc) · 5.93 KB
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
# frozen_string_literal: true
require "spec_helper"
describe "`tetra generate-all`", type: :aruba do
it "generates specs and tarballs for a sample package, source archive workflow" do
# Use binread for binary files
archive_source = File.join("spec", "data", "#{Tetra::CCOLLECTIONS}.zip")
archive_contents = File.binread(archive_source)
write_file("commons-collections.zip", archive_contents)
# init project
run_command_and_stop("tetra init commons-collections commons-collections.zip", exit_timeout: 120)
cd(File.join("commons-collections", "src", Tetra::CCOLLECTIONS))
# first dry-run, all normal (Interactive & Slow)
run_command("tetra dry-run --very-very-verbose", exit_timeout: 240)
type("mvn package -DskipTests")
type("\u{0004}") # ^D (Ctrl+D)
stop_all_commands
expect(last_command_started.output).to include("[INFO] BUILD SUCCESS")
expect(last_command_started.output).to include("Checking for tetra project")
# first generate-all, all normal
run_command_and_stop("tetra generate-all", exit_timeout: 300)
expect(last_command_started.output).to include("commons-collections-kit.spec generated")
expect(last_command_started.output).to include("commons-collections-kit.tar.xz generated")
expect(last_command_started.output).to include("build.sh generated")
expect(last_command_started.output).to include("commons-collections.spec generated")
# patch one file
append_to_file("README.txt", "patched by tetra test")
# second dry-run fails: sources changed
run_command_and_stop("tetra dry-run", fail_on_error: false)
expect(last_command_started.output).to include("Changes detected in src")
expect(last_command_started.output).to include("Dry run not started")
# run patch
run_command_and_stop("tetra patch")
# third dry-run succeeds with patch (Interactive & Slow)
run_command("tetra dry-run", exit_timeout: 240)
type("mvn package -DskipTests")
type("\u{0004}")
stop_all_commands
expect(last_command_started.output).to include("[INFO] BUILD SUCCESS")
run_command_and_stop("tetra generate-all --very-very-verbose", exit_timeout: 300)
expect(last_command_started.output).to include("commons-collections-kit.spec generated")
expect(last_command_started.output).to include("commons-collections-kit.tar.xz generated")
expect(last_command_started.output).to include("build.sh generated")
expect(last_command_started.output).to include("commons-collections.spec generated")
expect(last_command_started.output).to include("0001-Sources-updated.patch generated")
# rubocop:disable RSpec/ExpectActual
spec_path = "../../packages/commons-collections/commons-collections.spec"
expect(spec_path).to have_file_content(/0001-Sources-updated.patch/)
# rubocop:enable RSpec/ExpectActual
end
it "generates specs and tarballs for a sample package, manual source workflow" do
# Use binread
archive_source = File.join("spec", "data", "#{Tetra::CCOLLECTIONS}.zip")
archive_contents = File.binread(archive_source)
write_file("commons-collections.zip", archive_contents)
# init project
run_command_and_stop("tetra init -n commons-collections")
# add sources
run_command_and_stop("unzip commons-collections.zip -d commons-collections/src")
cd("commons-collections")
# first dry-run fails: sources changed
run_command_and_stop("tetra dry-run", fail_on_error: false)
expect(last_command_started.output).to include("Changes detected in src")
expect(last_command_started.output).to include("Dry run not started")
# run change-sources
run_command_and_stop("tetra change-sources ../commons-collections.zip")
expect(last_command_started.output).to include("New sources committed")
# second dry-run, all normal (Interactive & Slow)
cd(File.join("src", Tetra::CCOLLECTIONS))
run_command("tetra dry-run", exit_timeout: 240)
type("mvn package -DskipTests")
type("\u{0004}")
stop_all_commands
expect(last_command_started.output).to include("[INFO] BUILD SUCCESS")
# first generate-all, all normal
run_command_and_stop("tetra generate-all", exit_timeout: 120)
expect(last_command_started.output).to include("commons-collections-kit.spec generated")
expect(last_command_started.output).to include("commons-collections-kit.tar.xz generated")
expect(last_command_started.output).to include("build.sh generated")
expect(last_command_started.output).to include("commons-collections.spec generated")
# patch one file
append_to_file("README.txt", "patched by tetra test")
# second dry-run fails: sources changed
run_command_and_stop("tetra dry-run", fail_on_error: false)
expect(last_command_started.output).to include("Changes detected in src")
expect(last_command_started.output).to include("Dry run not started")
# run patch
run_command_and_stop("tetra patch")
# third dry-run succeeds with patch (Interactive & Slow)
run_command("tetra dry-run", exit_timeout: 240)
type("mvn package -DskipTests")
type("\u{0004}")
stop_all_commands
expect(last_command_started.output).to include("[INFO] BUILD SUCCESS")
run_command_and_stop("tetra generate-all", exit_timeout: 300)
expect(last_command_started.output).to include("commons-collections-kit.spec generated")
expect(last_command_started.output).to include("commons-collections-kit.tar.xz generated")
expect(last_command_started.output).to include("build.sh generated")
expect(last_command_started.output).to include("commons-collections.spec generated")
expect(last_command_started.output).to include("0001-Sources-updated.patch generated")
# rubocop:disable RSpec/ExpectActual
spec_path = "../../packages/commons-collections/commons-collections.spec"
expect(spec_path).to have_file_content(/0001-Sources-updated.patch/)
expect(spec_path).to have_file_content(/commons-collections.zip/)
# rubocop:enable RSpec/ExpectActual
end
end