Skip to content

Commit

Permalink
if windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hemnstill committed Feb 26, 2024
1 parent 729143f commit ef9a335
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .tests/ci-test-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set -e

"$dp0/test-tools.sh" || exit 1

cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1
if [[ "$is_windows_os" == true ]]; then
cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1
fi

"$dp0/test-run.sh" -- testInternalCreate || exit 1
12 changes: 6 additions & 6 deletions _AutoinstallCreator/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
_root_path: str = os.path.dirname(_self_path)
_tools_path: str = os.path.join(_root_path, '.tools')

busybox_exe_path: str = 'busybox'
busybox_exe_path_arg: list[str] = []
update_script_name: str = 'update.sh'
package_name = 'AutoinstallCreator.sh'
if sys.platform.startswith('win'):
busybox_exe_path = os.path.join(_tools_path, 'busybox.exe')
busybox_exe_path_arg = [os.path.join(_tools_path, 'busybox.exe')]
update_script_name = 'update.bat'
package_name = 'AutoinstallCreator.sh.bat'

Expand Down Expand Up @@ -45,7 +45,7 @@ def setUpClass(cls) -> None:
pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True)
pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True)

result = subprocess.run(['bash', os.path.join(_self_path, 'release.sh')],
result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_path, 'release.sh')],
check=True, stdout=subprocess.PIPE)
cls.version_str = get_version_from_stdout(result.stdout)

Expand All @@ -57,9 +57,9 @@ def setUp(self):
shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath)

def test_version_up_to_date(self):
subprocess.run(['bash', self.package_filepath], cwd=_self_tmp_path)
subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath], cwd=_self_tmp_path)

result = subprocess.run(['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')],
result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')],
env={
**os.environ,
'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str,
Expand All @@ -69,7 +69,7 @@ def test_version_up_to_date(self):
self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n'))

def test_update_to_new_version(self):
subprocess.run(['bash', self.package_filepath, '--target', self.test_old_version],
subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath, '--target', self.test_old_version],
cwd=_self_tmp_path)

io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'),
Expand Down

0 comments on commit ef9a335

Please sign in to comment.