Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
24f6834f
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
24f6834f
编写于
7月 13, 2021
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add installer unit tests
上级
c31e72fb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
202 addition
and
0 deletion
+202
-0
.github/workflows/scripts.yml
.github/workflows/scripts.yml
+27
-0
ci/dev/test-scripts.sh
ci/dev/test-scripts.sh
+9
-0
docs/CONTRIBUTING.md
docs/CONTRIBUTING.md
+2
-0
package.json
package.json
+1
-0
test/scripts/install.bats
test/scripts/install.bats
+163
-0
未找到文件。
.github/workflows/scripts.yml
0 → 100644
浏览文件 @
24f6834f
name
:
Script unit tests
on
:
push
:
branches
:
-
main
paths
:
-
"
installer.sh"
pull_request
:
branches
:
-
main
jobs
:
test
:
name
:
Run script unit tests
runs-on
:
ubuntu-latest
# This runs on Alpine to make sure we're testing with actual sh.
container
:
"
alpine:3.14"
steps
:
-
name
:
Checkout repo
uses
:
actions/checkout@v2
-
name
:
Install bats
run
:
apk add bats
-
name
:
Run script unit tests
run
:
./ci/dev/test-scripts.sh
ci/dev/test-scripts.sh
0 → 100755
浏览文件 @
24f6834f
#!/usr/bin/env bash
set
-euo
pipefail
main
()
{
cd
"
$(
dirname
"
$0
"
)
/../.."
bats ./test/scripts
}
main
"
$@
"
docs/CONTRIBUTING.md
浏览文件 @
24f6834f
...
...
@@ -44,6 +44,8 @@ Here is what is needed:
-
Get this by running
`apt-get install -y build-essential`
-
`rsync`
and
`unzip`
-
Used for code-server releases
-
`bats`
-
Used to run script unit tests
## Creating pull requests
...
...
package.json
浏览文件 @
24f6834f
...
...
@@ -20,6 +20,7 @@
"test:e2e"
:
"./ci/dev/test-e2e.sh"
,
"test:standalone-release"
:
"./ci/build/test-standalone-release.sh"
,
"test:unit"
:
"./ci/dev/test-unit.sh"
,
"test:scripts"
:
"./ci/dev/test-scripts.sh"
,
"package"
:
"./ci/build/build-packages.sh"
,
"postinstall"
:
"./ci/dev/postinstall.sh"
,
"update:vscode"
:
"./ci/dev/update-vscode.sh"
,
...
...
test/scripts/install.bats
0 → 100644
浏览文件 @
24f6834f
#!/usr/bin/env bats
SCRIPT_NAME="install.sh"
SCRIPT="$BATS_TEST_DIRNAME/../../$SCRIPT_NAME"
# Override version so it doesn't have to curl and to avoid caching in case the
# user already has the latest version installed.
export VERSION="9999.99.9"
function should-use-deb() {
DISTRO=$1 ARCH=$2 OS=linux run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Installing v$VERSION of the $2 deb package from GitHub." ]
[ "${lines[-5]}" = "deb package has been installed." ]
}
function should-use-rpm() {
DISTRO=$1 ARCH=$2 OS=linux run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Installing v$VERSION of the $2 rpm package from GitHub." ]
[ "${lines[-5]}" = "rpm package has been installed." ]
}
function should-fallback-npm() {
YARN_PATH=true DISTRO=$1 ARCH=$2 OS=linux run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "No standalone releases for $2." ]
[ "${lines[2]}" = "Falling back to installation from npm." ]
[ "${lines[3]}" = "Installing latest from npm." ]
[ "${lines[-5]}" = "npm package has been installed." ]
}
function should-use-npm() {
YARN_PATH=true DISTRO=$1 ARCH=$2 OS=linux run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Installing latest from npm." ]
[ "${lines[-5]}" = "npm package has been installed." ]
}
function should-use-aur() {
DISTRO=$1 ARCH=$2 OS=linux run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Installing latest from the AUR." ]
[ "${lines[-5]}" = "AUR package has been installed." ]
}
function should-fallback-npm-brew() {
YARN_PATH=true BREW_PATH= OS=macos ARCH=$1 run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Homebrew not installed." ]
[ "${lines[2]}" = "Falling back to standalone installation." ]
[ "${lines[3]}" = "No standalone releases for $1." ]
[ "${lines[4]}" = "Falling back to installation from npm." ]
[ "${lines[5]}" = "Installing latest from npm." ]
[ "${lines[-5]}" = "npm package has been installed." ]
}
function should-use-brew() {
BREW_PATH=true OS=macos ARCH=$1 run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Installing latest from Homebrew." ]
[ "${lines[-3]}" = "Brew release has been installed." ]
}
function should-use-standalone() {
DISTRO=$1 ARCH=$2 OS=$3 run "$SCRIPT" --method standalone --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Installing v$VERSION of the $2 release from GitHub." ]
[[ "${lines[-5]}" = "Standalone release has been installed"* ]]
}
@test "$SCRIPT_NAME: usage with --help" {
run "$SCRIPT" --help
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Installs code-server." ]
[[ "${lines[-1]}" = "More installation docs are at"* ]]
}
# These use the deb but fall back to npm for unsupported architectures.
@test "$SCRIPT_NAME: debian arm64" {
should-use-deb "debian" "arm64"
}
@test "$SCRIPT_NAME: debian amd64" {
should-use-deb "debian" "amd64"
}
@test "$SCRIPT_NAME: debian i386" {
should-fallback-npm "debian" "i386"
}
# These use the rpm but fall back to npm for unsupported architectures.
@test "$SCRIPT_NAME: fedora arm64" {
should-use-rpm "fedora" "arm64"
}
@test "$SCRIPT_NAME: fedora amd64" {
should-use-rpm "fedora" "amd64"
}
@test "$SCRIPT_NAME: fedora i386" {
should-fallback-npm "fedora" "i386"
}
# These always use npm regardless of the architecture.
@test "$SCRIPT_NAME: alpine arm64" {
should-use-npm "alpine" "arm64"
}
@test "$SCRIPT_NAME: alpine amd64" {
should-use-npm "alpine" "amd64"
}
@test "$SCRIPT_NAME: alpine i386" {
should-use-npm "alpine" "i386"
}
@test "$SCRIPT_NAME: freebsd arm64" {
should-use-npm "freebsd" "arm64"
}
@test "$SCRIPT_NAME: freebsd amd64" {
should-use-npm "freebsd" "amd64"
}
@test "$SCRIPT_NAME: freebsd i386" {
should-use-npm "freebsd" "i386"
}
# Arch Linux uses AUR but falls back to npm for unsuppported architectures.
@test "$SCRIPT_NAME: arch arm64" {
should-use-aur "arch" "arm64"
}
@test "$SCRIPT_NAME: arch amd64" {
should-use-aur "arch" "amd64"
}
@test "$SCRIPT_NAME: arch i386" {
should-fallback-npm "arch" "i386"
}
# macOS use homebrew but falls back to standalone when brew is unavailable then
# to npm for unsupported architectures.
@test "$SCRIPT_NAME: macos arm64 (no brew)" {
should-fallback-npm-brew "arm64"
}
@test "$SCRIPT_NAME: macos amd64 (no brew)" {
BREW_PATH= OS=macos ARCH=amd64 run "$SCRIPT" --dry-run
[ "$status" -eq 0 ]
[ "${lines[1]}" = "Homebrew not installed." ]
[ "${lines[2]}" = "Falling back to standalone installation." ]
[ "${lines[3]}" = "Installing v$VERSION of the amd64 release from GitHub." ]
[[ "${lines[-5]}" = "Standalone release has been installed"* ]]
}
@test "$SCRIPT_NAME: macos i386 (no brew)" {
should-fallback-npm-brew "i386"
}
@test "$SCRIPT_NAME: macos arm64 (brew)" {
should-use-brew "arm64"
}
@test "$SCRIPT_NAME: macos amd64 (brew)" {
should-use-brew "amd64"
}
@test "$SCRIPT_NAME: macos i386 (brew)" {
should-use-brew "i386"
}
# Force standalone.
@test "$SCRIPT_NAME: debian amd64 --method standalone" {
should-use-standalone "debian" "amd64" "linux"
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录