Skip to content

Commit

Permalink
Merge pull request #203634 from Homebrew/msitools-test
Browse files Browse the repository at this point in the history
msitools: use shell_output and assert_path_exists in test
  • Loading branch information
cho-m authored Jan 9, 2025
2 parents 3d7359a + 4dd42ea commit 9fd48be
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Formula/m/msitools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def install

test do
# wixl-heat: make an xml fragment
assert_match "<Fragment>", pipe_output("#{bin}/wixl-heat --prefix test")
assert_match "<Fragment>", pipe_output("#{bin}/wixl-heat --prefix test", nil, 0)

# wixl: build two installers
1.upto(2) do |i|
Expand Down Expand Up @@ -80,18 +80,16 @@ def install
</Wix>
XML
system bin/"wixl", "-o", "installer#{i}.msi", "installer#{i}.wxs"
assert_predicate testpath/"installer#{i}.msi", :exist?
assert_path_exists testpath/"installer#{i}.msi"
end

# msidiff: diff two installers
lines = `#{bin}/msidiff --list installer1.msi installer2.msi 2>/dev/null`.split("\n")
assert_equal 0, $CHILD_STATUS.exitstatus
lines = shell_output("#{bin}/msidiff --list installer1.msi installer2.msi 2>/dev/null").split("\n")
assert_equal "-Program Files/test/test1.txt", lines[-2]
assert_equal "+Program Files/test/test2.txt", lines[-1]

# msiinfo: show info for an installer
out = `#{bin}/msiinfo suminfo installer1.msi`
assert_equal 0, $CHILD_STATUS.exitstatus
out = shell_output("#{bin}/msiinfo suminfo installer1.msi")
assert_match(/Author: BigCo/, out)

# msiextract: extract files from an installer
Expand All @@ -103,7 +101,7 @@ def install
# msidump: dump tables from an installer
mkdir "idt"
system bin/"msidump", "--directory", "idt", "installer1.msi"
assert_predicate testpath/"idt/File.idt", :exist?
assert_path_exists testpath/"idt/File.idt"

# msibuild: replace a table in an installer
system bin/"msibuild", "installer1.msi", "-i", "idt/File.idt"
Expand Down

0 comments on commit 9fd48be

Please sign in to comment.