Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
 - Update emscripten, libarchive and Mbed-TLS
 - Remove fix_tz.patch, as new version of emscripten include the fix
 - Update libarchive headers
  • Loading branch information
HeavenVolkoff committed Sep 18, 2024
1 parent 32e2d77 commit 5fd7aa7
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 81 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,3 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/Node,Windows,Linux,macOS,VisualStudioCode,C

package.json.backup
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"src/**/*"
],
"author": "Vítor Vasconcellos",
"version": "1.7.0",
"version": "1.7.1",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=18.4"
Expand Down Expand Up @@ -46,7 +46,6 @@
"postbuild:js": "npm run format",
"prebuild": "npm run docs",
"build": "conc -c auto --timings --kill-others-on-fail 'npm:build:*'",
"postbuild": "npm run format",
"test": "test/setupAndRun.sh",
"prebuildtest": "npm run build",
"buildtest": "npm run test",
Expand Down Expand Up @@ -88,12 +87,12 @@
"concurrently": "^9.0.1",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-jsdoc": "^50.2.3",
"eslint-plugin-license-header": "^0.6.1",
"eslint-plugin-local-rules": "^3.0.2",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0",
"neostandard": "^0.11.4",
"neostandard": "^0.11.5",
"prettier": "3.3.3",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.7",
Expand Down
21 changes: 10 additions & 11 deletions test/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
PassphraseError,
} from '../src/archive.mjs'
import { extractTo } from '../src/fs.mjs'
import { FILETYPE_FLAG } from '../src/wasm/enums.mjs'
import { EntryType, EntryTypeName, FILETYPE_FLAG } from '../src/wasm/enums.mjs'

// The parent directory for the new temporary directory
const tmpDir = tmpdir()
Expand All @@ -52,13 +52,14 @@ const gitignoreFileStat = fs.statSync(new URL('../.gitignore', import.meta.url),
* @param {import('ava').ExecutionContext<unknown>} t
* @param {ReturnType<extract> | import('../src/archive.mjs').Entry[]} entries
* @param {number} i
* @param {boolean} [nullCheck]
* @returns {import('../src/archive.mjs').Entry}
*/
const getNextEntry = (t, entries, i) => {
const getNextEntry = (t, entries, i, nullCheck = true) => {
const entry = /** @type {import('../src/archive.mjs').Entry} */ (
Array.isArray(entries) ? entries[i] : entries.next().value
)
t.false(entry == null)
if (nullCheck) t.assert(entry != null)
return entry
}

Expand All @@ -85,21 +86,19 @@ const licenseCheck = (t, archivePath, opts, mode) => {
['PREAMBLE', preambleFile, preambleFileStat],
])) {
const entry = getNextEntry(t, entries, i++)
t.false(entry == null)
t.is(entry.path, path)
t.is(entry.size, stat.size)
t.is(entry.perm, ~FILETYPE_FLAG & Number(stat.mode))
t.is(entry.type, 'FILE')
t.is(entry.type, EntryTypeName[EntryType.FILE] ?? null)
t.is(entry.link, null)
t.is(d.decode(entry.data), data)
t.true(entry.atime >= 0n)
t.true(entry.ctime >= 0n)
t.true(entry.mtime >= 0n)
t.true(entry.birthtime >= 0n)
i++
}

t.true(getNextEntry(t, entries, i) == null)
t.true(getNextEntry(t, entries, i, false) == null)
}

/**
Expand All @@ -121,17 +120,17 @@ const gitignoreCheck = (t, archivePath, opts, mode) => {
t.is(entry.path, '.gitignore')
t.is(entry.size, gitignoreFileStat.size)
t.is(entry.perm, ~FILETYPE_FLAG & Number(gitignoreFileStat.mode))
t.is(entry.type, 'FILE')
t.is(entry.type, EntryTypeName[EntryType.FILE] ?? null)
t.is(entry.link, null)
t.is(d.decode(entry.data), gitignoreFile)

entry = getNextEntry(t, entries, i++)
t.is(entry.path, '.prettierignore')
t.is(entry.type, 'SYMBOLIC_LINK')
t.is(entry.type, EntryTypeName[EntryType.SYMBOLIC_LINK] ?? null)
t.is(entry.link, '.gitignore')
t.is(entry.data.byteLength, 0)

t.true((Array.isArray(entries) ? entries[i] : entries.next().value) == null)
t.true(getNextEntry(t, entries, i, false) == null)
}

for (let archive of /** @type { (string | [string, string])[] } */ ([
Expand Down Expand Up @@ -301,7 +300,7 @@ test("Test extract's ignoreDotDir option", t => {
let iter = extract(archiveFile, { ignoreDotDir: false })
let entry = iter.next().value
t.is(entry?.path, '.')
t.is(entry?.type, 'DIR')
t.is(entry?.type, EntryTypeName[EntryType.DIR] ?? null)

iter = extract(archiveFile, { ignoreDotDir: true })
entry = iter.next().value
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
},
"compilerOptions": {
"lib": ["ESNext"],
"outDir": "src",
"strict": true,
"checkJs": true,
"allowJs": true,
Expand Down
14 changes: 4 additions & 10 deletions wasm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
ARG ARM=''
ARG SYSROOT='/emsdk/upstream/emscripten/cache/sysroot'

FROM docker.io/emscripten/emsdk:3.1.64${ARM} as base
FROM docker.io/emscripten/emsdk:3.1.67${ARM} as base

SHELL ["/bin/bash", "-euxc"]

# Work around bug in emscripten 3.1.62+, introduced in https://github.com/emscripten-core/emscripten/pull/21379
# that makes the compilation of libarchive fail with the following error:
# error: undefined symbol: __secs_to_zone (referenced by root reference (e.g. compiled C/C++ code))
COPY fix_tz.patch /root/
RUN patch -F5 -lp1 -d / -t </root/fix_tz.patch

RUN apt-get update -y && apt-get install -y pkg-config

# Change emscripten default compilation configs
Expand All @@ -31,10 +25,10 @@ WORKDIR /src
FROM base as mbedtls

# Download & de-compress
RUN curl -fsSL https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.6.0.tar.gz \
RUN curl -fsSL https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.6.1.tar.gz \
| tar -xzf- -C /src --strip-components 1

RUN curl -fsSL https://github.com/Mbed-TLS/mbedtls-framework/archive/750634d3a51eb9d61b59fd5d801546927c946588.tar.gz \
RUN curl -fsSL https://github.com/Mbed-TLS/mbedtls-framework/archive/94599c0e3b5036e086446a51a3f79640f70f22f6.tar.gz \
| tar -xzf- -C /src/framework --strip-components 1

# Fix bug with newer compilers due to missing \emptydescription
Expand Down Expand Up @@ -160,7 +154,7 @@ FROM base as libarchive
ARG SYSROOT

# Download & de-compress
RUN curl -fsSL https://github.com/libarchive/libarchive/releases/download/v3.7.4/libarchive-3.7.4.tar.xz \
RUN curl -fsSL https://github.com/libarchive/libarchive/releases/download/v3.7.5/libarchive-3.7.5.tar.xz \
| tar -xJf- -C /src --strip-components 1

# Patch to disable grzip and lrzip
Expand Down
9 changes: 5 additions & 4 deletions wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ if [ "$_manager" = 'podman' ]; then
fi

case "$(uname -m)" in
aarch64 | arm64)
_arm64='-arm64'
;;
aarch64 | arm64)
_arm64='-arm64'
;;
esac

$_manager build --network host --build-arg ARM="${_arm64:-}" "$@" -o "${_dist}/" "$__dir"

npx eslint --no-ignore --rule 'jsdoc/require-jsdoc: off' --fix "${_dist}/libarchive.mjs" >/dev/null || true
npx eslint --no-ignore --rule 'jsdoc/require-jsdoc: off' --rule 'prettier/prettier: off' --fix "${_dist}/libarchive.mjs" >/dev/null || true
npx prettier --write "${_dist}/libarchive.mjs"
sed -i.bak -e '/export default/d' "${_dist}/libarchive.mjs"
rm -f "${_dist}/libarchive.mjs.bak"
42 changes: 0 additions & 42 deletions wasm/fix_tz.patch

This file was deleted.

4 changes: 2 additions & 2 deletions wasm/include/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3007004
#define ARCHIVE_VERSION_NUMBER 3007005

#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
Expand Down Expand Up @@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_ONLY_STRING "3.7.4"
#define ARCHIVE_VERSION_ONLY_STRING "3.7.5"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);

Expand Down
8 changes: 7 additions & 1 deletion wasm/include/archive_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED

/* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3007004
#define ARCHIVE_VERSION_NUMBER 3007005

/*
* Note: archive_entry.h is for use outside of libarchive; the
Expand Down Expand Up @@ -259,9 +259,11 @@ __LA_DECL int archive_entry_gid_is_set(struct archive_entry *);
__LA_DECL const char *archive_entry_gname(struct archive_entry *);
__LA_DECL const char *archive_entry_gname_utf8(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
__LA_DECL void archive_entry_set_link_to_hardlink(struct archive_entry *);
__LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
__LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
__LA_DECL int archive_entry_hardlink_is_set(struct archive_entry *);
__LA_DECL la_int64_t archive_entry_ino(struct archive_entry *);
__LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *);
__LA_DECL int archive_entry_ino_is_set(struct archive_entry *);
Expand All @@ -275,6 +277,7 @@ __LA_DECL const char *archive_entry_pathname_utf8(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
__LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *);
__LA_DECL int archive_entry_perm_is_set(struct archive_entry *);
__LA_DECL int archive_entry_rdev_is_set(struct archive_entry *);
__LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
Expand All @@ -283,6 +286,7 @@ __LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);
__LA_DECL la_int64_t archive_entry_size(struct archive_entry *);
__LA_DECL int archive_entry_size_is_set(struct archive_entry *);
__LA_DECL const char *archive_entry_strmode(struct archive_entry *);
__LA_DECL void archive_entry_set_link_to_symlink(struct archive_entry *);
__LA_DECL const char *archive_entry_symlink(struct archive_entry *);
__LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *);
__LA_DECL int archive_entry_symlink_type(struct archive_entry *);
Expand Down Expand Up @@ -324,6 +328,8 @@ __LA_DECL void archive_entry_set_fflags(struct archive_entry *,
/* Note that all recognized tokens are processed, regardless. */
__LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *,
const char *);
__LA_DECL const char *archive_entry_copy_fflags_text_len(struct archive_entry *,
const char *, size_t);
__LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
const wchar_t *);
__LA_DECL void archive_entry_set_gid(struct archive_entry *, la_int64_t);
Expand Down

0 comments on commit 5fd7aa7

Please sign in to comment.