Skip to content

Commit

Permalink
Use Python's platform agnostic file checks in gather_design_stats_test
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 655818896
  • Loading branch information
hnpl authored and copybara-github committed Jul 25, 2024
1 parent bf58c15 commit 75d9435
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions xls/tools/gather_design_stats_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
"""Tests for xls/tools/gather_design_stats.py."""

import filecmp
import pathlib
import subprocess

from absl.testing import absltest
Expand Down Expand Up @@ -44,11 +46,9 @@ def test_degenerate_use(self):
],
check=True,
)
wc_output = subprocess.check_output([
'wc',
out_textproto_file.full_path,
]).decode('utf-8')
self.assertIn('0 0 0', wc_output)
out_textproto_file_path = pathlib.Path(out_textproto_file)
self.assertTrue(out_textproto_file_path.exists())
self.assertEqual(out_textproto_file_path.stat().st_size, 0)

def test_sample_use(self):
out_textproto_file = self.create_tempfile()
Expand All @@ -62,12 +62,9 @@ def test_sample_use(self):
],
check=True,
)
diff_output = subprocess.check_output([
'diff',
out_textproto_file.full_path,
_EXP_TEXTPROTO_PATH,
]).decode('utf-8')
self.assertEmpty(diff_output)
self.assertTrue(
filecmp.cmp(out_textproto_file.full_path, _EXP_TEXTPROTO_PATH)
)


if __name__ == '__main__':
Expand Down

0 comments on commit 75d9435

Please sign in to comment.